Schleifenproblem mit sleep geloest

This commit is contained in:
lukario 2021-04-18 12:21:32 +02:00
parent a410dc90ef
commit 1834211e89

View File

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