New feature: selecting program

This commit is contained in:
Dis90
2024-07-20 23:34:47 +03:00
parent d6ef327344
commit 9afcc3da8e
2 changed files with 11 additions and 0 deletions

View File

@@ -266,6 +266,9 @@ class HCDevice:
elif resource == "/ro/activeProgram":
# Raises exception on failure
self.test_program_data(data)
elif resource == "/ro/selectedProgram":
# Raises exception on failure
self.test_program_data(data)
msg["data"] = data

View File

@@ -64,6 +64,12 @@ def hc2mqtt(
mqtt_active_program_topic = f"{mqtt_prefix}{device['name']}/activeProgram"
print(now(), device["name"], f"program topic: {mqtt_active_program_topic}")
client.subscribe(mqtt_active_program_topic)
# If the device has the SelectedProgram feature it allows programs to be selected
# via /ro/selectedProgram
if "BSH.Common.Root.SelectedProgram" == device["features"][value]["name"]:
mqtt_selected_program_topic = f"{mqtt_prefix}{device['name']}/selectedProgram"
print(now(), device["name"], f"program topic: {mqtt_selected_program_topic}")
client.subscribe(mqtt_selected_program_topic)
else:
print(now(), f"ERROR MQTT connection failed: {rc}")
@@ -91,6 +97,8 @@ def hc2mqtt(
resource = "/ro/values"
elif topic == "activeProgram":
resource = "/ro/activeProgram"
elif topic == "selectedProgram":
resource = "/ro/selectedProgram"
else:
raise Exception(f"Payload topic {topic} is unknown.")