From 164f0c77ff69fe157d42ad6c1eb6e6078481e075 Mon Sep 17 00:00:00 2001 From: Francois JUMELLE Date: Mon, 27 Oct 2025 22:10:46 +0100 Subject: [PATCH] Get devices if not present in self.did --- plugin.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugin.py b/plugin.py index 23bc319..501234e 100755 --- a/plugin.py +++ b/plugin.py @@ -34,7 +34,7 @@ from datetime import datetime from enum import IntEnum 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 Parameters = Parameters # type: ignore #NOSONAR #pylint: disable=undefined-variable,self-assigning-variable @@ -227,7 +227,7 @@ class BasePlugin: def get_heatzy_devices(self): """Get the device id from the token, using the Heatzy API""" if self.token == "" or self.retry<0: - return "" + return self.did if len(self.did) == 0: Domoticz.Status("Heatzy Devide Id unknown, need to call Heatzy API.") @@ -246,7 +246,7 @@ class BasePlugin: #Domoticz.Error("URL: " + str(url)) #Domoticz.Error("Headers: " + str(headers)) #Domoticz.Error("Params: " + str(params)) - return "" + return self.did Domoticz.Debug("Get Device Id Response:" + str(response)) @@ -388,6 +388,9 @@ class BasePlugin: } #data = '{"raw": '+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"] url = f"https://euapi.gizwits.com/app/control/{did}" try: