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