This commit is contained in:
2025-08-26 12:27:39 +02:00
parent cb2e06684b
commit 017653d34c

View File

@@ -128,11 +128,11 @@ logging.info("script started")
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
client_id = "dasdasdasd333" client_id = "dasdasdasd333"
try: # try:
client = mqtt_client.Client(mqtt_client.CallbackAPIVersion.VERSION1, client_id) # client = mqtt_client.Client(mqtt_client.CallbackAPIVersion.VERSION1, client_id)
except: # except:
client = mqtt_client.Client() # client = mqtt_client.Client()
client.username_pw_set(mqtt_username, mqtt_password) # client.username_pw_set(mqtt_username, mqtt_password)
@@ -200,9 +200,9 @@ hm = socket.gethostbyaddr(BACKUP_HOST)
logging.info(_RESTORE) logging.info(_RESTORE)
def send_mqtt_message(topic,msg): def send_mqtt_message(topic,msg):
try: try:
client.connect(broker,1883,60) #client.connect(broker,1883,60)
client.publish(topic, json.dumps(msg)) client.publish(topic, json.dumps(msg))
client.disconnect() #client.disconnect()
logging.info(f"Message sent {topic}, {msg}") logging.info(f"Message sent {topic}, {msg}")
except ValueError as e: except ValueError as e:
logging.error("Failed to send") logging.error("Failed to send")