overwrite window added
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful

This commit is contained in:
2024-11-07 19:22:41 +01:00
parent 62ce6f1b9c
commit e6b4733a60
3 changed files with 15 additions and 5 deletions

View File

@ -10,6 +10,7 @@ data:
MQTT_BOX_TOPIC_PREFIXES: |
{
"high_temp": "heating/config/high_temp/",
"overwrite_window": "heating/overwrite_window",
"cmd": "heating/command/"
}
MQTT_CENTRAL_TOPICS: |

View File

@ -66,7 +66,7 @@ try:
box_topic_prefixes = json.loads(BOX_TOPIC_PREFIXES_CONFIG)
# Validation: Check if the required keys are present
required_keys = {'high_temp', 'cmd'}
required_keys = {'high_temp', 'cmd', 'overwrite_window'}
missing_keys = required_keys - box_topic_prefixes.keys()
if missing_keys:

View File

@ -20,6 +20,7 @@ def prepare_context(box_name, context):
local_context['general_off'] = False
local_context['maintenance_mode'] = False
local_context['overwrite_window'] = False
local_context['window_state'] = {}
for w in context['boxes'][box_name]['windows']:
@ -45,6 +46,8 @@ def process_message(box_name, topic_key, payload, context):
result = process_high_temp(box_name, context, local_context, payload)
case [ primary_key ] if primary_key == 'cmd':
result = process_cmd(box_name, context, local_context, payload)
case [ primary_key ] if primary_key == 'overwrite_window':
result = process_overwrite_window(box_name, context, local_context, payload)
case [ primary_key ] if primary_key == 'general_off':
result = process_general_off(box_name, context, local_context, payload)
case [ primary_key ] if primary_key == 'maintenance_mode':
@ -74,10 +77,11 @@ def _calculate_output_temperature(local_context):
local_context['output_temperature'] = local_context['off_temperature']
return
# an open window shuts off the heating
for w in local_context['window_state'].values():
if w == 'open':
local_context['output_temperature'] = local_context['off_temperature']
return
if not local_context['overwrite_window']:
for w in local_context['window_state'].values():
if w == 'open':
local_context['output_temperature'] = local_context['off_temperature']
return
# finally evaluate the mode
if local_context['mode'] == 'off':
local_context['output_temperature'] = local_context['off_temperature']
@ -113,6 +117,11 @@ def process_cmd(box_name, context, local_context, payload):
logger.error(f"Invalid cmd for {box_name} received: {payload}")
return (local_context['output_temperature'], False)
def process_overwrite_window(box_name, context, local_context, payload):
local_context['overwrite_window'] = (payload.lower() in ('true'))
_calculate_output_temperature(local_context)
return (local_context['output_temperature'], False)
def process_high_temp(box_name, context, local_context, payload):
local_context['high_temperature'] = payload
_calculate_output_temperature(local_context)