Working activeProgram messages

This commit is contained in:
Meatballs1
2024-03-19 20:48:48 +00:00
parent bf168621f0
commit 8f54490dbb
2 changed files with 11 additions and 18 deletions

15
hc2mqtt
View File

@@ -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