I am trying to use a response_variable in an automation but I do not seem able to make it work. Automation Code:
actions:
- action: script.ground_temperature_ok_2
metadata: {}
data:
home_presence: "{{ home_presence }}"
manual_control: "{{ manual_temperature_control }}"
manual_temperature: "{{ manual_temperature }}"
comfort_target: 17
eco_target: 15
climate_mode: "{{ climate_mode }}"
current_temperature: "{{ climate_measurement }}"
climate_entity: "{{ climate_entity }}"
response_variable: result
- choose:
- conditions:
- condition: state
entity_id: !input climate_mode
state: 'Off'
- condition: template
value_template: |
{{ states(climate_entity) != 'off' or not is_state_attr(climate_entity, 'fan_mode', states(fan_mode)) or not is_state_attr(climate_entity, 'swing_mode', states(vertical_swing_mode)) }}
sequence:
- action: script.ground_hvac_heat
metadata: {}
data:
fan_mode: "{{ fan_mode }}"
vertical_swing_mode: "{{ vertical_swing_mode }}"
horizontal_swing_mode: "{{ horizontal_swing_mode }}"
- action: script.ground_hvac_off
metadata: {}
data: {}
- conditions:
- condition: state
entity_id: !input manual_temperature_control
state: 'on'
sequence:
- choose:
- conditions:
- condition: state
entity_id: !input climate_mode
state: "Heating"
sequence:
- choose:
- conditions:
- condition: template
value_template: result.hvac_needed
- condition: not
conditions:
- condition: state
entity_id: !input climate_entity
state: "heat"
sequence:
- action: script.ground_hvac_heat
metadata: {}
data:
fan_mode: "{{ fan_mode }}"
vertical_swing_mode: "{{ vertical_swing_mode }}"
horizontal_swing_mode: "{{ horizontal_swing_mode }}"
- conditions:
- condition: not
conditions:
- condition: template
value_template: result.hvac_needed
- condition: state
entity_id: !input climate_entity
state: "off"
sequence:
- action: script.ground_hvac_off
metadata: {}
data: {}
and the called script
alias: Ground Temperature OK
variables:
result: >
{% set target = comfort_target | float %}
{% if not states(home_presence) == 'on' %}
{% set target = eco_target | float %}
{% endif %}
{% if states(manual_control) == 'on' %}
{% set target = states(manual_temperature) | float %}
{% endif %}
{% set air_conditioning_needed = false %} {% set hvac_mode =
states(climate_mode) %}
{% if hvac_mode == 'Heating' %}
{% if states(current_temperature) | float < (target - 0.5) or states(climate_entity) == 'heat' %}
{% set air_conditioning_needed = true %}
{% endif %}
{% if states(current_temperature) | float > target %}
{% set air_conditioning_needed = false %}
{% endif %}
{% endif %}
{% if hvac_mode == 'Cooling' %}
{% if states(current_temperature) | float > (target + 0.5) or states(climate_entity) == 'cool' %}
{% set air_conditioning_needed = true %}
{% endif %}
{% if states(current_temperature) | float < target %}
{% set air_conditioning_needed = false %}
{% endif %}
{% endif %}
{{ {'hvac_needed': air_conditioning_needed} }}
sequence:
- stop: All Done
response_variable: result
mode: single
I do not seem to be able to read the boolean answer in result.hvac_needed ion the automation.