Problems setting up automations

Hello everyone,

I’m totally new to HA and Yaml. I’m on Raspberry, home assistant os 5.13, core-2021.6.2
I’m trying to set-up a simple automation related to Sun integration. I’ve copy-pasted some examples, set as “working code”, I found on the forum but I’m always getting different errors like

Message malformed: extra keys not allowed @
or
Message malformed: not a valid value for dictionary value @
or
Message malformed: expected dictionary

I’ve tryied to pay attention to indentation as some posts suggested but i’m still having troubles.

Could somebody give me an example to automate an entity id “light.led” to turn on at sunset with an offset?

Thank you

I’ve found this. Have you tried this one already?

Thanks for the example!

So I just tryied do this

- alias: Auto Lamps
  id: 'autolampson'
  trigger:
  - platform: sun
    event: sunset
    offset: -00:45:00
  action:
    service: light.turn_on
    entity_id: light.led

and I got :

Message malformed: expected dictionary

I’m wondering if the problem isn’t in my setup itself more than in the code…

  action:
  - service: light.turn_on
    entity_id: light.led

action is a YAML list
List items start with -

Thank you!
I’m still having the same expected dictionary error :roll_eyes:

- alias: Auto Lamps
  id: 'autolampson'
  trigger:
  - platform: sun
    event: sunset
    offset: -00:45:00
  action:
  - service: light.turn_on
    entity_id: light.led

post the entire error message from home-assisdtant.log in your config directory.

Well actually I’ve tryied

alias: Auto Lamps

instead of

- alias: Auto Lamps

with its relative indentation and it works.

alias: Auto Lamps
trigger:
  - platform: sun
    event: sunset
    offset: '-04:05:00'
action:
  - service: light.turn_on
    entity_id: light.led
mode: single

Thanks everybody