Good afternoon,
I am trying to automate multiple music players and i want to add playlist to them at the same time automatically , without modifying the automation every time that I want to add a new player,
As you can see on the following script I have all the players added as a single service call method,
- id: '1610385979552'
alias: 'LMS - ADD PLAYLIST everyday at 7:55 AM '
description: ''
#Automation is triggered at 7:55
trigger:
- platform: time
at: 07:55
condition: []
action:
#automation calls a service that add the first playlist that is at favorite playlists all the parameters and command are from the LMS commands documentation
- service: squeezebox.call_method
data:
#name of entity/player
entity_id: media_player.nbhmusic2k
#tells the player that its looking for favorites
command: favorites
#tells the player to add the first favorite playlist it follows the CLI commands for LMS
parameters:
- playlist
- add
- item_id:0
entity_id: media_player.nbhmusic2k
#replies the same for 3k player
- service: squeezebox.call_method
data:
entity_id: media_player.nbhmusic3k
command: favorites
parameters:
- playlist
- add
- item_id:0
entity_id: media_player.nbhmusic3k
#replies the same for 4k players
- service: squeezebox.call_method
data:
entity_id: media_player.nbhmusic4k
command: favorites
parameters:
- playlist
- add
- item_id:0
entity_id: media_player.nbhmusic4k
mode: single
But, what i want to do is the following process with templates, as the following code
alias: 'LMS - ADD PLAYLIST everyday at 7:55 am'
description: ''
mode: single
trigger:
- platform: time
at: '07:55'
condition: []
action:
{%- for state in states.media_player -%}
- service: squeezebox.call_method
data:
entity_id: {{state.entity_id }}
command: favorites
parameters:
- playlist
- add
- item_id:0
entity_id: {{state.entity_id }}
{%- endfor -%}
but i can not do it it shows the following error …
Message malformed: Service does not match format <domain>.<name> for dictionary value @ data['action'][0]['service']
Any help on what can i Do
thanks