Ecobee automation based on 'mode'

Hi all,

I’m trying to set up an automation based on the ecobee’s mode. I have a generic thermostat set up, and I want to be active only at night. I am thinking the best way to do that is this is to tie the heater to the ecobee’s sleep mode. (by the way, is there a way to turn off a generic thermostat? I didn’t see one, so I am planning to set the target temp to a realistic target during sleep mode)

I’ve been searching the forum for a answer, and the closest I’ve come is this post from last January.

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

I feel like I’m almost there. I’ve got the template sensor set up for the mode attribute of the ecobee, and that is displaying fine on my home screen, and I’ve set up the automation. But when I restart HA, I get the following error

17-02-21 18:20:05 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Mode, the state is unknown.
17-02-21 18:20:25 ERROR (MainThread) [homeassistant.bootstrap] Invalid config for [automation]: expected dict for dictionary value @ data['action'][0]['data']. Got None. (See /home/homeassistant/.homeassistant/configuration.yaml, line 243). Please check the docs at https://home-assistant.io/components/automation/
17-02-21 18:20:25 ERROR (MainThread) [homeassistant.bootstrap] Invalid config for [automation]: expected dict for dictionary value @ data['action'][0]['data']. Got None. (See /home/homeassistant/.homeassistant/configuration.yaml, line 243). Please check the docs at https://home-assistant.io/components/automation/

I suspect that HA is telling me it doesn’t know what values to expect for the new mode sensor. There isn’t an array for mode like there is for operation. Is there a way to get around this?

There are the relevant snippets from my configuration

  #ecobee Operation Mode sensor
  - platform: template
    sensors:
      homestead_mode:
        friendly_name: 'Mode'
        value_template: "{{ states.climate.homestead.attributes.mode }}"

- alias: 'Space Heater Sleep Mode on'
  trigger:
    - platform: state
      entity_id: sensor.homestead_mode
      to: 'sleep'
  action:
    - service: climate.set_temperature
      entity_id: climate.space_heater
      data:
        - temperature: 70

Any help would be greatly appreciated!

I finally got this figured out. After reading through a bunch more posts, I realized that the error indicated a syntax error in the automation. I finally figured out that the issue was that the entity_id needed to go into the data portion of the action section:

  action:
    - service: climate.set_temperature
      data:
        entity_id: climate.space_heater
        temperature: 70