Beginners guide to use Rhasspy with HomeAssistant

reserved for part 5 :slight_smile:

4 Likes

I hope you find this guide useful and can learn some things for yourself and your use of Rhasspy and Home Assistant.

As always, all input is welcome! :slight_smile: Criticize, find faults, or just tell me, how you liked it - input is welcome!

If you want something added, please leave a note!

And if you have questions, please use this thread to ask, I don’t know all the answers to life, but maybe someone else does! :rofl:

Happy voice commanding! :slight_smile:

2 Likes

Hey. Thanks for the great guide. Very concise and useful.
Here is my automation

  alias: Rhasspy Lights
  description: ''
  trigger:
  - platform: event
    event_type: rhasspy_LightState
    event_data: {}
  condition: []
  action:
  - service: light.turn_{{ trigger.event.data.state }}
    template_data: {}
    target:
      entity_id: "{{ trigger.event.data.entity }}"
      # entity_id: light.dining_room_light
  mode: single

I have a little trouble getting the entity template to work. For the single light case shown commented out it works fine.
For the data: {} line I have also tried template_data: {} as shown above.
Also tried double quotes although single quotes should be correct.
I tried again with
entity_id: 'light.{{ trigger.event.data.entity }}'
but always get the automation trace showing like

trigger:
  id: '0'
  idx: '0'
  platform: event
  event:
    event_type: rhasspy_LightState
    data:
      entity: dining room light
      entity_raw_value: dining room light
      state: 'on'
      state_raw_value: 'on'
      _text: turn dining room light on
      _raw_text: turn dining room light on
      _intent:
        input: turn dining room light on
        intent:
          intentName: LightState
          confidenceScore: 1
        siteId: C1
        id: 05180ee4-835a-4a54-a6d9-1382da9c5838
        slots:
          - entity: entity
            value:
              kind: Unknown
              value: dining room light
            slotName: entity
            rawValue: dining room light
            confidence: 1
            range:
              start: 5
              end: 22
              rawStart: 5
              rawEnd: 22
          - entity: state
            value:
              kind: Unknown
              value: 'on'
            slotName: state
            rawValue: 'on'
            confidence: 1
            range:
              start: 23
              end: 25
              rawStart: 23
              rawEnd: 25

and the light of course is not going on.
The Rhasspy Sentence is

[LightState]
states = (on | off)
turn [the] (dining room light | west wall light){entity} (<states>){state}

The light entities in both cases are defined from switch entities using the “Change device type of a switch” tool.

Any thoughts?
TIA

Thanks for the compliment, appreciate it! :slight_smile:

This will send as entity_id the string dining room light. What you rather need in your entity_id in your automation is light.dinigroom_room_light. You’re missing the domain (=light) and the underscores in the string. :slight_smile:

What you need to do is “translate” the spoken word to the correct entity_id

To solve this, change

[LightState]
states = (on | off)
turn [the] (dining room light | west wall light){entity} (<states>){state}

to

[LightState]
states = (on | off)
turn [the] (dining room light:light.dining_room_light | west wall light:light.west_wall_light){entity} (<states>){state}

PS: It’s very late here, I’m going to bed now, maybe I misspelled something or am totally wrong. :rofl: :rofl: Just as a warning and please bear with me. :rofl: :rofl:

1 Like

Thanks. The now working Sentence is

[LightState]
states = (on | off)
turn [the] (light.dining_room_light | light.west_wall_light){entity} (<states>){state}

and it still correctly responds to “turn dining room light on”.
The final automation is

  alias: Rhasspy Lights
  description: ''
  trigger:
  - platform: event
    event_type: rhasspy_LightState
    event_data: {}
  condition: []
  action:
  - service: light.turn_{{ trigger.event.data.state }}
    data: {}
    target:
      entity_id: '{{ trigger.event.data.entity }}'
  mode: single

Thanks again.

This guide is so detailed, thank you!

Do you know how any of this is affected by/addressed by the new rhasspy integration?

I have done a bit more research and it seems that for the moment the integration just obviates the need to add intent to your config.

You’re right, for now it does “only” the intent setup in configuration.yaml. But I’m sure, there will be more (hint: if the boss does something himself, you know :rofl:).

For this guide this is not relevant, as this goes under “installation”, and further more, this guide uses “events” instead of “intents” to speak to HA. This is simply because I couldn’t get “intents” running in the first place and after a bit of research, I found “events” working great. Btw. I can’t see any advantages for “intents” over “events”. In my setup “events” work great, and what I hear, for people who get “intents” running, it is the same.

I hope you can work with this guide and it will bring you further in your use of Rhasspy. I love it, it’s just a great addition to HA! I could use it much more for sure, but the time… :wink:

Hello,

I would like to use some voice commands for my HA. but I don’t want to hook up microphones in every room. or actually I don’t want them at all.
I can’t find the answer, so I’m asking.
Is it possible to install an app(HA companion or another one) which apply the function of a microphone.

Yes there is, at least for Android devices. It works like a satellite for Rhasspy and works good. I didn’t test it much, as it is not my use case, but what I tested went smooth and without hassle. :slight_smile:

If you test, you might want to report back your experience. :slight_smile:

And here is the link:

EDIT:
As it is not obvious at first, you get the “apk” under releases from the link above. :slight_smile:

Thank you for sharing this information
Is it work with Junior version of Rhasspy?
It’s not taking my ip address for some reason
TY

Unfortunate android won’t run on my iPhone :pensive:. So I hope someone will come with a solution.

You can get a cheap Android tablet and use like a dashboard for HA and install this apk

Unfortunately not, I’m sorry. :slight_smile: I haven’t worked with Rhasspy Junior. I’m running my Rhasspy instance on a seperate machine. But why don’t you try the normal Rhasspy addOn? it should be nearly the same as “Junior”, despite you need to setup your own sentences. And with the AddOn, the Android app is working. :slight_smile:

I will try of course but I need to be in front of my computer and I need to setup SSh and web addon first. Thank you

Need help with Rhasspy configuration:


Can’t retrain , error occur after I follow this guide: Local Voice Control With Home Assistant Just Got Easier! - YouTube
Terminal show’s some errors to :
Thank you

3 Likes

I set up that automation. It does trigger in home assistant, but doesn’t speak anything.
I tried with intents and there it does speak. Anyone has an an idea to make it work?

Solved it. Have configured external mqtt. Then I was getting the
Error rendering data template: UndefinedError: ‘dict object’ has no attribute ‘event’
and
no sensor defined.
Had to change the automation to

id: Rhasspy GetTime
alias: Rhasspy GetTime
trigger:
  - platform: event
    event_data: {}
    event_type: rhasspy_GetTime
action:
  - service: mqtt.publish
    data_template:
      topic: hermes/dialogueManager/endSession
      payload: >-
        {"sessionId": "{{ trigger.event.data._intent.sessionId }}", "text": "{{
        states('sensor.time') }}"}
mode: single

sensor with states(‘sensor.time’) and just payload: >-

I will probably come back here to ask a million questions later, but want to post already that this guide is beyond perfect! I have been struggling with Rhasspy all day and after finally making it work, all my questions about it are here. It is extremely concise and has the perfect examples that the Rhasspy documentation should have. Thank you so much! Keep the amazing work!

I copied the below automation to my automations.yaml

- id: Rhasspy TurnOnLight
  alias: Rhasspy TurnOnLight
  mode: single
  trigger:
    - platform: event
      event_data: {}
      event_type: rhasspy_TurnOnLight
  action:
    - service: light.turn_on
      entity_id: "{{ trigger.event.data.entity }}"
    - service: mqtt.publish
      data:
        topic: hermes/dialogueManager/endSession
        payload_template: '{"sessionId": "{{ trigger.event.data._intent.sessionId }}", "text": "OK, the  {{ trigger.event.data.entity_raw_value }} is on"}'

and get the following error on homeassistant:
“Invalid config for [automation]: not a valid value for dictionary value @ data[‘action’][0][‘entity_id’]. Got None. (See /config/configuration.yaml, line 21).”

how do i go about fixing this error or do i need to specify the entityid on the rhasspy sentence?