issue found and fixed
This commit is contained in:
@ -49,10 +49,8 @@ try:
|
|||||||
context['boxes'] = boxes
|
context['boxes'] = boxes
|
||||||
|
|
||||||
# add context dict to each box in the list
|
# add context dict to each box in the list
|
||||||
for box_name, config in boxes.items():
|
for _, config in boxes.items():
|
||||||
config['context'] = {}
|
config['context'] = {}
|
||||||
|
|
||||||
logger.info(f"{boxes=}")
|
|
||||||
except json.JSONDecodeError as e:
|
except json.JSONDecodeError as e:
|
||||||
logger.error(f"Error parsing JSON configuration for boxes: {e}")
|
logger.error(f"Error parsing JSON configuration for boxes: {e}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@ -9,9 +9,10 @@ from loguru import logger
|
|||||||
# store here what ever is require to represent the state of the box
|
# store here what ever is require to represent the state of the box
|
||||||
|
|
||||||
def process_message(box_name, topic_key, payload, context):
|
def process_message(box_name, topic_key, payload, context):
|
||||||
logger.info(f"{context=}")
|
# logger.info(f"{context=}")
|
||||||
try:
|
try:
|
||||||
logger.info(f"[{box_name}] Processing message for '{topic_key}': {payload}")
|
box = context['boxes'][box_name]
|
||||||
|
logger.info(f"[{box_name}, {box['label']}] Processing message for '{topic_key}': {payload}")
|
||||||
|
|
||||||
match topic_key.split('/'):
|
match topic_key.split('/'):
|
||||||
case [ primary_key, sub_key ] if primary_key == 'window':
|
case [ primary_key, sub_key ] if primary_key == 'window':
|
||||||
@ -28,7 +29,7 @@ def process_message(box_name, topic_key, payload, context):
|
|||||||
raise Error(f"Unexcepted topic_key: {topic_key}, {payload}")
|
raise Error(f"Unexcepted topic_key: {topic_key}, {payload}")
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
publish_topic = context["boxes"]["output_topic"]
|
publish_topic = box["output_topic"]
|
||||||
context['client'].publish(publish_topic, result)
|
context['client'].publish(publish_topic, result)
|
||||||
logger.info(f"[{box_name}] Result published on '{publish_topic}': {result}")
|
logger.info(f"[{box_name}] Result published on '{publish_topic}': {result}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Reference in New Issue
Block a user