Hi, I have around 5 lights in my set-up. Currently I have an ‘automation’ for each of them individually to turn them on and off -> 10 automations. This does not really scale.
Is there an easier way to create only two automations (on/off) and keep the light-name as a parameter, received from an rhasspy voice-command input event? How and where would I add that?
One exemplary trigger event is: rhasspy_ChangeLightState
Hi Petro, thanks for helping. I added the automation.yaml to above post, can you see it? Or did you mean another yaml? Here are some more entries. They are all the same format. Light on, Light off. I created an individual automation for each of these interactions, which seems like an overkill to me. I’d love to have something like
Take a look at the trigger object and it’s data (through templating).
Pretty much what we are doing here is triggering on ANY rhasspy_ChangeLightState event. But we only fire when ‘state’ and ‘name’ are inside the event data. Then we use ‘name’ and ‘state’ to call the correct switch. We need to use template fields to use templates. So that’s why it’s using service_template and data_template. You can’t put templates anywhere, the need to be called out. Also, you can’t just add _template to a field and expect it to work. It just so happens that service_template and data_template are valid templating fields.
Wow Petro, I’m blown away! This works like a charm on the first try - copy & pasted.
Thank you also for the detailed explanation. Writing the value_template like this sounds very odd, because it is so ‘human readable’, that I first thought it was an explanation. Works fine.