Schleifenproblem mit sleep geloest

This commit is contained in:
lukario 2021-04-18 12:21:32 +02:00
parent a410dc90ef
commit 1834211e89
1 changed files with 5 additions and 10 deletions

View File

@ -16,7 +16,7 @@ class Zimmer:
thermostat = None
zimmer = [Zimmer, Zimmer]
zimmer = [Zimmer(), Zimmer()]
zimmerName = ["alexander", "wohnzimmer" ]
zimmerThermostat = ["00:1A:22:16:4B:B4", "00:1A:22:16:25:C3"]
@ -44,17 +44,14 @@ def on_message(client, userdata, message):
msg = message.payload.decode("utf-8")
log.debug('received message: %s from %s', format(msg), format(message.topic))
if message.topic.split("/", -1)[2] == "heizung":
if message.topic.split("/", -1)[3] == "temperatur":
for i in zimmer:
tmpThermostat = Thermostat(i.thermostat)
for i in zimmer:
tmpThermostat = Thermostat(i.thermostat)
if message.topic.split("/", -1)[2] == "heizung":
if message.topic.split("/", -1)[3] == "temperatur":
if message.topic.split("/", -1)[1] == i.name:
tmpThermostat.mode= 3
tmpThermostat.target_temperature = round(float(msg),1)
time.sleep(10)
sendReadings()
@ -72,8 +69,6 @@ def sendReadings():
else:
client.publish("zimmer/" + i.name + "/heizung/status", 0, qos=1, retain=True)
time.sleep(10)
log.debug('sent readings')