Skip to content

Commit

Permalink
Added fix to target time when pending approval
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-r committed Jan 2, 2024
1 parent 40054ce commit a85dc55
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions custom_components/ohme/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, coordinator, hass: HomeAssistant, client):

self._client = client

self._state = 0
self._state = None
self._last_updated = None
self._attributes = {}

Expand Down Expand Up @@ -64,11 +64,12 @@ def icon(self):
@property
def native_value(self):
"""Get value from data returned from API by coordinator"""
if self.coordinator.data and self.coordinator.data['appliedRule']:
# Make sure we're not pending approval, as this sets the target time to now
if self.coordinator.data and self.coordinator.data['appliedRule'] and self.coordinator.data['mode'] != "PENDING_APPROVAL":
target = self.coordinator.data['appliedRule']['targetTime']
return dt_time(
self._state = dt_time(
hour=target // 3600,
minute=(target % 3600) // 60,
second=0
)
return None
return self._state

0 comments on commit a85dc55

Please sign in to comment.