Skip to content
Closed
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
51 changes: 16 additions & 35 deletions e3dc/_e3dc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2397,39 +2397,20 @@ def set_weather_regulated_charge(self, enable: bool, keepAlive: bool = False):
0 if success
-1 if error
"""
if enable:
res = self.sendRequest(
(
RscpTag.EMS_REQ_SET_POWER_SETTINGS,
RscpType.Container,
[
(
RscpTag.EMS_WEATHER_REGULATED_CHARGE_ENABLED,
RscpType.UChar8,
1,
)
],
),
keepAlive=keepAlive,
)
else:
res = self.sendRequest(
(
RscpTag.EMS_REQ_SET_POWER_SETTINGS,
RscpType.Container,
[
(
RscpTag.EMS_WEATHER_REGULATED_CHARGE_ENABLED,
RscpType.UChar8,
0,
)
],
),
keepAlive=keepAlive,
)
res = self.sendRequest(
(
RscpTag.EMS_REQ_SET_POWER_SETTINGS,
RscpType.Container,
[
(
RscpTag.EMS_WEATHER_REGULATED_CHARGE_ENABLED,
RscpType.UChar8,
enable,
)
],
),
keepAlive=keepAlive,
)

# validate return code for EMS_RES_WEATHER_REGULATED_CHARGE_ENABLED is 0
if res[2][0][2] == 0:
return 0
else:
return -1
# validate return code for EMS_RES_WEATHER_REGULATED_CHARGE_ENABLED being equal to requested new state
return res[2][0][2] == enable