Automation beginner question light scene with transition yaml error - solved!

Hello,

i just use simple configurations for starting home assistant. Now I´m trying to get my automations smarter for me.
I´ve trying to set up an automation with light scenes after sunset with transition. This is my yaml.file

alias: Licht Abends ein Transition
description: ‘’
trigger:

  • platform: sun
    event: sunset
    offset: "-15
    condition: []
    action:
  • service: scene.turn_on
    data:
    entity_id: scene.wohnzimmer_abends
    transition: 600
  • service: scene.turn_on
    data:
    entity_id: scene.esszimmer_gedimmt
    transition: 600
  • service: scene.turn_on
    data:
    entity_id: scene.esszimmer_gedimmt
    transition: 600

This the error message: Message malformed: required key not provided @ data[‘action’]

Tried different thinks - but no solution. Whats the mistake?

It is an indentation issue… The row where you have action:, remove all the white spaces.

U mean like this:

image

Look, it would be much easier to help you if you format your code as a code:

alias: Licht Abends ein Transition
  description: ''
  trigger:
  - platform: sun
    event: sunset
    offset: "-15
  condition: []
action:
- service: scene.turn_on
data:
entity_id: scene.wohnzimmer_abends
transition: 600
- service: scene.turn_on
data:
entity_id: scene.esszimmer_gedimmt
transition: 600
- service: scene.turn_on
data:
entity_id: scene.esszimmer_gedimmt
transition: 600`Preformatted text`

Thank you, thats what I´m lokking for. Don´t now how to format the code copy&paste

Your code should be (look at the documentation, the indentation used will help you to avoid this issue in the future):

alias: Licht Abends ein Transition
description: ‘’
trigger:
  - platform: sun
    event: sunset
    offset: "-15"
condition: []
action:
  - service: scene.turn_on
    target:
      entity_id: scene.wohnzimmer_abends
    data:
      transition: 600
  - service: scene.turn_on
    target:
      entity_id: scene.esszimmer_gedimmt
    data:
      transition: 600
  - service: scene.turn_on
    target:
      entity_id: scene.esszimmer_gedimmt
    data:
      transition: 600

Thank you, i tried this also in different ways. But always get the same error.
Tried to save your code as well - same error.

Retry, I had a indentation problem as well… :rofl:

You were missing a double quote at the “offset” parameter

That´s it - man, thank you. I tried so many formations but the double quote… :roll_eyes:
Saved - thank you.

1 Like

You can simplify the action part:


  - service: scene.turn_on
    data:
      transition: 600
    target:
      entity_id:
        - scene. wohnzimmer_abends
        - scene. esszimmer_gedimmt

Thank you, much more easier. I see…a lot to learn :thinking:

What i don’t get is, why people, especially the newbies, keep on trying to add it manually :thinking:
Devs are putting so much effort to avoid it…

And once the basic framework is working, you can try to edit it manually :grin:

1 Like

Hey, tried also this but don´t now how to select a scene there :wink:
There for I tried it manually.

You’ve already used the service call scene.turn_on. It’s also provided by the UI Editor.

Yes, but how to select a light.scene there? Only the 3 choices
As I told you - beginner mistake.

From the dropdown choose „Dienst ausführen“ / „execute service“ (don’t know what it’s called in the English UI) ——> scene.turn_on and then click/tap the green button as often as you like.

Hallo, aber da sind ja nur die einzelnen Lichtquellen aufgeführt, aber keine Szenen. Das ist ja die Ursache warum ich auf manuell umgestiegen bin.

Hello, but there are only the individual light sources listed, but no scenes. That is the reason why I switched to manual.

No offense but please take into account that the forums language is English :slight_smile:

Strange. In my editor all scenes appear if I choose scene.turn_on. If you are using Hue you can select hue.activate_scene