feedback
This commit is contained in:
parent
da5506f432
commit
12bcbfcca4
@ -59,6 +59,7 @@ data:
|
||||
"street": { "topic": "homegear/instance1/plain/52/1/STATE", "label": "Strasse", "converter": "max" }
|
||||
},
|
||||
"output_topic": "homegear/instance1/set/42/1/SET_TEMPERATURE",
|
||||
"feedback_topic": "homegear/instance1/jsonobj/42/1",
|
||||
"output_converter": "max"
|
||||
},
|
||||
"wolfgang": {
|
||||
|
@ -24,11 +24,14 @@ class Box:
|
||||
self.windows = box_config['windows']
|
||||
self.output_converter = box_config['output_converter']
|
||||
self.output_topic = box_config['output_topic']
|
||||
# we use get here since this key is optional
|
||||
self.feedback_topic = box_config.get('feedback_topic')
|
||||
self.config = config
|
||||
|
||||
self.context = Context(high_temperature=config.DEFAULT_HIGH_TEMPERATURE,
|
||||
output_temperature=config.DEFAULT_HIGH_TEMPERATURE,
|
||||
mode='high',
|
||||
feedback={},
|
||||
window_state={ k: 'closed' for k in self.windows.keys() })
|
||||
|
||||
self.mqtt_client = None
|
||||
@ -89,6 +92,8 @@ class Box:
|
||||
self.context.maintenance_mode = payload.lower() == 'true'
|
||||
case [ primary_key ] if primary_key == 'status':
|
||||
pass
|
||||
case [ primary_key ] if primary_key == 'feedback':
|
||||
self.context.feedback = json.loads(payload)
|
||||
case _:
|
||||
raise Error(f"Unexcepted topic_key: {topic_key}, {payload}")
|
||||
|
||||
|
@ -45,6 +45,14 @@ def on_connect(client, userdata, flags, reason_code, properties):
|
||||
topic_mapping[topic] = (box, topic_key)
|
||||
logger.info(f"[{box.id}] Subscribed to '{topic}' (Key: '{topic_key}')")
|
||||
|
||||
# Subscribe feedback topic if one is available
|
||||
if box.feedback_topic:
|
||||
topic = box.feedback_topic
|
||||
topic_key = "feedback"
|
||||
client.subscribe(topic)
|
||||
topic_mapping[topic] = (box, topic_key)
|
||||
logger.info(f"[{box.id}] Subscribed to '{topic}' (Key: '{topic_key}')")
|
||||
|
||||
# Subscribe to central topics and create mappings
|
||||
for central_key, central_topic in config.CENTRAL_TOPICS.items():
|
||||
client.subscribe(central_topic)
|
||||
|
Loading…
x
Reference in New Issue
Block a user