I have been using the below to set my Nest to ECO and return to its previous state for years. But something has caused it to stop working and I can’t figure it out. Any help would be great.
sensor:
- platform: template
sensors:
downstairs_thermostat_hvac_mode:
value_template: >
{% if is_state_attr('climate.downstairs', 'preset_mode', 'eco') %}
eco
{% else %}
{{ states('climate.downstairs') }}
{% endif %}
script:
nest_eco_on:
alias: Nest Thermostat - Set to ECO mode
sequence:
# Only turn on ECO mode if thermostat is not off and not already in ECO
# mode.
- condition: template
value_template: >
{{ states('sensor.downstairs_thermostat_operation_mode')
not in ['off', 'eco'] }}
- service: input_text.set_value
entity_id: input_text.previous_hvac_mode
data_template:
value: "{{ states('sensor.downstairs_thermostat_operation_mode') }}"
- service: climate.set_preset_mode
entity_id: climate.downstairs
data:
preset_mode: eco
nest_eco_off:
alias: Nest Thermostat - Return from ECO mode
sequence:
# Only set back to previous mode if thermostat is still in ECO mode.
- condition: template
value_template: >
{{ is_state('sensor.downstairs_thermostat_operation_mode', 'eco') }}
- service: climate.set_hvac_mode
entity_id: climate.downstairs
data_template:
hvac_mode: "{{ states('input_text.previous_hvac_mode') }}"