forked from Chaospott/Heizberry
i to room
This commit is contained in:
parent
afae8b4016
commit
6e8ecf2977
@ -32,16 +32,16 @@ for i in range(len(rooms)):
|
|||||||
def on_connect(client, userdata, flags, rc):
|
def on_connect(client, userdata, flags, rc):
|
||||||
log.debug("Connected with result code " + str(rc))
|
log.debug("Connected with result code " + str(rc))
|
||||||
|
|
||||||
for i in rooms:
|
for room in rooms:
|
||||||
|
|
||||||
client.subscribe("room/" + i.name + "/heating/control/automatic")
|
client.subscribe("room/" + room.name + "/heating/control/automatic")
|
||||||
client.subscribe("room/" + i.name + "/heating/control/temperature")
|
client.subscribe("room/" + room.name + "/heating/control/temperature")
|
||||||
client.subscribe("room/" + i.name + "/heating/control/status")
|
client.subscribe("room/" + room.name + "/heating/control/status")
|
||||||
client.subscribe("room/" + i.name + "/heating/actor/temperature")
|
client.subscribe("room/" + room.name + "/heating/actor/temperature")
|
||||||
client.subscribe("room/" + i.name + "/heating/actor/status")
|
client.subscribe("room/" + room.name + "/heating/actor/status")
|
||||||
# client.subscribe("room/" + i.name + "/sensoren/tuer/status")
|
# client.subscribe("room/" + room.name + "/sensoren/tuer/status")
|
||||||
# client.subscribe("room/" + i.name + "/sensoren/fenster/status")
|
# client.subscribe("room/" + room.name + "/sensoren/fenster/status")
|
||||||
# client.subscribe("room/" + i.name + "/sensoren/temperature")
|
# client.subscribe("room/" + room.name + "/sensoren/temperature")
|
||||||
|
|
||||||
sendReadings()
|
sendReadings()
|
||||||
|
|
||||||
@ -59,29 +59,29 @@ def on_message(client, userdata, message):
|
|||||||
if message.topic.split("/", -1)[2] == "heating":
|
if message.topic.split("/", -1)[2] == "heating":
|
||||||
if message.topic.split("/", -1)[3] == "control":
|
if message.topic.split("/", -1)[3] == "control":
|
||||||
if message.topic.split("/", -1)[4] == "automatic":
|
if message.topic.split("/", -1)[4] == "automatic":
|
||||||
for i in rooms:
|
for room in rooms:
|
||||||
if message.topic.split("/", -1)[1] == i.name:
|
if message.topic.split("/", -1)[1] == room.name:
|
||||||
i.automatic = bool(msg)
|
room.automatic = bool(msg)
|
||||||
if message.topic.split("/", -1)[4] == "temperature":
|
if message.topic.split("/", -1)[4] == "temperature":
|
||||||
for i in rooms:
|
for room in rooms:
|
||||||
if message.topic.split("/", -1)[1] == i.name:
|
if message.topic.split("/", -1)[1] == room.name:
|
||||||
i.temperatureSet = round(float(msg),1)
|
room.temperatureSet = round(float(msg),1)
|
||||||
if message.topic.split("/", -1)[3] == "actor":
|
if message.topic.split("/", -1)[3] == "actor":
|
||||||
if message.topic.split("/", -1)[4] == "status":
|
if message.topic.split("/", -1)[4] == "status":
|
||||||
for i in rooms:
|
for room in rooms:
|
||||||
if message.topic.split("/", -1)[1] == i.name:
|
if message.topic.split("/", -1)[1] == room.name:
|
||||||
i.statusActual = bool(msg)
|
room.statusActual = bool(msg)
|
||||||
|
|
||||||
|
|
||||||
sendReadings()
|
sendReadings()
|
||||||
|
|
||||||
def sendReadings():
|
def sendReadings():
|
||||||
|
|
||||||
for i in rooms:
|
for room in rooms:
|
||||||
|
|
||||||
if i.automatic:
|
if room.automatic:
|
||||||
client.publish("room/" + i.name + "/heating/actor/temperature", i.temperatureSet, qos=1, retain=True)
|
client.publish("room/" + room.name + "/heating/actor/temperature", room.temperatureSet, qos=1, retain=True)
|
||||||
client.publish("room/" + i.name + "/heating/control/status", i.statusActual, qos=1, retain=True)
|
client.publish("room/" + room.name + "/heating/control/status", room.statusActual, qos=1, retain=True)
|
||||||
|
|
||||||
log.debug('sent readings')
|
log.debug('sent readings')
|
||||||
|
|
||||||
|
@ -28,9 +28,9 @@ for i in range(len(rooms)):
|
|||||||
def on_connect(client, userdata, flags, rc):
|
def on_connect(client, userdata, flags, rc):
|
||||||
log.debug("Connected with result code " + str(rc))
|
log.debug("Connected with result code " + str(rc))
|
||||||
|
|
||||||
for i in rooms:
|
for room in rooms:
|
||||||
client.subscribe("room/" + i.name + "/heating/actor/temperature")
|
client.subscribe("room/" + room.name + "/heating/actor/temperature")
|
||||||
client.subscribe("room/" + i.name + "/heating/actor/status")
|
client.subscribe("room/" + room.name + "/heating/actor/status")
|
||||||
|
|
||||||
sendReadings()
|
sendReadings()
|
||||||
|
|
||||||
@ -44,12 +44,12 @@ 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))
|
||||||
|
|
||||||
for i in rooms:
|
for room in rooms:
|
||||||
tmpThermostat = Thermostat(i.thermostat)
|
tmpThermostat = Thermostat(room.thermostat)
|
||||||
if message.topic.split("/", -1)[2] == "heating":
|
if message.topic.split("/", -1)[2] == "heating":
|
||||||
if message.topic.split("/", -1)[3] == "actor":
|
if message.topic.split("/", -1)[3] == "actor":
|
||||||
if message.topic.split("/", -1)[4] == "temperature":
|
if message.topic.split("/", -1)[4] == "temperature":
|
||||||
if message.topic.split("/", -1)[1] == i.name:
|
if message.topic.split("/", -1)[1] == room.name:
|
||||||
tmpThermostat.mode= 3
|
tmpThermostat.mode= 3
|
||||||
tmpThermostat.target_temperature = round(float(msg),1)
|
tmpThermostat.target_temperature = round(float(msg),1)
|
||||||
|
|
||||||
@ -60,15 +60,15 @@ def on_message(client, userdata, message):
|
|||||||
def sendReadings():
|
def sendReadings():
|
||||||
log.debug('read target temperature from thermostat')
|
log.debug('read target temperature from thermostat')
|
||||||
|
|
||||||
for i in rooms:
|
for room in rooms:
|
||||||
tmpThermostat = Thermostat(i.thermostat)
|
tmpThermostat = Thermostat(room.thermostat)
|
||||||
|
|
||||||
tmpThermostat.update()
|
tmpThermostat.update()
|
||||||
|
|
||||||
if tmpThermostat.target_temperature > 17.0:
|
if tmpThermostat.target_temperature > 17.0:
|
||||||
client.publish("room/" + i.name + "/heating/actor/status", 1, qos=1, retain=True)
|
client.publish("room/" + room.name + "/heating/actor/status", 1, qos=1, retain=True)
|
||||||
else:
|
else:
|
||||||
client.publish("room/" + i.name + "/heating/actor/status", 0, qos=1, retain=True)
|
client.publish("room/" + room.name + "/heating/actor/status", 0, qos=1, retain=True)
|
||||||
|
|
||||||
log.debug('sent readings')
|
log.debug('sent readings')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user