Skip to content

Commit

Permalink
#93
Browse files Browse the repository at this point in the history
  • Loading branch information
magnuselden authored and magnuselden committed Dec 1, 2023
1 parent 9d58ff0 commit 2bbce54
Showing 1 changed file with 0 additions and 28 deletions.
28 changes: 0 additions & 28 deletions custom_components/peaqhvac/sensors/simple_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from custom_components.peaqhvac.const import HEATINGDEMAND, WATERDEMAND, NEXT_WATER_START, LATEST_WATER_BOOST
from custom_components.peaqhvac.sensors.sensorbase import SensorBase
from custom_components.peaqhvac.service.hvac.water_heater.models.group import Group
import logging

_LOGGER = logging.getLogger(__name__)
Expand All @@ -17,7 +16,6 @@ def __init__(self, hub, entry_id, name: str, internal_entity: str, icon: str = "
super().__init__(hub, self._attr_name, entry_id)
self._internal_entity = internal_entity
self._state = ""
self._groups = None

@property
def state(self) -> str:
Expand All @@ -32,35 +30,9 @@ async def async_update(self) -> None:
if ret is not None:
if self._internal_entity == NEXT_WATER_START:
self._state = self._set_next_start(ret)
self._groups = self._create_groups_display(self._hub.hvac.water_heater.booster.model.groups)
else:
self._state = ret

@property
def extra_state_attributes(self) -> dict:
attr_dict = {}
if self._internal_entity == NEXT_WATER_START:
attr_dict["groups"] = self._groups
return attr_dict

@staticmethod
def _create_groups_display(groups: list[Group]) -> dict:
def __set_group_hours(hours: list) -> list:
_ret = []
for h in hours:
if h > 23:
_ret.append(f"{h-24:02d}:00⁺¹")
else:
_ret.append(f"{h:02d}:00")
return _ret

ret = {}
for idx, g in enumerate(groups):
val = (g.group_type.value.capitalize(), __set_group_hours(g.hours))
#_LOGGER.debug(f"Group {idx}: {val}")
ret[idx]= val
return ret

@staticmethod
def _set_next_start(next_start: datetime) -> str:
if next_start > datetime.now() + timedelta(days=2):
Expand Down

0 comments on commit 2bbce54

Please sign in to comment.