Skip to content

Commit

Permalink
Tweaks to _is_on fix
Browse files Browse the repository at this point in the history
  • Loading branch information
megakid authored Jun 8, 2023
1 parent ba7d1f6 commit bb3c8b0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions custom_components/octopus_intelligent/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ def __init__(self, hass, octopus_system, name : str, store_attributes : bool = F
self._octopus_system = octopus_system
self._store_attributes = store_attributes
self._look_ahead_mins = look_ahead_mins
self._timer = async_track_utc_time_change(
hass, self.timer_update, minute=range(0, 60, 30), second=1)

self._attributes = {}
self._is_on = self._is_off_peak()

super().__init__(octopus_system)
self._timer = async_track_utc_time_change(
hass, self.timer_update, minute=range(0, 60, 30), second=1)

def _is_off_peak(self):
mins_looked = 0
Expand Down Expand Up @@ -129,13 +129,13 @@ def __init__(self, hass, octopus_system, name : str) -> None:
self._name = name
self._unique_id = slugify(name)
self._octopus_system = octopus_system
self._timer = async_track_utc_time_change(
hass, self.timer_update, minute=range(0, 60, 30), second=1)

self._attributes = {}
self._is_on = self._octopus_system.is_off_peak_charging_now()

super().__init__(octopus_system)

self._timer = async_track_utc_time_change(
hass, self.timer_update, minute=range(0, 60, 30), second=1)

@callback
def _handle_coordinator_update(self) -> None:
"""Handle updated data from the coordinator."""
Expand Down

0 comments on commit bb3c8b0

Please sign in to comment.