Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle num_phases correctly, can be 1, 3, or auto, see #28 #35

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading