Working activeProgram messages
This commit is contained in:
14
HCDevice.py
14
HCDevice.py
@@ -117,7 +117,6 @@ class HCDevice:
|
|||||||
raise Exception(f"{self.name}. Unable to configure appliance. Program UID {uid} is not a valid program.")
|
raise Exception(f"{self.name}. Unable to configure appliance. Program UID {uid} is not a valid program.")
|
||||||
|
|
||||||
if 'options' in data:
|
if 'options' in data:
|
||||||
## TODO: Check to see if options is mandatory
|
|
||||||
for option_uid in data['options']:
|
for option_uid in data['options']:
|
||||||
if str(option_uid) not in self.features:
|
if str(option_uid) not in self.features:
|
||||||
raise Exception(f"{self.name}. Unable to configure appliance. Option UID {uid} is not valid for this device.")
|
raise Exception(f"{self.name}. Unable to configure appliance. Option UID {uid} is not valid for this device.")
|
||||||
@@ -233,7 +232,7 @@ class HCDevice:
|
|||||||
# Raises exception on failure
|
# Raises exception on failure
|
||||||
self.test_program_data(data)
|
self.test_program_data(data)
|
||||||
|
|
||||||
msg["data"] = [data]
|
msg["data"] = [data]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.ws.send(msg)
|
self.ws.send(msg)
|
||||||
@@ -325,17 +324,6 @@ class HCDevice:
|
|||||||
self.services[service["service"]] = {
|
self.services[service["service"]] = {
|
||||||
"version": service["version"],
|
"version": service["version"],
|
||||||
}
|
}
|
||||||
# print(self.name, now(), "services", self.services)
|
|
||||||
|
|
||||||
# we should figure out which ones to query now
|
|
||||||
# if "iz" in self.services:
|
|
||||||
# self.get("/iz/info", version=self.services["iz"]["version"])
|
|
||||||
# if "ni" in self.services:
|
|
||||||
# self.get("/ni/info", version=self.services["ni"]["version"])
|
|
||||||
# if "ei" in self.services:
|
|
||||||
# self.get("/ei/deviceReady", version=self.services["ei"]["version"], action="NOTIFY")
|
|
||||||
|
|
||||||
# self.get("/if/info")
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print(now(), self.name, "Unknown", msg)
|
print(now(), self.name, "Unknown", msg)
|
||||||
|
|||||||
15
hc2mqtt
15
hc2mqtt
@@ -112,8 +112,12 @@ def client_connect(client, device, mqtt_topic):
|
|||||||
|
|
||||||
host = device["host"]
|
host = device["host"]
|
||||||
device_topics = topics
|
device_topics = topics
|
||||||
|
active_program = False
|
||||||
|
|
||||||
for value in device["features"]:
|
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 (
|
if (
|
||||||
"access" in device["features"][value]
|
"access" in device["features"][value]
|
||||||
and "read" in device["features"][value]["access"].lower()
|
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"
|
mqtt_set_topic = mqtt_topic + "/set"
|
||||||
print(now(), device["name"], f"set topic: {mqtt_set_topic}")
|
print(now(), device["name"], f"set topic: {mqtt_set_topic}")
|
||||||
client.subscribe(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
|
client.on_message = on_message
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
@@ -156,11 +166,6 @@ def client_connect(client, device, mqtt_topic):
|
|||||||
if value is None:
|
if value is None:
|
||||||
continue
|
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]
|
new_topic = device_topics[topic]
|
||||||
state[new_topic] = value
|
state[new_topic] = value
|
||||||
update = True
|
update = True
|
||||||
|
|||||||
Reference in New Issue
Block a user