I’m trying to create a blueprint to use for various zigbee TRVs around the house.
The trigger is based on a template as i need to compare both the HVAC mode and the current/set temps of the TRV.
I’ve tried a number of different formats for the template (i’m no expert using templates) but i keep getting an error in the logs when i try to create an automation with it.
This is the whole blueprint yaml:
blueprint:
name: Automatic Radiator HVAC Mode
description: 'Set the heating mode of a radiator based on the current and set temperature.'
domain: automation
input:
trv_entity:
name: Radiator Device
description: Radiator TRV Device
selector:
entity:
integration: mqtt
domain: climate
multiple: false
cold_tolerance:
name: Cold Tolerance
description: Amount of degrees lower than the set temp before TRV turns back on
selector:
number:
min: 0
max: 2
unit_of_measurement: 'degrees C'
hot_tolerance:
name: Hot Tolerance
description: Amount of degrees higher than the set temp before TRV turns back off
selector:
number:
min: 0
max: 2
unit_of_measurement: 'degrees C'
mode: parallel
max_exceeded: silent
trigger_variables:
var_trv_device: !input trv_entity
var_hot_tolerance: !input hot_tolerance
var_cold_tolerance: !input cold_tolerance
trigger:
- platform: template
value_template: >
'
{% set tempdiff = state_attr('var_trv_device',''current_temperature'') | float - state_attr('var_trv_device',''temperature'') | float %}
{% if is_state('var_trv_device', 'heat') and tempdiff > var_hot_tolerance %}
true
{% else %}
false
{% endif %}
'
id: turnoff
- platform: template
value_template: >
'
{% set tempdiff = state_attr('var_trv_device','current_temperature') | float - state_attr('var_trv_device','temperature') | float %}
{% if is_state('var_trv_device', 'auto') and tempdiff < cold_tolerance %}
true
{% else %}
false
{% endif %}
'
id: turnon
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: turnoff
sequence:
- service: climate.set_hvac_mode
data:
hvac_mode: auto
target:
device_id: trv_entity
- conditions:
- condition: trigger
id: turnon
sequence:
- service: climate.set_hvac_mode
data:
hvac_mode: heat
target:
device_id: trv_entity
The latest error with this version is:
Logger: homeassistant.components.automation
Source: components/automation/__init__.py:285
Integration: Automation (documentation, issues)
First occurred: 11:38:03 (7 occurrences)
Last logged: 11:38:03
Blueprint Automatic Radiator HVAC Mode generated invalid automation with inputs OrderedDict([('cold_tolerance', 1), ('trv_entity', 'climate.office_radiator'), ('hot_tolerance', 1)]): invalid template (TemplateSyntaxError: expected token ',', got 'current_temperature') for dictionary value @ data['value_template']. Got None
Blueprint Automatic Radiator HVAC Mode generated invalid automation with inputs OrderedDict([('trv_entity', 'climate.office_radiator'), ('cold_tolerance', 1), ('hot_tolerance', 1)]): invalid template (TemplateSyntaxError: expected token ',', got 'current_temperature') for dictionary value @ data['value_template']. Got None
An automation is now created when using the blueprint, but having a look at the traces when it runs shows that the trigger variables are not being converted back to their actual values in the trigger template, they are just being added as the variable names themselves.
Is this a valid use of inputs/trigger variables in a template trigger? Or are they not supported?
Thanks, I’ve since removed that but I still get the same problem.
My reason for using template triggers was that i wanted multiple conditions in the triggers all tied into 1 blueprint automation rather than multiple automations per TRV. It would also allow me to add further options into the blueprint and apply that quickly to all TRVs at once rather than adding new automations or editing all the existing ones.
The scenarios I’m trying to accomplish are:
Trigger = HVAC mode set to heat and current temp is higher than set temp (taking into account the tolerance)
Action = Set TRV to auto
Trigger = HVAC mode set to auto and set temp is higher than current temp (taking into account the tolerance)
Action = Set TRV to heat