wow. I feel dumb now. THANK YOU. I somehow cross named them. ( Was aware they are different, and named them differently intentionally - but somehow mixed up my naming convention )
For anyone using the great Google Cloud TTS with this, this is how it works, even for selecting language, voices, ā¦:
service: media_player.play_media
data:
entity_id: media_player.yourplayer
media_content_id: >-
media-source://tts/google_cloud?language=de-DE&voice=de-DE-Wavenet-B&message=Your_text_here
media_content_type: music
extra:
volume: 30
play_on_bonded: true or false
Replace de-DE-Wavenet-B with your Google voice of choice.
You can say the content of an entity with this:
media-source://tts/google_cloud?language=de-DE&voice=de-DE-Wavenet-B&message=ā{{
states.sensor.yoursensorhere.state }}ā
Since upgrading to HA 2022.6 and Sonos Cloud 0.3.0, Iāve had a few times when the integration suddenly stops working with error message āinvalid access tokenā.
The first time it happened, I noticed log message āā¦Application Credentials have been imported and can be removed from configuration.yamlā - so I removed them. This didnt fix the issue so I deleted the integration (and restarted HA just in case). When I added the integration again, I wasnt prompted to enter a client ID or key (even after deleting from configuration.yaml and deleting the integration). But it remember them and the problem was fixed.
Today it failed again, after working fine for about 2 weeks.
2022-08-04 17:54:59.500 ERROR (MainThread) [custom_components.sonos_cloud] Household request failed (401): {"fault":{"faultstring":"Invalid Access Token","detail":{"errorcode":"keymanagement.service.invalid_access_token"}}}
This time I deleted the integration, then created new credentials in Sonos Dev account (even though the old ones hadnāt changed). When adding the integration again, it STILL didnāt ask for client credentials so I was forced to enter the new client ID and key in configuration.yaml. Now its working again.
- Has anyone else had this problem after upgrading from configuration.yaml version?
- Where are the client ID and key stored now and is there any way to delete them?
Thanks.
Iāve had that a few times now as well, no particular pattern identified. On each occasion I have removed the Integration, rebooted and then re-added it. This has always prompted to re-authentication which I have done with the original details. Interesting Iām being prompted to re-authenticate and your notā¦
One difference is I have the client credentials commented out in my configuration.yaml
Itās definitely not obvious, but theyāre on the Integrations page hidden behind the top-right āā¦ā button as āApplication Credentialsā:
This will hold the credentials imported from configuration.yaml
or ones you add during the new onboarding flow.
I havenāt hit these 401 errors myself and Iām wondering if theyāre transient. If you leave the credentials as-is and wait some time, does login with the same credentials later succeed?
I have this issue too, starting with the same upgrade to Sonos Cloud 0.3.0.
It does not start working again if I wait, at least after 24 hours.
Edit: I created a fresh Sonos Developer API key and deleted/reinstalled the integration. Weāll see how long it lastsā¦
Thanks @jjlawren. I wasnāt aware HA stored OAuth credentials there. Makes perfect sense now.
To answer your question, both times when it stopped working I left it for about 24 hours and it continued to fail. So it doesnt appear to be transient and has been 100% reliable for many days leading up to those moments.
The first time I used the same OAuth credentials to get it working again, so Iām not sure where the 401 is coming from. Maybe HA itself? Let me know if you want me to enable verbose logging or check anything if it happens again. Happy to help because this is the best Sonos integration by far.
Interesting. To clarify, after re-adding I was not prompted for the Sonos Dev Application credentials, but I was prompted for my main Sonos Account credentials. Next time I can try deleting the OAuth credentials from the Application Credentials page. Then Iāll see how long it lasts if the credentials arenāt imported from config.yaml.
Thatās pretty crappy. The native TTS is awesome and volume control would be a pretty dang useful feature when trying to use Sonos speakers for system announcements. Boo.
Thatās a very old comment youāre replying to. Check out the examples for how to accomplish this today.
This integration rocks, thanks for your hard work!
We like to have parties around sporting events and Iām using this to play music during commercial breaks/after scores/etc. It really ups the atmosphere! I basically created a āSoundboardā tab and can pick from what Iād like to hear.
One question though, is there a way to make an āinterruptā button? Sometimes Iāll start a song and the game will quickly come back from commercial and I donāt have a way to stop the playing media and return to the TV audio.
The API states that currently playing alerts can be interrupted by followup calls. Perhaps try to play an āemptyā alert to cancel whatās playing?
@jjlawren Iām also seeing the āInvalid Access Tokenā error. I canāt pinpoint when it happens, but the error does not repeat and the integration works on subsequent attempts to use SONOS cloud. Seems to be occurring after a long (~8 hours) of no use of the integration.
Your comment mentions the use of the Application Credentials in the configuration.yaml fileā¦ I donāt have the credentials there. Just in the integration setup section of HA. Should the credentials be referenced in the configuration.yaml file?
Not sure I can make any guesses besides it being a transient issue with the cloud service.
No, thatās just old info from before the HA credentials store existed.
I just loaded this integration, but canāt get it to work via a service call. this is what i am using:
service: media_player.play_media
data:
entity_id: media_player.living_room_sonos_cloud
media_content_id: media-source://google_cloud_say?lanaguage=en-GB&voice=en-GB-Standard-F&message=Testing Sonos text to speech
media_content_type: music
extra:
volume: 50
I can call this service, and i get no errors in the log, but i also donāt get any voice on the sonos. If i go to the media tab and select google cloud TTS using the same media player as an output i do get playback on the sonos. I have tried the message with and without single quotes. anyone have any ideas?
Try something like this:
service: tts.google_cloud_say
data:
entity_id: media_player.living_room_sonos_cloud
message: Testing Sonos text to speech
language: en-GB
thanks, that works, butā¦ it doesnāt give me the options to set volume like in the play_media call. basically i was following the third example at https://github.com/jjlawren/sonos_cloud#examples
This isnāt what your looking for but will work, go to the media_player.living_room_sonos_cloud entity and set the volume there, once set on the entity any time itās called it will use that volume.
The format looks wrong. Try media-source://tts/google?...
as the media_content_id
.
that i didnāt know, thank you!