From 7af92d01eac87a35497fa38b8706f765222ad828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Seux?= Date: Thu, 19 Sep 2024 19:16:01 +0200 Subject: [PATCH] Fix SetDemandControl Since there is no way to get the current value of demandcontrol, HA listens to the same topic where we send the command. Thus when users set DemandControl to 20%, we send "81.2" via mqtt. HA reads that value and tries to cast it to an int. fix #252 --- custom_components/aquarea/definitions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/aquarea/definitions.py b/custom_components/aquarea/definitions.py index 2d20d14..9ad236d 100644 --- a/custom_components/aquarea/definitions.py +++ b/custom_components/aquarea/definitions.py @@ -353,14 +353,14 @@ def bit_to_bool(value: str) -> Optional[bool]: def read_demandcontrol(value: str) -> Optional[int]: - i = int(value) + i = float(value) if i >= 43 and i <= 234: return int((i - 43) / (234 - 43) * 100) return None def write_demandcontrol(value: int) -> str: - return str(value / 100 * (234 - 43) + 43) + return str(int(value / 100 * (234 - 43) + 43)) def read_smart_grid_mode(value: str) -> str: