Mediaplayer automation doesn't work

Hi,

I am new to home-assistant and loving it greatly. Got my devices set up and wanted to start creating automations. So I created an automation to turn on the stereo via an Harmony hub when the Google (audio)cast starts playing, the yaml for this is as follows:

alias: 'Turn on stereo when audio starts playing'
description: ''
trigger:
  - platform: state
    entity_id: media_player.sleepingroom_audio
    from: 'off'
    to: playing
condition: []
action:
  - type: turn_on
    device_id: 01f497fa794a14d919e4d714bc20307e
    entity_id: switch.hub_sleepingroom_music
    domain: switch
mode: single

But somehow this automation doesn’t work. What am i missing?
I created the automation using the UI and the ‘’ at off are placed there automatically.

Thanks in advance,
André

Remove the from: 'off' line and see if it works. The state may be transitioning from idle to playing.

Thanks! That worked. Strange as i thought the only states where off or playing and not idle.

I believe you can also do it this way, but there’s not really any reason to:

trigger:
  - platform: state
    entity_id: media_player.sleepingroom_audio
    from:
      - 'off'
      - 'idle'
    to: playing

Also that only works if using yaml. The UI automation editor incorrectly converts it to:

trigger:
  - platform: state
    entity_id: media_player.sleepingroom_audio
    from: 'off, idle' # the quotes should only be around each individual state not the whole thing.
    to: playing