Need some help here, as I cannot seem to get the variable out to Sonos Media Player script.
I set up a list with favourites, and based on day of week, I get different music favourites to play to Sonos.
Whilst in template UI, the variable comes out correctly, but when I put it into scripts for automation to stat playing at certain times I get an error “Missing favorite for media_id: FV:2/29:”, yet template display this correctly, but wont work in script.
Please note, that I am learning to use template, just so anyone ask why I’m doing it this way, if there is a better way, at least I am trying to learn.
If you copy-paste the following template into the Template Editor, it will list the keys of the dictionary contained by the sensor’s items attribute (I am assuming you have a sensor.sonos_favorites entity). You’ll notice that each key’s name doesn’t end with a colon.
{{ state_attr('sensor.sonos_favorites', 'items').keys() | list }}
EDIT
For future reference, avoid posting screenshots of YAML; post the YAML as text. It spares the people replying from having to re-type the contents of your screenshot.
Thanks to Pedolsky and Taras - I did try Pedolsky, but it still gave me the same error as before, so I tried Tara’s solution and hey presto, just removing “:” worked, not sure why, as when I put this in hard code as well it still worked - is there a reason for this Tara?
Now I can resume with this, and will try out shorter version that Tara’s suggested. Noted the screenshot, I was having trouble submitting my issues when I did copy the code, even using the preformatted text, hence the screen shot, but found that I should have just put a tick in the do not show again next time I will just do that again.