Thanks for your post. It was a life saver.
I had been working on it for 3 days. None of the other links gave the location of the mp3 file. I was trying /config/media/ and that doesnât work. It also doesnât work without the 8123 port.
Have just begun my journey to have announcements on my Sonos. Found your code, but after trying to include it in my configuration.yaml file I received a bunch of errors.
- service: media_player.play_media
data:
entity_id: media_player.bad
media_content_type: music
media_content_id: 'http://10.0.1.85:8123/local/Test.mp3'
Could you please give me some context, such as where the code is added, and I assume this could just be triggered by an automation? Also, in relation to the media_content I assume the mp3 files are in a directory under /config??
Not sure I understand what you mean by âwhere the code is addedâ ?
The code forms part of a script that will play audio to a (sonos) speaker. If you search for âSonos TTSâ, there are a number of examples that show you how this works.
You can either create scripts manually (which is what most people tend to do once they know how), or use the scripting tool within HA.
Probably like a lot of others, we are looking for where to put the codes you post to do something. any yaml? (config/script/automat/etc.) and what part it is, or what precedes it? The question was to play music and we get utfg on TTS. If someone is interested in TTS, they will find it themselves, right? This whole community shares snippets of meaningless code, without continuity, itâs nice that you know, but no one else does.
I share your pain⌠unfortunately that has been my personal experience. Mind you I am appreciative of those people that share, just sometimes the gurus may forget those of us that are rookies, and it takes us time to âget itâ with the coding.
Iâve likened my experience to reading a crime novel⌠picking up clues as I go, hopefully solving the mystery at the end. Can be frustrating at times, and doesnât help when guruâs run out of patience with those of us finding our way.
Not sure if it helps⌠but this community is literally the same as others, so try not to be discouraged.
I understand your frustration, but unfortunately where you put the code is down entirely to how you have configured and manage your Home Assistant installation.
In the case of the script snippet, at a basic level it goes in scripts.yaml. However, depending on how you configure your setup, this will need to be edited to work (IDâs, location, etc)
For example, in my case, I have split all my yaml code (see Splitting up the configuration - Home Assistant ) and if you read that section (and the examples) you will notice that everyone does it differently. Some will break their code down into very small sections and individual yaml files (as I do) whilst others will create larger files containing (for example) all their scripts.
Below is a screenshot from my Git account showing (at a high level) how I organise my code.
It is unique to me, although a number of other people will use similar structures.
This is why you will invariably see just code snippets posted, because everyone manages their code differently. The code I posted will work, you just need to understand where to post it within your own personal HA setup.