Skip to content

Commit

Permalink
Merge pull request #35 from jwillemsen/jwi-numphases2
Browse files Browse the repository at this point in the history
Handle num_phases correctly, can be 1, 3, or auto, see #28
  • Loading branch information
CJNE authored Jun 3, 2024
2 parents 73bdebe + 4542beb commit fcf1da0
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions pymyenergi/zappi.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,21 @@
"F": "Fault",
"U": "",
}
SINGLE_PHASE = "SINGLE_PHASE"
PHASES_STATES = {
"SINGLE_PHASE" : "1",
"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."""
Expand Down Expand Up @@ -249,11 +263,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):
Expand Down Expand Up @@ -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+"]:
Expand Down

0 comments on commit fcf1da0

Please sign in to comment.