Hi
It seems there is a missing link between installing the Rhasspy plugin and adding my lights to Home assistant. I am very great full to the community for making these two cool tools but I think the last 1% is missing. Once I enabled all the stuff in Rhasspy mic and speaker and used all the recommended stuff it took me WAY to long to connect the events generated in Rhasspy to HA. I was also not prepared to write multiple files different setting that I know would change later or would require maintaing.
This script will turn individual lights on and off or all the ground floor lights. When event come though from Rhasspy they will have a space in the name. This is stripped by the script.
In the sentences I have
[ChangeLightState]
lightname = ((ground floor | living room | hallway | back garden | dining room) {name}) | <ChangeLightColor.lightname>
light_state = (on | off) {state}
turn <lightstate> [the] <lightname> light
turn [the] <lightname> light <lightstate>
turn [the] <lightname> lights <lightstate>
Then in HA I have one automation.
alias: Change Lights
description: ''
trigger:
- eventtype: rhasspyChangeLightState
platform: event
condition:
- condition: template
value_template: '{{ ''name'' in trigger.event.data and ''state'' in trigger.event.data }}'
action:
- servicetemplate: light.turn{{ trigger.event.data.state }}
data_template:
entity_id: >
{% if trigger.event.data.name|replace(" ","") == 'groundfloor' %}
light.diningroom,light.livingroom,light.hallway
{% else %}
light.{{ trigger.event.data.name|replace(" ","")}}
{% endif %}
mode: single
You will most likely need to adjust your entities above in this example they were called
light.hallway
light.livingroom
light.diningroom
etc…
This saves writing a truck load of jinja2 for every light state. I am shocked this is not the default style of setup. As for jinja2 WTF who invited that language to the party?
good luck with your setups and have fun.