Teste Singleconnect, weil mehrere Verbindungen nicht moeglich sind

This commit is contained in:
lukario 2021-04-18 11:20:03 +02:00
parent 99415291ea
commit 8eba2c198c

View File

@ -18,7 +18,7 @@ class Zimmer:
zimmer = [Zimmer, Zimmer] zimmer = [Zimmer, Zimmer]
zimmerName = ["alexander", "wohnzimmer" ] zimmerName = ["alexander", "wohnzimmer" ]
zimmerThermostat = [Thermostat('00:1A:22:16:4B:B4'), Thermostat('00:1A:22:16:25:C3')] zimmerThermostat = ["00:1A:22:16:4B:B4", "00:1A:22:16:25:C3"]
for i in range(len(zimmer)): for i in range(len(zimmer)):
zimmer[i].name = zimmerName[i] zimmer[i].name = zimmerName[i]
@ -48,8 +48,9 @@ def on_message(client, userdata, message):
if message.topic.split("/", -1)[3] == "temperatur": if message.topic.split("/", -1)[3] == "temperatur":
for i in zimmer: for i in zimmer:
if message.topic.split("/", -1)[1] == i.name: if message.topic.split("/", -1)[1] == i.name:
i.thermostat.mode= 3 tmpThermostat = Thermostat(i.thermostat)
i.thermostat.target_temperature = round(float(msg),1) tmpThermostat.mode= 3
tmpThermostat.target_temperature = round(float(msg),1)
sendReadings() sendReadings()
@ -60,10 +61,12 @@ def sendReadings():
log.debug('read target temperature from thermostats') log.debug('read target temperature from thermostats')
for i in zimmer: for i in zimmer:
tmpThermostat = Thermostat(i.thermostat)
i.thermostat.update()
if i.thermostat.target_temperature > 17.0: tmpThermostat.update()
if tmpThermostat.target_temperature > 17.0:
client.publish("zimmer/" + i.name + "/heizung/status", 1, qos=1, retain=True) client.publish("zimmer/" + i.name + "/heizung/status", 1, qos=1, retain=True)
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)