Help automation based on "climate" "operation" (attribute)

Hello,

I have been fighting with this for a while and cannot figure it out.

I would like one of my lights to come on when the furnace is running, using an Ecobee3 thermostat if that matters.

The Ecobee seems fine, I can adjust temperature with HASS, I have other automation working based on the humidity (entity_id: sensor.home_humidity).

I am trying to read the “operation” mode to determine when the heat is running:

climate.home

{
“actual_humidity”: 35,
“away_mode”: “off”,
“current_temperature”: 72.6,
“fan”: “off”,
“fan_min_on_time”: 5,
“friendly_name”: “Home”,
“max_temp”: 95,
“min_temp”: 44.6,
“mode”: “home”,
“operation”: “heat”,
“operation_list”: [
“auto”,
“auxHeatOnly”,
“cool”,
“heat”,
“off”
],
“operation_mode”: “heat”,
“target_temp_high”: 74,
“target_temp_low”: 72,
“temperature”: null,
“unit_of_measurement”: “°F”
}

My Automation looks like this currently (after changing it a ton of times):

automation 3:

  • alias: Utility light on when heating
    trigger:
    platform: state
    entity_id: climate.home
    value_template: ‘{{ state.attributes.operation}}’
    state: heat
    action:
    service: light.turn_on
    entity_id:
    - light.table

The error I am getting is:

17-01-16 18:34:10 homeassistant.bootstrap: Invalid config for [automation]: [value_template] is an invalid option for [automation]. Check: automation->trigger->0->value_template. (See ?, line ?). Please check the docs at Automation - Home Assistant

Any ideas?

Thanks!

You need to use sensor templates to split out the attributes you need. Here is a code snippet of mine:

sensors:

thermostat_main_current_status:
    value_template: '{{ states.climate.main_floor.attributes.operation }}'
thermostat_main_status_fan:
    value_template: '{{ states.climate.main_floor.attributes.fan }}'
thermostat_main_away_mode:
    value_template: '{{ states.climate.main_floor.attributes.away_mode }}'
thermostat_upstairs_current_status:
    value_template: '{{ states.climate.upstairs.attributes.operation }}'
thermostat_upstairs_status_fan:
    value_template: '{{ states.climate.upstairs.attributes.fan }}'
thermostat_upstairs_away_mode:
    value_template: '{{ states.climate.upstairs.attributes.away_mode }}'

I haven’t had much luck with template triggers and as @jwelter mentioned, you could create a template sensor, then base your automation on that as a trigger.

Also, you’ve got the format wrong for that trigger definition, I think. I don’t believe you can use a value_template with a state platform. Use “platform: template”

Ok, I did get it to work! Thanks!

 sensor:
   - platform: template
     sensors:
       thermostat_status:
         friendly_name: 'HVAC Status'
         value_template: "{{ states.climate.home.attributes.operation }}"
 automation 3:
   alias: Utility light on when heating
   trigger:
    - platform: state
      entity_id: sensor.thermostat_status
      to: "heat"
   condition:
   action:
     service: light.turn_on
     entity_id:
      - light.table

Now I am having an issue where the value does not update for a minute or so after the heat kicks on/off. Different thread…

That thread is here: