Not sure if this is the best way of executing this or of sharing this but I didn’t quite understand how this was supposed to work and thought it could be helpful to share this for others.
I have 41 switches in HA (mostly Kasa tp-link). I wanted to just have a simple “intent” to turn them on or off. I tried to figure out the least amount of code / config necessary to do that and this is what I came up with (please let me know if there was something simpler):
There are basically 3 things that were needed.
Update the sentences.ini with my intent
Create a slots file with the list of switches / lights from HA (using their friendly name)
Create an automation in HA that responded to the intent
In a file called switches in my profile/slots directory:
3D Printer
Back Door Light
Basement Light
Christmas Lights
Dining Room Fan
Dining Room Light
Dining Room Restart
Front Door Light
Garage Charger 1
Garage Charger 2
Garage Light
Gym Lights 1
Gym Lights 2
Kitchen Light
Kitchen Restart
The rest of my 41 switches with the friendly name that is in HA one per line
I was going to write something that just creates that slots file on a regular basis / on demand, but my list of switches don’t change too often as of now. Hopefully this helps someone else out, but I would also really appreciate any advice / feedback to confirm if what I did made sense or not.
I was attempting to just use a selectattr to match on the name instead of the for loop but I couldn’t figure out how to get it to match on the lower case name. I couldn’t find an case insensitive match (I guess I could have done a regex match instead).
Like this (Kitchen Lamp):switch.kitchenLamp
So you will have entity id and won’t need for cycle
Also in this case friendly_name in HA and device name in Rhasspy can be different
I wanted to do that way but I couldn’t figure out how to programatically map the friendly name and entity id in rhasspy. I didn’t see any sort of dictionary or other lookup mechanism. Any ideas?
Thanks for sharing this: can’t wait to try it at home!
Did you know if it’s possible to use substitutions also for the slot “state_onf_off”?
In fact, I will used french words (allume/allumer, éteins/éteindre) in place of “on” and “off” words.
So I could used the same HA automation that the one you share