if DE.changed_device_name == "Test Python" and DE.Devices["Test Python"].n_value_string == "On":
client = mqtt.Client(clientID) #create new instance
rc= client.connect(Broker,PortaBroker,KeepAliveBroker) #connect to broker
if rc != 0: print("[E-STATUS] Connection au Broker. Resultat de la Connection: " + str(rc))
if CodePG == '' : CodePG = 'Re-Init' # si ESP recoit ce message il renverra un nouveau code sans ouvrir la porte!
client.publish("home/domoticz/PG/Dz2PG", CodePG, qos=0, retain=False) #publish message
# initialisation de la User Variable avant reception du nouveau code
url= "http://192.168.0.45:18080/json.htm?type=command¶m=updateuservariable&vname=NewCodePG&vtype=string&vvalue="
CLE64 = {"Authorization" : "Basic RG9tb0JvZ2dpejpEUyFhZnMhYWZ5MTk1MA=="}
rc = requests.get(url, headers= CLE64)
if rc != 0: print("[E-INIT User Variable] erreur: " + str(rc))`
This code works fine, the user variable is correctly initialized but a minute later, Domoticz froze with the error above (title).
An idea ?
Hello, I currently upgraded from 2023.1 to 2024.4 because problems with Python & Paho MQTT. Some of them are resolved but not this one :
`import sys sys.path.append('/usr/local/lib/python3.9/dist-packages/') import DomoticzEvents as DE # voir https://www.domoticz.com/wiki/Python_Events import requests # https://fr.python-requests.org/en/latest/user/quickstart.html from requests.auth import HTTPBasicAuth from paho.mqtt import client as mqtt
Broker = "192.168.0.45" PortaBroker = 11883 KeepAliveBroker = 60 clientID = "Boggiz"
CodePG = DE.user_variables["NewCodePG"]
if DE.changed_device_name == "Test Python" and DE.Devices["Test Python"].n_value_string == "On": client = mqtt.Client(clientID) #create new instance
This code works fine, the user variable is correctly initialized but a minute later, Domoticz froze with the error above (title). An idea ?