Hi,
I hope somebody can help me. What am I doing wrong?
During the last day I managed to write my first script, to put a TTS message to one of my speakers and try to restore the speaker state afterwards.
My problem is the Variable âWasOffâ which should reflect the power state of the speaker. The variable âPlayerâ contains the entityID of the speaker and is consistent through the whole script.
The problem that I try to solve is that the snapshot function doesnât store the speakers mode (input) when the speaker is off, when creating the snapshot.
So my goal was to switch it on so the the input is active, snapshot the state and switch it off afterwards, when I had to switched it on, before the snapshot.
The problem is, that the variable âWasOffâ never seems to reflect the state at the end of the script.
I am at a loss, can somebody with more knowledge than me help please?
Cheers
hello @umtauscher ,
When have this working would you mind your finished project, or maybe create a blueprint for it.
I would love to use it myself as well.
@Taras
Thanks, but I donât have sonos speakers and I already experienced, that the mediaplayer interface is not the same using different manufacturers. For exaple SONOS speakers have the state âpausedâ when beeing idle, Yamaha Musiccast has the state âidleâ or âoffâ
I have a Yamaha-Musicast setup.
@ nielsnl68 Sure, I will post my script as soon as I have tested it sufficiently. I am far from putting it into a blueprint.
Cheers
Actually, my response was intended for nielsnl68. In addition, regardless of the speakerâs integration, the linked script also serves as an example of how to use script variables correctly. If nielsnl68 isnât using Sonos speakers, the script blueprint can be easily modified as needed.
Did you try the script variable example I posted above? Any questions about the difference between Jinja2 variables and script variables?
Like I said in my previous post, it doesnât matter if you are not using Sonos speakers. The linked script blueprint can be easily modified to work with whatever media_player integration you are using. If you donât want to modify it, just search for other examples of resuming music after a TTS message because there are many of them.
@Taras
I tested the mentioned automation and it didnât work. I even could not select any of my speakers.
I will continue with mine. Thanks @nilesnl68
If you are still interrested, I append my script that is working now for me.
I didnât parameterize the TTS Engine and the speak-volume, but since you have the script you could easily modify it.
Maybe there is a way to automaticcal select the standard TTS engine?
Glad to hear that the correct use of variables that I had suggested has corrected the problem you reported.
Please consider marking my post above with the Solution tag (only the topicâs author can mark one post). It will automatically place a check-mark next to the topicâs title which signals to other users that this topic has been resolved. This helps other users find answers to similar questions.
Thatâs because the author of that blueprint used a feature of the Entity Selector that allows you to restrict displayed entities to a specific domain and integration.
The integration is set to sonos so the selector will only display media_players based on the Sonos integration. Entity Selector can also constrain the selection by device_class.
Hey @123 , was just reading through this; I wrote the script you linked to. Nice breakdown of what I did and why. My script is definitely written for Sonos but I tried to document it to make it easy for people to adapt it or learn from it.
Anyhow, just wanted to send out a small shout-out / thanks
I was pretty close to a solution on my own, but had the same issue as the OP so this particular comment solved the issue I was stuck on. So then my whole script ran just fine, but it never played the music at the end.
I EVENTUALLY realised this was somehow because I was pausing the music before my announcement, so somehow pressing play at the end no longer had my music queued up or something.
Anyway removing the pause before the announcement (and just letting the announcement pause the audio naturally) fixed it!