Automation - what is wrong here?


#1

Pulling my hair out for the last hours.

- alias: Film Ende
  trigger:
    platform: state
    entity_id: media_player.kodi_wohnzimmer, media_player.schwarzes_kastchen
    to: 'idle'
  condition:
    - condition: state
      entity_id: light.wohnzimmer_stehlampe
      state: 'on'
  action:
    service: light.turn_on
    data:
      entity_id: light.wohnzimmer_stehlampe
      color_temp: 400
      brightness_pct: 100
      transition: 4

- alias: Licht an, wenn Film schon spielt
  trigger:
    platform: state
    entity_id: light.wohnzimmer.stehlampe
    to: 'on'
  condition:
    - condition: state
      entity_id: media_player.kodi_wohnzimmer, media_player.schwarzes_kastchen
      state: 'playing'
  action:
    service: light.turn_on
    data:
      entity_id: light.wohnzimmer_stehlampe
      color_temp: 453
      brightness_pct: 20
      transition: 3

The second alias does not work, hass complains: “Invalid config”. It must be something obvious, but I do net see it :frowning:
What I want to achieve: If a film is running, and someone turns the light on (while the film is running), then I want to set the light to a defined state (temperature, brightness)
Any help is appreciated,

Rainer


#2

Try taking the comma out of the alias line.


#3

Change condition in second automation to:

  condition:
    - condition: state
      entity_id: media_player.kodi_wohnzimmer
      state: 'playing'
    - condition: state
      entity_id: media_player.schwarzes_kastchen
      state: 'playing'

That will require both to be playing. If you want it to run if either is playing, then:

  condition:
    condition: or
    conditions:
      - condition: state
        entity_id: media_player.kodi_wohnzimmer
        state: 'playing'
      - condition: state
        entity_id: media_player.schwarzes_kastchen
        state: 'playing'

#4

Still invalid :frowning:

- alias: Licht an wenn Film schon spielt
  trigger:
    platform: state
    entity_id: light.wohnzimmer.stehlampe
    to: 'on'
#  condition:
#    - condition: state
#      entity_id: media_player.kodi_wohnzimmer, media_player.schwarzes_kastchen
#      state: 'playing'
  condition: or
  conditions:
    - condition: state
      entity_id: media_player.kodi_wohnzimmer
      state: 'playing'
    - condition: state
      entity_id: media_player.schwarzes_kastchen
      state: 'playing'
  action:
    service: light.turn_on
    data:
      entity_id: light.wohnzimmer_stehlampe
      color_temp: 453
      brightness_pct: 20
      transition: 3

hass 0.80.3 on Raspian


#5

should be:
light.wohnzimmer_stehlampe


#6

Good find!

But the config is still invalid :frowning:


#7

There should be one upper “condition” and quoted lines idented under it. See here https://www.home-assistant.io/docs/scripts/conditions/#or-condition


#8
- alias: Licht an wenn Film spielt
  trigger:
    platform: state
    entity_id: light.wohnzimmer_stehlampe
    to: 'on'
#  condition:
#    - condition: state
#      entity_id: media_player.kodi_wohnzimmer, media_player.schwarzes_kastchen
#      state: 'playing'
  conditon:
    condition: or
    conditions:
      - condition: state
        entity_id: media_player.kodi_wohnzimmer
        state: 'playing'
      - condition: state
        entity_id: media_player.schwarzes_kastchen
        state: 'playing'
  action:
    service: light.turn_on
    data:
      entity_id: light.wohnzimmer_stehlampe
      color_temp: 453
      brightness_pct: 20
      transition: 3

Invalid :frowning:
I give up for today/tonight.


#9

What would really really help everyone to assist you here would be if instead of just saying “invalid” you posted the actual error message, which will tell you exactly what is wrong, and we can then help you fix it.


#10

I’d really want to provide the error, but there is noting but “invalid config” in the UI. Nothing in home-assistant.log.

The actual config is here: https://gitlab.sokoll.com/rainer/home-assistant/tree/%2310


#11

The error message will be immediately below where it says invalid config.

You’ve missed the second letter I out of the word condition.


#12

@mf_social Oh my bad - you’re correct. it was the missing “i” - and there was no more information in the UI, I swear.
Thank you so much!