status text output
This commit is contained in:
@ -10,7 +10,7 @@ data:
|
||||
MQTT_BOX_TOPIC_PREFIXES: |
|
||||
{
|
||||
"high_temp": "heating/config/high_temp/",
|
||||
"overwrite_window": "heating/overwrite_window",
|
||||
"overwrite_window": "heating/overwrite_window/",
|
||||
"cmd": "heating/command/"
|
||||
}
|
||||
MQTT_CENTRAL_TOPICS: |
|
||||
@ -20,6 +20,7 @@ data:
|
||||
"status": "heating/system/status"
|
||||
}
|
||||
MQTT_STATUS_TOPIC: "heating/status"
|
||||
MQTT_STATUSTEXT_TOPIC_PREFIX: "heating/statustext/"
|
||||
OFF_TEMPERATURE: "5.0"
|
||||
LOW_TEMPERATURE: "15.0"
|
||||
DEFAULT_HIGH_TEMPERATURE: "21.0"
|
||||
|
@ -19,6 +19,7 @@ LOW_TEMPERATURE = os.getenv("LOW_TEMPERATURE", "15.0")
|
||||
DEFAULT_HIGH_TEMPERATURE = os.getenv("DEFAULT_HIGH_TEMPERATURE", "21.0")
|
||||
MAINTENANCE_TEMPERATURE = os.getenv("MAINTENANCE_TEMPERATURE", "30.0")
|
||||
STATUS_TOPIC = os.getenv("MQTT_STATUS_TOPIC")
|
||||
STATUSTEXT_TOPIC_PREFIX = os.getenv("MQTT_STATUSTEXT_TOPIC_PREFIX")
|
||||
|
||||
# Check if required environment variables are set
|
||||
missing_vars = []
|
||||
@ -32,6 +33,8 @@ if not CENTRAL_TOPICS_CONFIG:
|
||||
missing_vars.append('MQTT_CENTRAL_TOPICS')
|
||||
if not STATUS_TOPIC:
|
||||
missing_vars.append('MQTT_STATUS_TOPIC')
|
||||
if not STATUSTEXT_TOPIC_PREFIX:
|
||||
missing_vars.append('MQTT_STATUSTEXT_TOPIC_PREFIX')
|
||||
|
||||
if missing_vars:
|
||||
logger.error(f"Error: The following environment variables are not set: {', '.join(missing_vars)}")
|
||||
@ -46,6 +49,7 @@ context['low_temperature'] = LOW_TEMPERATURE
|
||||
context['default_high_temperature'] = DEFAULT_HIGH_TEMPERATURE
|
||||
context['maintenance_temperature'] = MAINTENANCE_TEMPERATURE
|
||||
context['status_topic'] = STATUS_TOPIC
|
||||
context['statustext_topic_prefix'] = STATUSTEXT_TOPIC_PREFIX
|
||||
|
||||
# Load box configurations from JSON
|
||||
try:
|
||||
|
@ -63,6 +63,9 @@ def process_message(box_name, topic_key, payload, context):
|
||||
context['client'].publish(publish_topic, result_message)
|
||||
logger.info(f"[{box_name}] Result published on '{publish_topic}': {status} {result_message}")
|
||||
|
||||
statustext_topic = f"{context['statustext_topic_prefix']}/{box['label']}"
|
||||
context['client'].publish(statustext_topic, f"{local_context}")
|
||||
|
||||
logger.info(f"[{box_name}] Local context after: {local_context}")
|
||||
except Exception as e:
|
||||
logger.error(f"[{box_name}] Error processing '{topic_key}': {e}")
|
||||
|
Reference in New Issue
Block a user