Skip to content

Commit 0c62278

Browse files
Merge pull request #271 from b3nn0/fix-demand-control
2 parents 8301f21 + 2134f79 commit 0c62278

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

custom_components/aquarea/definitions.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,14 @@ def bit_to_bool(value: str) -> Optional[bool]:
355355
def read_demandcontrol(value: str) -> Optional[int]:
356356
i = float(value)
357357
if i >= 43 and i <= 234:
358-
return round((i - 43) / (234 - 43) * 100)
358+
i = (i - 43) / (234 - 43)
359+
return round(i * 95) + 5
359360
return None
360361

361362

362363
def write_demandcontrol(value: int) -> str:
363-
return str(int(value / 100 * (234 - 43) + 43))
364+
value = (value - 5) / 95 # 5% -> 100% to 0% -> 95% for remapping
365+
return str(int(value * (234 - 43) + 43))
364366

365367

366368
def read_smart_grid_mode(value: str) -> str:
@@ -645,7 +647,7 @@ def build_numbers(mqtt_prefix: str) -> list[HeishaMonNumberEntityDescription]:
645647
name="Demand Control",
646648
entity_category=EntityCategory.CONFIG,
647649
native_unit_of_measurement="%",
648-
native_min_value=20,
650+
native_min_value=5,
649651
native_max_value=100,
650652
native_step=5,
651653
state=read_demandcontrol,

0 commit comments

Comments
 (0)