Desperately trying to create my first automation.. and failing.. miserably

hi all…

looking for a few pointers if you don’t mind… i’m new to all this and i’m trying to write my first automation but failing miserably… here is whats going on…

started with hass.io about a week ago… got help to set up my broadlink RM pro+ and set up both RF and IR remote controls in HASSIO

all that is working fine…

now i’m trying to automate two lamps on RF sockets to switch on when the sun sets ( i’ll work on tweaking it to offset and stuff once i work out the basics). I tried using the Automation tab in Hass.io though since the update there is nothing there… so i tried to enter the following into my automations.yaml

 alias: turn on lounge lamps at sunset
   initial_state: true
   hide_entity: false
   trigger:
      platform:sun
      event: sunset
   action:
     service: switch.turn_on

nothing happend… i was expecting to be able to se it on the over view page but nothing… so i removed it from there and went direct into the configuration.yaml with this…

automation:
   alias: turn on lounge lamps at sunset
   initial_state: true
   hide_entity: false
   trigger:
    platform:sun
    event: sunset
   action:
    service: switch.turn_on

now when i check the configuration i get this message

Configuration invalid

Error loading /config/configuration.yaml: mapping values are not allowed here in “/config/configuration.yaml”, line 78, column 10

line 78 is " event: sunset"

the last time i had a problem it was due to capital letters… so i have gone through and ensured there are non this time… what else am i missing? what have i done wrong?

thank you all in advance for your help.

It looks like you missed out the entity that you wanted to turn on. Here is my sunset light on Automation so you can have a look at it.

- id: '1529080549046'
  alias: Outside Lights on sunset
  trigger:
  - event: sunset
    platform: sun
  condition: []
  action:
  - service: switch.turn_on
    entity_id: switch.outside_lights

thanks Cee,

i looked at yours and noticed i had event and platform in the other order so i re-ordered them… i also added “-” and altered my indenting (also missed a space)

now i have this

automation:
   alias: turn on lounge lamps at sunset
   initial_state: true
   hide_entity: false
   trigger:
   - event: sunset
     platform: sun
   action:
   - service: switch.turn_on
     entity_id: group.all_switches

the config checker says its ok… but the overview page says

config error :see dev_info for details

no idea what or where that is to check it…

any help?

here’s mine as an example…

switching on 1 hour before sunset:

- id: House Night Lights switch on
  alias: House Night Lights switch on
  trigger:
  - event: sunset
    offset: -01:00:00
    platform: sun
  action:
    service: switch.turn_on
    data:
      entity_id:
      - switch.109_switch
      - switch.124_switch
      - switch.125_switch
      - switch.126_switch
      - switch.127_switch
      - switch.128_switch
      - switch.132_switch
      - switch.142_switch
      - switch.144_switch

and then switch off at 10:30 pm…

- id: House Night Lights switch off
  alias: House Night Lights switch off
  trigger:
  - at: '22:30:00'
    platform: time
  action:
  service: switch.turn_off
  data:
    entity_id:
    - switch.109_switch
    - switch.124_switch
    - switch.125_switch
    - switch.126_switch
    - switch.127_switch
    - switch.128_switch
    - switch.132_switch
    - switch.142_switch
    - switch.144_switch
1 Like

I dont think you can use the group.all_switches as the entity for switch.turn_on try using homeassistant.turn_on instead,

automation:
   alias: turn on lounge lamps at sunset
   initial_state: true
   hide_entity: false
   trigger:
   - event: sunset
     platform: sun
   action:
   - service: homeassistant.turn_on
     entity_id: group.all_switches

That should work I think, my brain isn’t working 100% today.

1 Like

None of my automations are working, after I upgraded to the latest version. If I visit the automations page, I can see all of them, but I cannot edit them. (Then I get an empty page)
I think you might have the same problem.

  • tried rebooting
  • did not edit my automations lately
  • tried another browser as well.
1 Like

that sounds like what i have yes… so it could be a bug…

as im new to hass.io i wasnt sure if it was something i done wrong… though i would think that even if the automations gui isnt working, a manually entered automation should have worked… however. i know nothing about this lol

i’m just about to try editing to the homeassistant.turn_on and see if that does anything…

thank you all for your help…

i’ll go see if there is a fix for the ‘bug’ next…

My automations stopped working after the update, so I do not think that manual automations will work.
I am surprised to see that the bug is registered like javascript errors, because that does not explain why my automations stopped working.

All of my automations are hangout messages, so maybe this is another bug in this version?

Demesmeaker

Your identation is 3 spaces. Modify to two and it should work.

Hey,
I also needed a long time to get my light with sun level automation to work, so i share mine - perhaps it helps. i use the elevation of the sun as trigger so i can get the lights going on a bit before sunset, not the perfect way but it works:

>   - id: Motion 1
>     alias: Motion 1
>     trigger:
>       platform: state
>       entity_id: binary_sensor.YOUR_SENSOR
>       to: 'on'
>     condition:
>       condition: or
>       conditions:
>         - condition: numeric_state
>           entity_id: sun.sun
>           value_template: "{{ state.attributes.elevation }}"
>           below: "8"
>     action:
>       - service: homeassistant.turn_on
>         entity_id: switch.YOUR_SWITCH

In your first post your second bit of automation code the problem was that you had “platform:sun” (no space between the : & sun). That’s why it was giving you the mapping error there.

And you didn’t have an entity for the action.

Later on you had too many spaces under automation: as pointed out above.

You have extra code in your condition: that you don’t need. You can remove the “or” statement since you only have one condition:

condition:
  - condition: numeric_state
    entity_id: sun.sun
    value_template: "{{ state.attributes.elevation }}"
    below: "8"
1 Like

thanks finity, i will integrate that=)