|
|
|
@ -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)
|
|
|
|
|