ERROR (SyncWorker_2) [homeassistant.components.media_player.sonos] Error on play_media with UPnP Error 714 received: Illegal MIME-Type from ipaddresshere
…however if I switch media_content_id to just the link to the mp3 (without the logic), it works just fine.
I’ve been trying for hours to get this working now … can someone help?
Well, I haven’t played with media_player items yet, but right off the bat, I think, in the action part of your automation, you have data where you should have data_template, and you have data_template where you can use just data.
And, FWIW, you don’t need the elif, you can (and probably should) just use else.
As @pnbruckner said, you need the data_template instead of data. Also, you need to add a default sound for when the input select isn’t selecting something in the interface, i.e startup. So you need to add an else and choose a default media to play. Or do what @pnbruckner said and swap the elif is_state(…) for else.
One thing about jinja is that you should never leave pathways that don’t provide data because yaml won’t complain and you could cause python errors.
Also, the “initial” entry under “input_select” should make sure “birds” is selected if no user actually changes its value manually I believe…
When I check in the template editor, it shows correct values (i.e “birds” or “beach” depending on what is chosen.
I’m pretty sure using is_state() will let you use a simple else. I.e., is_state() will never fail, even if input_select.wakeup_sound didn’t exist. It would simply return False. I think that’s the main reason for that function existing (although it does also make it a little easier than having to enter states.input_select.wakeup_sound.state == ‘birds’.)
FWIW, after having done some careful inspection of the HA log during startup, I’m pretty sure you don’t have to worry about the automation running before an input_select is ready to do. Either it will have the value it had before HA shutdown (assuming you’re using the logger), or it will have the initial state (if you specify one.) Even if it were to come up with no selection, again, I think using is_state() will “protect” you from that scenario. But, again, I’m still pretty new to HA and I still get surprised on a daily basis.
Glad you got it working. Just as an FYI, if you use ‘reply’ under a persons name or tag them, it will send them a notification. I never got any so didn’t even know you responded!