2 Commits
0.0.26 ... main

Author SHA1 Message Date
626b8edc88 feedback
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-11-24 15:58:51 +01:00
c5ed655399 feedback
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-11-24 15:56:18 +01:00

View File

@ -73,6 +73,7 @@ class Box:
try:
# match topic to find operation to be executed
send_command = True
match topic_key.split('/'):
case [ primary_key, sub_key ] if primary_key == 'window':
self.context.window_state[sub_key] = CONVERTERS["window_contact_input"][self.windows[sub_key]["converter"]](payload)
@ -91,9 +92,12 @@ class Box:
case [ primary_key ] if primary_key == 'maintenance_mode':
self.context.maintenance_mode = payload.lower() == 'true'
case [ primary_key ] if primary_key == 'status':
send_command = False
pass
case [ primary_key ] if primary_key == 'feedback':
self.context.feedback = json.loads(payload)
# merge the both dicts
self.context.feedback |= json.loads(payload)
send_command = False
case _:
raise Error(f"Unexcepted topic_key: {topic_key}, {payload}")
@ -101,12 +105,14 @@ class Box:
self._calculate_output_temperature()
# publish output temperature
result_message = CONVERTERS["target_temperature_output"][self.output_converter](self.context.output_temperature)
publish_topic = self.output_topic
self.mqtt_client.publish(publish_topic, result_message)
logger.info(f"[Box {self.id}] Result published on '{publish_topic}': {result_message}")
if send_command:
# publish output temperature
result_message = CONVERTERS["target_temperature_output"][self.output_converter](self.context.output_temperature)
publish_topic = self.output_topic
self.mqtt_client.publish(publish_topic, result_message)
logger.info(f"[Box {self.id}] Result published on '{publish_topic}': {result_message}")
# send context in any case
context_topic = f"{self.config.CONTEXT_TOPIC_PREFIX}{self.id}"
self.mqtt_client.publish(context_topic, str(self.context))
except Exception as e: