From 05cacfdc02b014d3974e20618c823efb44242ce9 Mon Sep 17 00:00:00 2001 From: David Rapan Date: Fri, 13 Dec 2024 18:42:12 +0100 Subject: [PATCH] fix: TOU entity stays enabled when disabled - Deye --- .../solarman/inverter_definitions/deye_hybrid.yaml | 4 +++- custom_components/solarman/inverter_definitions/deye_p3.yaml | 4 +++- custom_components/solarman/select.py | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/custom_components/solarman/inverter_definitions/deye_hybrid.yaml b/custom_components/solarman/inverter_definitions/deye_hybrid.yaml index 33788ae..937f98c 100644 --- a/custom_components/solarman/inverter_definitions/deye_hybrid.yaml +++ b/custom_components/solarman/inverter_definitions/deye_hybrid.yaml @@ -1681,7 +1681,9 @@ parameters: - key: 0x00C1 value: "Weekend" - key: 0x00FF - default: + value: "Week" + - bit: 0 + mode: single value: "Enabled" - name: "Program 1 Time" diff --git a/custom_components/solarman/inverter_definitions/deye_p3.yaml b/custom_components/solarman/inverter_definitions/deye_p3.yaml index ea562fc..0c2b9ac 100644 --- a/custom_components/solarman/inverter_definitions/deye_p3.yaml +++ b/custom_components/solarman/inverter_definitions/deye_p3.yaml @@ -897,7 +897,9 @@ parameters: - key: 0x00C1 value: "Weekend" - key: 0x00FF - default: + value: "Week" + - bit: 0 + mode: single value: "Enabled" - name: Program 1 Time diff --git a/custom_components/solarman/select.py b/custom_components/solarman/select.py index 21114aa..bb6d9db 100644 --- a/custom_components/solarman/select.py +++ b/custom_components/solarman/select.py @@ -50,7 +50,7 @@ def get_key(self, value: str): if self.dictionary: for o in self.dictionary: if o["value"] == value and (key := from_bit_index(o["bit"]) if "bit" in o else o["key"]) is not None: - return key if not self.mask else self._attr_value & (0xFFFFFFFF - self.mask) | key + return (key if not "mode" in o else (self._attr_value | key)) if not self.mask else (self._attr_value & (0xFFFFFFFF - self.mask) | key) return self.options.index(value)