Working activeProgram messages
This commit is contained in:
15
hc2mqtt
15
hc2mqtt
@@ -112,8 +112,12 @@ def client_connect(client, device, mqtt_topic):
|
||||
|
||||
host = device["host"]
|
||||
device_topics = topics
|
||||
active_program = False
|
||||
|
||||
for value in device["features"]:
|
||||
# If the device has the ActiveProgram feature it allows programs to be started and scheduled via /ro/activeProgram
|
||||
if "BSH.Common.Root.ActiveProgram" == device['features'][value]['name']:
|
||||
active_program = True
|
||||
if (
|
||||
"access" in device["features"][value]
|
||||
and "read" in device["features"][value]["access"].lower()
|
||||
@@ -132,6 +136,12 @@ def client_connect(client, device, mqtt_topic):
|
||||
mqtt_set_topic = mqtt_topic + "/set"
|
||||
print(now(), device["name"], f"set topic: {mqtt_set_topic}")
|
||||
client.subscribe(mqtt_set_topic)
|
||||
|
||||
if active_program:
|
||||
mqtt_active_program_topic = mqtt_topic + "/activeProgram"
|
||||
print(now(), device["name"], f"program topic: {mqtt_active_program_topic}")
|
||||
client.subscribe(mqtt_active_program_topic)
|
||||
|
||||
client.on_message = on_message
|
||||
|
||||
while True:
|
||||
@@ -156,11 +166,6 @@ def client_connect(client, device, mqtt_topic):
|
||||
if value is None:
|
||||
continue
|
||||
|
||||
# new_topic = topics[topic]
|
||||
# if new_topic == "remaining":
|
||||
# state["remainingseconds"] = value
|
||||
# value = "%d:%02d" % (value / 60 / 60, (value / 60) % 60)
|
||||
|
||||
new_topic = device_topics[topic]
|
||||
state[new_topic] = value
|
||||
update = True
|
||||
|
||||
Reference in New Issue
Block a user