Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
adcc5a86f8
|
|||
39adf907b1
|
@ -26,20 +26,65 @@ data:
|
|||||||
BOXES: |
|
BOXES: |
|
||||||
{
|
{
|
||||||
"box1": {
|
"box1": {
|
||||||
"label": "living_room",
|
"label": "patty",
|
||||||
"windows": [
|
"windows": [
|
||||||
{ "topic": "window/living_room/garden_side", "label": "garden_side" }
|
{ "topic": "homegear/instance1/plain/18/1/STATE", "label": "Garten rechts" },
|
||||||
|
{ "topic": "homegear/instance1/plain/22/1/STATE", "label": "Garten links" }
|
||||||
],
|
],
|
||||||
"output_topic": "output/living_room"
|
"output_topic": "heating/homegear/instance1/set/39/1/SET_TEMPERATURE"
|
||||||
},
|
},
|
||||||
"box2": {
|
"box2": {
|
||||||
"label": "kitchen",
|
"label": "kueche",
|
||||||
"windows": [
|
"windows": [
|
||||||
{ "topic": "window/kitchen/street_side", "label": "street_side" },
|
{ "topic": "homegear/instance1/plain/37/1/STATE", "label": "Garten Fenster" },
|
||||||
{ "topic": "window/kitchen/garden_side", "label": "garden_side" },
|
{ "topic": "homegear/instance1/plain/36/1/STATE", "label": "Garten Tuer" },
|
||||||
{ "topic": "window/kitchen/garden_door", "label": "garden_door" }
|
{ "topic": "homegear/instance1/plain/38/1/STATE", "label": "Strasse rechts" },
|
||||||
|
{ "topic": "homegear/instance1/plain/13/1/STATE", "label": "Strasse links" }
|
||||||
],
|
],
|
||||||
"output_topic": "output/kitchen"
|
"output_topic": "heating/homegear/instance1/set/40/1/SET_TEMPERATURE"
|
||||||
|
},
|
||||||
|
"box3": {
|
||||||
|
"label": "bad_oben",
|
||||||
|
"windows": [
|
||||||
|
],
|
||||||
|
"output_topic": "heating/homegear/instance1/set/41/1/SET_TEMPERATURE"
|
||||||
|
},
|
||||||
|
"box4": {
|
||||||
|
"label": "schlafzimmer",
|
||||||
|
"windows": [
|
||||||
|
{ "topic": "homegear/instance1/plain/52/1/STATE", "label": "Strasse" }
|
||||||
|
],
|
||||||
|
"output_topic": "heating/homegear/instance1/set/42/1/SET_TEMPERATURE"
|
||||||
|
},
|
||||||
|
"box5": {
|
||||||
|
"label": "wolfgang",
|
||||||
|
"windows": [
|
||||||
|
{ "topic": "homegear/instance1/plain/24/1/STATE", "label": "Garten" }
|
||||||
|
],
|
||||||
|
"output_topic": "heating/homegear/instance1/set/43/1/SET_TEMPERATURE"
|
||||||
|
},
|
||||||
|
"box6": {
|
||||||
|
"label": "esszimmer",
|
||||||
|
"windows": [
|
||||||
|
{ "topic": "homegear/instance1/plain/26/1/STATE", "label": "Strasse rechts" },
|
||||||
|
{ "topic": "homegear/instance1/plain/27/1/STATE", "label": "Strasse links" }
|
||||||
|
],
|
||||||
|
"output_topic": "heating/homegear/instance1/set/45/1/SET_TEMPERATURE"
|
||||||
|
},
|
||||||
|
"box7": {
|
||||||
|
"label": "wohnzimmer",
|
||||||
|
"windows": [
|
||||||
|
{ "topic": "homegear/instance1/plain/28/1/STATE", "label": "Garten rechts" },
|
||||||
|
{ "topic": "homegear/instance1/plain/29/1/STATE", "label": "Garten links" }
|
||||||
|
],
|
||||||
|
"output_topic": "heating/homegear/instance1/set/46/1/SET_TEMPERATURE"
|
||||||
|
},
|
||||||
|
"box8": {
|
||||||
|
"label": "bad_unten",
|
||||||
|
"windows": [
|
||||||
|
{ "topic": "homegear/instance1/plain/44/1/STATE", "label": "Strasse" }
|
||||||
|
],
|
||||||
|
"output_topic": "heating/homegear/instance1/set/48/1/SET_TEMPERATURE"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ def process_message(box_name, topic_key, payload, context):
|
|||||||
try:
|
try:
|
||||||
box = context['boxes'][box_name]
|
box = context['boxes'][box_name]
|
||||||
local_context = box['context']
|
local_context = box['context']
|
||||||
logger.info(f"{local_context=}")
|
logger.info(f"Local context before: {local_context}")
|
||||||
logger.info(f"[{box_name}, {box['label']}] Processing message for '{topic_key}': {payload}")
|
logger.info(f"[{box_name}, {box['label']}] Processing message for '{topic_key}': {payload}")
|
||||||
|
|
||||||
match topic_key.split('/'):
|
match topic_key.split('/'):
|
||||||
@ -59,6 +59,8 @@ def process_message(box_name, topic_key, payload, context):
|
|||||||
publish_topic = box["output_topic"] if not status else context['status_topic']
|
publish_topic = box["output_topic"] if not status else context['status_topic']
|
||||||
context['client'].publish(publish_topic, result_message)
|
context['client'].publish(publish_topic, result_message)
|
||||||
logger.info(f"[{box_name}] Result published on '{publish_topic}': {status} {result_message}")
|
logger.info(f"[{box_name}] Result published on '{publish_topic}': {status} {result_message}")
|
||||||
|
|
||||||
|
logger.info(f"Local context after: {local_context}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"[{box_name}] Error processing '{topic_key}': {e}")
|
logger.error(f"[{box_name}] Error processing '{topic_key}': {e}")
|
||||||
|
|
||||||
@ -117,7 +119,7 @@ def process_high_temp(box_name, context, local_context, payload):
|
|||||||
return (local_context['output_temperature'], False)
|
return (local_context['output_temperature'], False)
|
||||||
|
|
||||||
def process_window(box_name, context, local_context, sub_key, payload):
|
def process_window(box_name, context, local_context, sub_key, payload):
|
||||||
local_context['window_state'][sub_key] = 'closed' if (payload.lower() in ('true', 'close', 'closed')) else 'open'
|
local_context['window_state'][sub_key] = 'closed' if (payload.lower() in ('false', 'close', 'closed')) else 'open'
|
||||||
_calculate_output_temperature(local_context)
|
_calculate_output_temperature(local_context)
|
||||||
return (local_context['output_temperature'], False)
|
return (local_context['output_temperature'], False)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user