Skip to content

Commit

Permalink
fix: set a default start_time if the device returns none
Browse files Browse the repository at this point in the history
  • Loading branch information
vanstinator committed Jun 6, 2023
1 parent f152557 commit 2bd646c
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions melnor_bluetooth/models/frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,11 @@ def start_time(self) -> time:
"""The start time of the watering"""

if self._attr_raw_start_time == 0:
return date.to_start_time(
int(datetime.now(tz=get_localzone()).timestamp())
).time()
self._attr_raw_start_time = date.from_start_time(datetime.now())

else:
# This date we get from the device, even with the time_shift, is always
# wrong but the time should be correcct
return date.to_start_time(self._attr_raw_start_time).time()
# This date we get from the device, even with the time_shift, is always
# wrong but the time should be correcct
return date.to_start_time(self._attr_raw_start_time).time()

@start_time.setter
def start_time(self, value: time) -> None:
Expand Down

0 comments on commit 2bd646c

Please sign in to comment.