Noob automation problem

Hi all,

It has been quite some time since I delved into the world of HA and now I don’t seem to be able to get a simple automation working.

Can someone tell me what is wrong with this automation. When I check the config it gives me an error:

- alias: Rolluik Slaapkamer openen om 7u op weekdagen.
  trigger:
    platform: time
    at: '7:00:00'
  condition:
    - condition: state
      entity_id: binary_sensor.workday_sensor
      state: 'on'
  action:
    - data:
      entity_id: cover.slaapkamer
      service: cover.open_cover

Remove -data from your action.

1 Like

Thanks! that seems to solve it. Any chance you can explain why the ‘-data’ doesn’t cause problems in this automation?

- alias: Rolluik Slaapkamer aflaten half uur na zonsondergang.
  trigger:
    - event: sunset
      offset: 00:30:00
      platform: sun
  action:
    - data:
        entity_id: cover.slaapkamer
      service: cover.close_cover

Neither require the - data: entry.

The first isn’t properly indented, items under data need to be indented by two spaces. Due to this it gave an error.

In your second example you are passing the data “entity_id: cover.slaapkamer” to the service cover.close_cover. In the first HA doesn’t see any data passed.

1 Like

Thanks. I understand now.

Just to add to what @silvrr said, all data for service belongs under data (or data_template.) However, the service handler allows entity_id to be at the same level as service as a shortcut/convenience. So:

service: abc
entity_id: xyz

is equivalent to, and a shortcut for:

service: abc
data:
  entity_id: xyz
1 Like

Thanks for the clarification @pnbruckner! I suggest you guys start writing the docs :slight_smile: