Skip to content

Commit

Permalink
Merge pull request #271 from b3nn0/fix-demand-control
Browse files Browse the repository at this point in the history
  • Loading branch information
kamaradclimber authored Jan 12, 2025
2 parents 8301f21 + 2134f79 commit 0c62278
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions custom_components/aquarea/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 0c62278

Please sign in to comment.