Set-Up:
I’m on HA 2021.1.4.
I’m sending events to HA via voice control Rhasspy to switch on/off zigbee light blubs and plugs that are set to lights in HA.
This works like this: Rhasspy sends an event to HA, and with this event some data, depending on your speech input.
E.g. Saying “turn off LED Strip” and “turn on living room lamp” sends an json event called “Lights” with data “location” and “action” to HA. This is used to fire the HA event with the respective parameters. This is working fine with this code:
alias: Voice Control Lights On/Off
trigger:
- event_data: {}
event_type: rhasspy_Lights
platform: event
condition: []
action:
# Should send feedback to Rhasspy for spoken confirmation. Not working at the moment.
- data_template:
siteid: '{{trigger.event.data._intent.siteId}}'
payload: OK, {{ trigger.event.data.location }} {{trigger.event.data.action}}
service: rest_command.rhasspy_speak
# Switch lights on/off
- data_template:
entity_id: light.{{ trigger.event.data.location }}
service_template: light.turn_{{ trigger.event.data.action }}
mode: single
What I’m trying to do:
Some of the lights are colored. I want to change the color of the lights via Rhassy voice command. E.g. “Set LED Strip color to blue” or “Set living room lamp to orange”.
What I tried:
Rhasspy sends an event “ChangeColor” to HA with “location” and “color” data.
Automation in HA (not working):
alias: ChangeColor
trigger:
- event_data: {}
event_type: rhasspy_ChangeColor
platform: event
condition: []
action:
# Should send feedback to Rhasspy for spoken confirmation. Not working at the moment.
- data_template:
siteid: '{{trigger.event.data._intent.siteId}}'
payload: OK, {{ trigger.event.data.location }} set to color {{trigger.event.data.action}}
service: rest_command.rhasspy_speak
# Change color of light
- service: light.turn_on
data_template:
color_name: '{{ trigger.event.data.color }}'
entity_id: light.{{ trigger.event.data.location }}
mode: single
It seems to be an issue with the entity.id in the penultimate line of the code above. Setting the entiy.id to a specific entity (e.g. “light.ledstrip_1”) DOES work, i.e. I can change color of ledstrip_1 by sending the respective events+data from Rhasspy.
What am I doing wrong? Thanks for any hints.
P.S, I’m completely new to this and already spent way more time on playing around with Rhasspy and HA than I care to admit. Just a big fan of the idea having a humble offline smart home toy.