GOAL: I’m trying to use an input select drop-down on my HA dashboard to select which speaker group my alarm plays on when it’s next triggered.
I’ve created an input_select.room_speaker_list that lists the groups I want in plain language.
All Speakers
Office Speaker
Common Area
Etc… I have added this input select list to an entity card on my dashboard and am able to see/ select the options without issue.
Additionally, I have created an alarm automation based on the wonderful work posted on this forum.
When the alarm is triggered, it does a number of things including
media_player.volume_set
–> to set chromecast group volume to a specific amount, currently sets media_player.all_speakers to vol .9
media_player.play_media
–> currently plays a short jingle on media_player.all_speakers
tts.google_cloud_say
–> currently announces the time based on if/elif statement using above input select (see down below for code) <== this appears to be working
While this input select statement works with tts.google_cloud_say, it does not appear to work with either media service (vol set/ play media) resulting in the following message
Message malformed: not a valid value for dictionary value @ data['action'][4]['entity_id']
So, my question is how do I use an input select to substitute for entity_id: for the media_player services
I’ve tried using if/elif, I’ve tried using entity_id: input_select.room_speaker_list, I’ve tried using entity_id: ‘{{states(“input_select.room_speaker_list”)}}’
I’m stumped and raising the white flag. Appreciate any help you can offer.
Thanks so much for the suggestion!
It’s not working in my case though, still getting Message malformed: not a valid value for dictionary value @ data['action'][4]['entity_id']
Now you have entity_id twice for the same service.
You can also simplify this, as your input selects options are the entity_ids just in proper case and with spaces. Try this:
This is what I would like to work, from an actions perspective, currently though only the tts section is functioning properly with the if/elif statement as entity_id
I tried to decipher the unformatted automation you posted and then correct it. Here is the result which also includes several techniques to reduce duplication of code. This version passes “Check Configuration”.
Thanks for helping out with this, planning to try this evening. One question, I don’t see a variables option in automation actions under the UI, I assume I simply add one action then combine everything in yaml in the UI?
Resulting message on save Message malformed: expected dictionary @ data['action'][0]
I was hoping this was a simple issue of having my input_select.room_speaker_list syntax wrong or something, but it looks like this is fairly difficult to accomplish. Appreciate all the help so far!
You never posted a properly formatted version of your automation so what I posted is based on a best guess of what you did post (which was a mess).
What I posted is confirmed to pass ‘Check Configuration’ without errors. The error message you are getting now is because you (somehow) introduced a syntax error during the copy-paste process.
The media_player entities I used in my example come from what you had posted. If you haven’t actually defined these entities yet then you should.
I don’t use the UI’s Automation Editor because it has too many limitations; can’t help you with that.
Hmn… I prefer the UI editor cause I can edit on the fly.
What if I approach this differently, it’s not as optimized, but I can duplicate the working automation per speaker group, update the entities and then add a condition to check state of the input select?
Configuration > Automations > Add Automation > Start with an Empty Automation
Open the overflow menu (three vertical dots) in the extreme upper right hand corner.
Select Edit as YAML
Erase the default code that is displayed
Paste the code I posted above
On the first line, replace the hyphen in front of the word alias with a space
Click Save
Optionally, click the overflow menu and select Edit with UI. It will convert whatever it can into UI mode and whatever it can’t (like variables) will be left as YAML.