From 1d7ea9ca6940e24114ef9df1bdea2474b2085975 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Thu, 25 Apr 2024 15:31:32 +0200 Subject: [PATCH 1/2] Handle num_phases correctly, can be 1, 3, or auto, see #28 * pymyenergi/zappi.py: --- pymyenergi/zappi.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pymyenergi/zappi.py b/pymyenergi/zappi.py index 69acadb..eedd63d 100644 --- a/pymyenergi/zappi.py +++ b/pymyenergi/zappi.py @@ -14,7 +14,11 @@ "F": "Fault", "U": "", } -SINGLE_PHASE = "SINGLE_PHASE" +PHASES_STATES = { + "SINGLE_PHASE" : "1", + "THREE_PHASE" : "3", + "AUTO" : "auto", +} class Zappi(BaseDevice): """Zappi Client for myenergi API.""" @@ -249,11 +253,7 @@ def zsl(self): @property def num_phases(self): - phases = self._data.get("phaseSetting", 1) - if phases == SINGLE_PHASE: - return 1 - else: - return 3 + return PHASES_STATES.get(self._data.get("phaseSetting", "1"), "") @property def update_available(self): From 4542beba33fdc0590ceb4c0c0a2d22cfe9c815a3 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Fri, 10 May 2024 17:30:05 +0200 Subject: [PATCH 2/2] Implement set_phase_setting * pymyenergi/zappi.py: --- pymyenergi/zappi.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pymyenergi/zappi.py b/pymyenergi/zappi.py index eedd63d..24387b7 100644 --- a/pymyenergi/zappi.py +++ b/pymyenergi/zappi.py @@ -19,6 +19,16 @@ "THREE_PHASE" : "3", "AUTO" : "auto", } +PHASES_STRINGS = { + "1" : "SINGLE_PHASE", + "3" : "THREE_PHASE", + "auto" : "AUTO", +} +PHASE_SETTING = { + "1" : 0, + "3" : 1, + "auto" : 2, +} class Zappi(BaseDevice): """Zappi Client for myenergi API.""" @@ -343,6 +353,17 @@ async def set_minimum_green_level(self, level): self._data["mgl"] = level return True + async def set_phase_setting(self, phase): + """Set phase setting, can be set 1/3/auto""" + phasesetting_int = PHASE_SETTING.get(phase) + await self._connection.get( + f"/cgi-zappi-phase-setting-Z{self._serialno}-{phasesetting_int}" + ) + # Set local data if successful + self._data["num_phases"] = PHASES_STRINGS.get(phase) + return True + + async def start_boost(self, amount): """Start boost""" if self.charge_mode not in ["Eco", "Eco+"]: