Skip to content

Commit

Permalink
Cleaning up comment, linting
Browse files Browse the repository at this point in the history
  • Loading branch information
valleedelisle committed Dec 7, 2023
1 parent d16b4f9 commit 04406bc
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions custom_components/hilo/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
DEFAULT_ENERGY_METER_PERIOD,
DEFAULT_GENERATE_ENERGY_METERS,
DEFAULT_HQ_PLAN_NAME,
DEFAULT_PRE_COLD_PHASE,
DEFAULT_SCAN_INTERVAL,
DEFAULT_UNTARIFICATED_DEVICES,
DOMAIN,
Expand Down Expand Up @@ -660,15 +659,24 @@ def state(self):
return "scheduled"
else:
return "off"
elif datetime.now(timezone.utc) > self._next_events[0].phases.recovery_start:
elif (
datetime.now(timezone.utc) > self._next_events[0].phases.recovery_start
):
return "recovery"
elif datetime.now(timezone.utc) > self._next_events[0].phases.reduction_start:
elif (
datetime.now(timezone.utc) > self._next_events[0].phases.reduction_start
):
return "reduction"
elif datetime.now(timezone.utc) > self._next_events[0].phases.preheat_start:
return "pre_heat"
elif datetime.now(timezone.utc) > self._next_events[0].phases.appreciation_start:
elif (
datetime.now(timezone.utc)
> self._next_events[0].phases.appreciation_start
):
return "appreciation"
elif datetime.now(timezone.utc) > self._next_events[0].phases.appreciation_start - timedelta(hours = CONF_PRE_COLD_PHASE):
elif datetime.now(timezone.utc) > self._next_events[
0
].phases.appreciation_start - timedelta(hours=CONF_PRE_COLD_PHASE):
return "pre_cold"
else:
return "scheduled"
Expand Down Expand Up @@ -729,10 +737,11 @@ async def _async_update(self):
new_events.append(event.as_dict())

self._next_events = []

if len(new_events):
self._next_events = new_events
#we don't update the state here anymore, since it's now calculated in the "state"
# NOTE(ic-dev21): we don't update the state here anymore,
# since it's now calculated in the "state"


class DeviceSensor(HiloEntity, SensorEntity):
Expand Down

0 comments on commit 04406bc

Please sign in to comment.