Skip to content

Commit

Permalink
Allow charging schedule configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
nanomad committed Apr 11, 2024
1 parent 59421a8 commit de5c6cf
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions wallbox/wallbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,49 @@ def setIcpMaxCurrent(self, chargerId, newIcpMaxCurrentValue):
except requests.exceptions.HTTPError as err:
raise (err)
return json.loads(response.text)

def getChargerSchedules(self, chargerId):
try:
response = requests.get(
f"{self.baseUrl}chargers/{chargerId}/schedules", headers=self.headers,
timeout=self._requestGetTimeout
)
response.raise_for_status()
except requests.exceptions.HTTPError as err:
raise (err)
return json.loads(response.text)

"""
Example request:
{
'schedules': [{
'id': 0,
'chargerId': 42,
'enable': 1,
'max_current': 1,
'max_energy': 0,
'days': {'friday': True, 'monday': True, 'saturday': True, 'sunday': True, 'thursday': True,
'tuesday': True, 'wednesday': True},
'start': '2100',
'stop': '0500'
}]
}
Where id is the position to add/replace
"""

def setChargerSchedules(self, chargerId, newSchedules):
try:
# Enforce chargerId
for s in newSchedules.get('schedules', []):
s['chargerId'] = chargerId

response = requests.post(
f"{self.baseUrl}chargers/{chargerId}/schedules",
headers=self.headers,
json=newSchedules,
)
response.raise_for_status()
except requests.exceptions.HTTPError as err:
raise (err)
return json.loads(response.text)

0 comments on commit de5c6cf

Please sign in to comment.