Skip to content

Commit

Permalink
Merge pull request #50 from sbabcock23/updateunits
Browse files Browse the repository at this point in the history
updated units for sleep and nap measurements
  • Loading branch information
sbabcock23 authored Jun 21, 2022
2 parents d8b0d21 + 57200b3 commit 1de6f84
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ Turns on the collar light after dark if the pet is not home.
* Enable possibility of if pet not home and not with owner then trigger lost dog mode

# Version History
## 0.0.14
* Fix - fixed sleep and nap units from hours to minutes with proper conversion
## 0.0.13
* Enhancement - Added Sleep and Nap "sensors"/attributes based on new version of pytryfi
## 0.0.12
Expand Down
2 changes: 1 addition & 1 deletion custom_components/tryfi/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "tryfi",
"name": "TryFi",
"version": "0.0.12",
"version": "0.0.14",
"config_flow": true,
"documentation": "https://github.com/sbabcock23/hass-tryfi",
"issue_tracker": "https://github.com/sbabcock23/hass-tryfi/issues",
Expand Down
14 changes: 7 additions & 7 deletions custom_components/tryfi/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
DEVICE_CLASS_BATTERY,
LENGTH_KILOMETERS,
PERCENTAGE,
TIME_HOURS,
TIME_MINUTES,
STATE_OK,
STATE_PROBLEM,
)
Expand Down Expand Up @@ -177,18 +177,18 @@ def state(self):
return round(self.pet.monthlyTotalDistance / 1000, 2)
elif self.statType.upper() == "NAP":
if self.statTime.upper() == "DAILY":
return self.pet.dailyNap
return round(self.pet.dailyNap / 60, 2)
elif self.statTime.upper() == "WEEKLY":
return self.pet.weeklyNap
return round(self.pet.weeklyNap / 60, 2)
elif self.statTime.upper() == "MONTHLY":
return self.pet.monthlyNap
return round(self.pet.monthlyNap / 60, 2)
elif self.statType.upper() == "SLEEP":
if self.statTime.upper() == "DAILY":
return self.pet.dailySleep
return round(self.pet.dailySleep / 60, 2)
elif self.statTime.upper() == "WEEKLY":
return self.pet.weeklySleep
return round(self.pet.weeklySleep / 60, 2)
elif self.statTime.upper() == "MONTHLY":
return self.pet.monthlySleep
return round(self.pet.monthlySleep / 60, 2)
else:
return None

Expand Down

0 comments on commit 1de6f84

Please sign in to comment.