Try to get an Automation but get fault code

Vad är det för fel på denna Yaml koden

Get this when I try to save it :frowning: Message malformed: extra keys not allowed @ data[‘0’]

  • alias: ‘Turn off lights when both doors are closed’
    trigger:
    • platform: state
      entity_id:
      • c6175cb7120463acecdcb81c58944d4e
      • d51dbb13f6819fc64734d7dda457c376
        to: ‘off’
        condition:
    • condition: state
      entity_id: c6175cb7120463acecdcb81c58944d4e
      state: ‘off’
    • condition: state
      entity_id: d51dbb13f6819fc64734d7dda457c376
      state: ‘off’
      action:
    • choose:
      • conditions:
        • condition: state
          entity_id: ‘0f849f2a7c688cc68d253b832070a35’
          state: ‘on’
          sequence:
        • service: light.turn_on
          target:
          entity_id: ‘abf49bac076e5986434aaa2f7e9ae6a8’
          data:
          brightness_pct: >
          {% set other_lights = [states.light.andra_lampor] %}
          {% set max_brightness = 0 %}
          {% for lamp in other_lights %}
          {% if lamp.state == ‘on’ %}
          {% set level = lamp.attributes.brightness | int / 255 * 100 %}
          {% if level > max_brightness %}
          {% set max_brightness = level %}
          {% endif %}
          {% endif %}
          {% endfor %}
          {{ max_brightness }}
      • default:
        • service: light.turn_off
          target:
          entity_id: ‘abf49bac076e5986434aaa2f7e9ae6a8’

If you want someone to help you, please format your code properly

What he said. :grin:

But does light.turn_on accept a template for brightness_pct?

Make sure those are actually entity_id’s not device_id’s…
I HIGHLY suggest using the human readable version of the entity_id’s.

Oh, and yes, fix the formatting…
You can use the </> button like this… How to format your code in forum posts
OR… Here is an example of how to fix it from the site FAQ Page.
How to help us help you - or How to ask a good question.

Sorry for the formating is totaly new on this, coding is not my thing :frowning:

1 Like

Thanks, cant se that i can editing my text any more…