Hi everybody,
I am currently trying to connect rhasspy
to my home assistant. My test automation is to switch on my office fan. This is the code in automations/rhasspy.yaml
- id: '<number>'
alias: "turn on fan"
trigger:
platform: event
event_type: rhasspy_ChangeSwitchState
event_data:
name: ventilator
state: ein
action:
service: switch.turn_on
entity_id: switch.arbeitszimmer_ventilator
- id: '<number>'
alias: "turn off fan"
trigger:
platform: event
event_type: rhasspy_ChangeSwitchState
event_data:
name: ventilator
state: aus
action:
service: switch.turn_off
entity_id: switch.arbeitszimmer_ventilator
How can I template both name
and state
? Let’s say I have these names: ventilator, computer, light, desk
and states ein, aus
. I’d then like to
- if
state: aus
=>service: switch.turn_off
- if
state: ein
=>service: switch.turn_on
- if
name: ventilator
=>entity_id: switch.ventilator
- if
name: desk
=>entity_id: switch.desk
- if
name: light
=>entity_id: switch.light
- if
name: computer
=>entity_id: switch.computer
So if I say okay rhasspy, turn on computer
the automation will read on
and computer
that has been sent by rhasspy and will know the device and state to use. Currently I would have to copy this block of code for each device and each state, but I am sure automation template can do what I want. I am just not understanding the syntax enough.
I assume I can use to_state
for the state, but since I am using German voice commands, it would create switch.turn_ein
or switch.turn_aus
instead of on/off
- and that’s only if I manage to figure out the syntax.
My fan is currently named arbeitszimmer_ventilator
, which I’d have to change to ventilator
only in order for this to work. But that’d be fine with me. Or perhaps I’d call the device arbeitszimmer ventilator
in rhasspy
, but then home assistant would somehow have to add replace the empty space in the name
payload with _
.
I have read through automation templates but just don’t understand how to use them. Would anybody be so kind to help me out with a minimalistic script that works in my scenario and that I can build on?
Thanks in advance for your help