The main issue I am having is that nothing happens and I get an error in the logs:
2018-07-06 12:50:50 WARNING (SyncWorker_5) [homeassistant.components.media_player.sonos] Loading Sonos via platform config is deprecated.
2018-07-06 12:50:54 ERROR (MainThread) [homeassistant.core] Invalid service data for media_player.sonos_snapshot: Entity ID ['media_player.living_room' is an invalid entity id for dictionary value @ data['entity_id']. Got "['media_player.living_room', 'media_player.master_bedroom', 'media_player.theater']"
2018-07-06 12:50:54 ERROR (MainThread) [homeassistant.core] Invalid service data for media_player.sonos_unjoin: Entity ID ['media_player.living_room' is an invalid entity id for dictionary value @ data['entity_id']. Got "['media_player.living_room', 'media_player.master_bedroom', 'media_player.theater']"
2018-07-06 12:50:54 ERROR (MainThread) [homeassistant.core] Invalid service data for media_player.volume_set: Entity ID ['media_player.living_room' is an invalid entity id for dictionary value @ data['entity_id']. Got "['media_player.living_room', 'media_player.master_bedroom', 'media_player.theater']"
2018-07-06 12:50:54 ERROR (MainThread) [homeassistant.core] Invalid service data for tts.google_say: Entity ID ['media_player.living_room' is an invalid entity id for dictionary value @ data['entity_id']. Got "['media_player.living_room', 'media_player.master_bedroom', 'media_player.theater']"
I would love to be able to pass an array or a group to a script in some way.
I think the problem is that when you use the variable sonos_entity (which is an array) in a template (which you have to do) it turns into a string. So [a, b, c] turns into "[a, b, c]", which of course, is no longer an array.
However, some things that can take an array of entity_idâs will also take a string of comma separated entity_idâs. So, you could try this:
I tried passing a group before asking for help in this thread, and it didnât work. Maybe I was doing something wrong. Would you be able to post an example code so I could learn?
If youâre asking about a delay step in an automation action or a script, it does accept a template. If the template returns a single number, it will be interpreted as seconds.
I donât think this is correct, though:
{% set duration = states.[sonos_entity]|default('media_player.living_room').attributes.media_duration %}
If sonos_entity is an entity_id, then this should work:
- delay: >
{% set duration = state_attr(sonos_entity|default('media_player.living_room'), 'media_duration') %}
{% if duration > 1 %}
{% set duration = duration - 1 %}
{% endif %}
{{ duration }}
Yes, I know sonos_entity is not an entity itself. Itâs a variable. My question was what does that variable contain. And, yes, Iâm aware of the code in the OP, but that doesnât mean youâre using it as-is.
If sonos_entity does indeed contain a comma separated list of multiple entity_idâs, then what I suggest would not work. But in that case, which entityâs media_duration attribute would you want to use? And if itâs not a comma separated listed of entity_idâs, then youâll need to be specific about that.
So do you still need help at this point, and if so, can you be a bit more specific about what youâre looking for?