Get devices if not present in self.did

This commit is contained in:
2025-10-27 22:10:46 +01:00
parent 70f4fafbfd
commit 164f0c77ff

View File

@@ -34,7 +34,7 @@ from datetime import datetime
from enum import IntEnum from enum import IntEnum
import requests import requests
import DomoticzEx as Domoticz # type: ignore import DomoticzEx as Domoticz #pylint: disable=import-error #pyright:ignore
if None is not None: #Fake statement to remove warning on global Domoticz variables #NOSONAR if None is not None: #Fake statement to remove warning on global Domoticz variables #NOSONAR
Parameters = Parameters # type: ignore #NOSONAR #pylint: disable=undefined-variable,self-assigning-variable Parameters = Parameters # type: ignore #NOSONAR #pylint: disable=undefined-variable,self-assigning-variable
@@ -227,7 +227,7 @@ class BasePlugin:
def get_heatzy_devices(self): def get_heatzy_devices(self):
"""Get the device id from the token, using the Heatzy API""" """Get the device id from the token, using the Heatzy API"""
if self.token == "" or self.retry<0: if self.token == "" or self.retry<0:
return "" return self.did
if len(self.did) == 0: if len(self.did) == 0:
Domoticz.Status("Heatzy Devide Id unknown, need to call Heatzy API.") Domoticz.Status("Heatzy Devide Id unknown, need to call Heatzy API.")
@@ -246,7 +246,7 @@ class BasePlugin:
#Domoticz.Error("URL: " + str(url)) #Domoticz.Error("URL: " + str(url))
#Domoticz.Error("Headers: " + str(headers)) #Domoticz.Error("Headers: " + str(headers))
#Domoticz.Error("Params: " + str(params)) #Domoticz.Error("Params: " + str(params))
return "" return self.did
Domoticz.Debug("Get Device Id Response:" + str(response)) Domoticz.Debug("Get Device Id Response:" + str(response))
@@ -388,6 +388,9 @@ class BasePlugin:
} }
#data = '{"raw": '+mode_str[mode]+'}' #data = '{"raw": '+mode_str[mode]+'}'
data = '{"attrs": {"mode":' + str(mode_str[mode]) + '}}' data = '{"attrs": {"mode":' + str(mode_str[mode]) + '}}'
if deviceid not in self.did:
#Should not occur... but it occurs sometimes
self.did = self.get_heatzy_devices()
did = self.did[deviceid]["did"] did = self.did[deviceid]["did"]
url = f"https://euapi.gizwits.com/app/control/{did}" url = f"https://euapi.gizwits.com/app/control/{did}"
try: try: