From 2134f799683d0a2c60c283627347011d6522ddc8 Mon Sep 17 00:00:00 2001 From: Adrian Batzill Date: Sun, 12 Jan 2025 09:07:57 +0100 Subject: [PATCH] fix demand control range and remapping --- custom_components/aquarea/definitions.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/custom_components/aquarea/definitions.py b/custom_components/aquarea/definitions.py index 50e7572..60dfed5 100644 --- a/custom_components/aquarea/definitions.py +++ b/custom_components/aquarea/definitions.py @@ -355,12 +355,14 @@ def bit_to_bool(value: str) -> Optional[bool]: def read_demandcontrol(value: str) -> Optional[int]: i = float(value) if i >= 43 and i <= 234: - return round((i - 43) / (234 - 43) * 100) + i = (i - 43) / (234 - 43) + return round(i * 95) + 5 return None def write_demandcontrol(value: int) -> str: - return str(int(value / 100 * (234 - 43) + 43)) + value = (value - 5) / 95 # 5% -> 100% to 0% -> 95% for remapping + return str(int(value * (234 - 43) + 43)) def read_smart_grid_mode(value: str) -> str: @@ -645,7 +647,7 @@ def build_numbers(mqtt_prefix: str) -> list[HeishaMonNumberEntityDescription]: name="Demand Control", entity_category=EntityCategory.CONFIG, native_unit_of_measurement="%", - native_min_value=20, + native_min_value=5, native_max_value=100, native_step=5, state=read_demandcontrol,