Skip to content

Commit

Permalink
💄 Applied black linter
Browse files Browse the repository at this point in the history
  • Loading branch information
kamaradclimber committed Nov 1, 2023
1 parent 19f8071 commit 801d6a9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 6 additions & 3 deletions custom_components/aquarea/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ async def async_setup_entry(
def compute_cop(values) -> Optional[float]:
assert len(values) == 24
production = extract_sum(values[18:21] + values[12:15] + values[0:3] + values[6:9])
consumption = extract_sum(values[21:24] + values[15:18] + values[3:6] + values[9:12])
consumption = extract_sum(
values[21:24] + values[15:18] + values[3:6] + values[9:12]
)
if consumption == 0:
return 0
cop = production / consumption
Expand All @@ -189,12 +191,13 @@ def compute_cop(values) -> Optional[float]:
return 0
return round(cop, 2)


def extract_sum(values):
def chunks3(lst):
for i in range(0, len(lst), 3):
yield lst[i:i+3]
yield lst[i : i + 3]

for (i, candidate) in enumerate(chunks3(values)):
for i, candidate in enumerate(chunks3(values)):
if len(list(filter(lambda el: el is not None, candidate))) > 0:
_LOGGER.debug(f"Chunk {i} {candidate} has data")
return sum(filter(lambda el: el is not None, candidate))
Expand Down
10 changes: 8 additions & 2 deletions custom_components/aquarea/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,15 @@ async def async_added_to_hass(self) -> None:
def message_received(message):
"""Handle new MQTT messages."""

if self.stats_firmware_contain_version == False and message.topic == self.marker3_2_topic:
if (
self.stats_firmware_contain_version == False
and message.topic == self.marker3_2_topic
):
self._attr_installed_version = "3.2"
if self.stats_firmware_contain_version == False and message.topic == self.marker3_1_and_before_topic:
if (
self.stats_firmware_contain_version == False
and message.topic == self.marker3_1_and_before_topic
):
self._attr_installed_version = "<= 3.1"
if message.topic == self.entity_description.heishamon_topic_id:
field_value = json.loads(message.payload).get("version", None)
Expand Down

0 comments on commit 801d6a9

Please sign in to comment.