Hi!
I created an automation for a media player- in this case for SONOS.
I checked the state of the 4 players and when some of them change the state from “off” to “paused” (and it is after 11o’clock) the player which has changed the state should begin to play.
The problem is the that the log say:
homeassistant.bootstrap: Invalid config for [automation]: Entity ID trigger.to_state.entity_id is an invalid entity id for dictionary value @ data[‘action’][1][‘entity_id’]. Got None. (See /home/homeassistant/.homeassistant/automation.yaml:4). Please check the docs at Automation - Home Assistant
Because I used for the entity_id of the service the “trigger.to_state.entity_id”.
Here is the complete code:
- alias: 'Status Sonos'
initial_state: 'on'
trigger:
platform: state
entity_id: media_player.kuche, media_player.bad, media_player.wohnzimmer, media_player.schlafzimmer
from: 'off'
to: 'paused'
condition:
- condition: time
after: '11:00:00'
action:
- service: notify.pushover
data_template:
message: >
{{ trigger.to_state.attributes.friendly_name }} is {{ trigger.to_state.state }} und {{ trigger.to_state.entity_id }}
title: "state change alert"
- service: media_player.play_media
entity_id: trigger.to_state.entity_id
data:
media_content_id: x-rincon-mp3radio://regiocast.hoerradar.de/deltaradio-foehnfrisur-mp3-hq?sABC=582r034r%230%235469p473qo9365nr3n7564s9sn
media_content_type: music
I use the notification for debugging:) the value of “trigger.to_state.entity_id” is the correct entity_id of the correct media player e.g.“media_player.schlafzimmer”
The value is correct but the log tells me that this is an invalid entity_id
- service: media_player.play_media
data:
entity_id: '{{trigger.entity_id}}'
media_content_id: x-rincon-mp3radio://regiocast.hoerradar.de/deltaradio-foehnfrisur-mp3-hq?sABC=582r034r%230%235469p473qo9365nr3n7564s9sn
media_content_type: music
then I got no error by restart, but when I trigger the automation, I got in the Log:
homeassistant.core:
Invalid service data for media_player.play_media: Entity ID
{{trigger.entity_id}} is an invalid entity id for dictionary value @
data[‘entity_id’]. Got ‘{{trigger.entity_id}}’