So, I’m very new to HA, and I’d like to try and get my first piece of automation up and running.
I’d like to have one of my Sonos units (bedroom) play a specific radio station at a specific time, and possibly start with the volume at 0 and fade up to a specific level. Now, this is where I get a bit lost. I’ve looked at some examples, and I’m finding the structure a little confusing, as well as knowing if terms being used (say, script.turn_on) are something unique to the example I’m looking at, or specific to the entity, or just present in HA and can be called on as needed.
I’ve got an include in my main config to pull in a file containing my automation, which then has an include to pull in a file containing this particular piece of automation. Can I put everything in that file, or do I need to call a script?
I’m happy to try and work this out, but I guess I’d be after a reference guide to what commands I can use.
If you look at services under dev tools (looks like a computer tower icon). You can look at all of your domains and the services that are available to those domains.
For example in your question, script would be the domain and turn_on would be the service.
Hope that helps get you started. If you post your current automation I’m sure someone can help you fine tune it.
For future reference, It’s helpful to paste your code using the preformatted text option. This will retain indents and spacing which is important in yaml.
Paste your code, highlight it and then click the “< / >” button at the top of the post editor.
That said. You could add an action to turn on a script.
Ah, I’d wondered how to paste ‘as code’ so the formatting was maintained - that’s what not enough sleep does to your brain!
Thanks for the advice Mike! I’ll pick that script apart later so I understand what’s it’s doing when I implement it. I work in IT, but I’m not a coder by nature, so this stuff is coming a little harder than, say, the networking side of this home automation project!
No problem. I’m in the exact same boat as you. Server admin, not a programmer and I’ve only been using HA for about 2-3 months. The community here is great though, so that helps a lot.
@Mike_D where does one find the media_content_id: like what you are using the “x-rincon-mp3radio://”? I’ve seen these all over in example configs but have no idea where it’s coming from. Thanks!
Unfortunately I don’t have a Sonos. But I’m going to guess and say in the attributes of your Sonos media_player in the states-dev tool section. Probably need to be playing that station at the time you check.