Automation configuration

Hi there. I’m new to Home Assistant. I really like it, but I’m having trouble with the learning curve.

I’m trying to set up some automation and I’d appreciate some help.

Here is what I’m tripping on:

automation:

  • alias: “Sunset Automation”
    trigger:
    platform: sun
    event: sunset
    action:
    service: homeassistant.turn_on
    entity_id:
    - switch.fan
    - switch.curtians

  • alias: “Basement Automation”
    trigger:
    platform: state
    entity_id: binary_sensor.basement_motion
    to: ‘on’
    action:
    service: homeassistant.turn_on
    entity_id:
    - switch.basement

Any help would be greatly appreciated.

Cheers

use as service: switch.turn_on

What do you want to achieve and where are you getting stuck?

P.S. When you want to post code, place 3 backticks (the character next to the ‘1’ on your keyboard), type ‘yaml’, paste your code and end with another 3 backticks. Like this:

‘’‘yaml
code line1
code line2
‘’’
This will format the code so that the indentation is kept and will also apply syntax-highlighting for easier reading.

1 Like

Hey there. I’m trying to turn on a light switch basement switch when there is motion in the basement.

It seems I cannot have two automation events. I’m a little confused.

Here is my code:

automation:
  trigger:
    platform: sun
    event: sunset
  action:
    service: homeassistant.turn_on
    entity_id:
      - switch.fan
      - switch.curtians

- alias: "Basement Automation"
  trigger:
    platform: state
    entity_id: binary_sensor.basement_motion
    to: 'on'
  action:
    service: switch.turn_on
    entity_id:
      - switch.basement

You need to have different numbers for each automation.

automation 1:
  trigger:
    platform: sun
    event: sunset
  action:
    service: homeassistant.turn_on
    entity_id:
      - switch.fan
      - switch.curtians

automation 2:
- alias: "Basement Automation"
  trigger:
    platform: state
    entity_id: binary_sensor.basement_motion
    to: 'on'
  action:
    service: switch.turn_on
    entity_id:
      - switch.basement

also in your first automation, use switch.turn_on as service…

@broesie: That is not necessary. homeassistant.turn_on will also work fine.

Thank you. This is exactly what I needed. Its working now.
Cheers