Skip to content

Commit

Permalink
Add OTA updates API
Browse files Browse the repository at this point in the history
  • Loading branch information
SylvainPer authored Dec 7, 2024
1 parent 9e7bbc2 commit 6e0651d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Classes/WebServer/WebServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,35 @@ def rest_battery_state(self, verb, data, parameters):

_response["Data"] = json.dumps(_battEnv, sort_keys=True)
return _response

def rest_ota_firmware_available(self, verb, data, parameters):
_response = prepResponseMessage(self, setupHeadersResponse())
_response["Headers"]["Content-Type"] = "application/json; charset=utf-8"

if verb == "GET":
_fwAvail = []
for x in self.ListOfDevices:
if x == "0000":
continue

if "OTAUpdate" in self.ListOfDevices[x] and self.ListOfDevices[x]["OTAUpdate"] is not None:
for y in self.ListOfDevices[x]["OTAUpdate"]:
self.logging("Status", "AAA")
device = { 'zdevicename' : self.ListOfDevices[x]["ZDeviceName"],
'model' : self.ListOfDevices[x]["Model"],
'manufacturername' : self.ListOfDevices[x]["Manufacturer Name"],
'ieee' : self.ListOfDevices[x]["IEEE"],
'fwtype' : y,
'currentversion' : self.ListOfDevices[x]["OTAUpdate"][y]["currentversion"],
'newestversion' : self.ListOfDevices[x]["OTAUpdate"][y]["newestversion"],
'url' : self.ListOfDevices[x]["OTAUpdate"][y]["url"],
}
self.logging("Status", str(device))
_fwAvail.append(device)
self.logging("Status", str(_fwAvail))
_response["Data"] = json.dumps(_fwAvail, sort_keys=True)
return _response

def logging(self, logType, message):
self.log.logging("WebServer", logType, message)

Expand Down

0 comments on commit 6e0651d

Please sign in to comment.