SiteId to Home Assistant

Hi,

How to (allways) add the siteId from Rhasspy to Home Assistant ?
Wihtout having to setup mqtt (awainting for 2.5 :slight_smile: )
What I got into HA :

{
    "event_type": "rhasspy_SetLight",
    "data": {
        "piece": "bureau",
        "_text": "allume le bureau",
        "_raw_text": "allume le bureau"
    },
    "origin": "REMOTE",
    "time_fired": "2020-03-23T14:19:34.129864+00:00",
    "context": {
        "id": "a6e08f1de66848d2ac6205d77120f552",
        "parent_id": null,
        "user_id": "d2c36efd2ee24987ac996426821a428b"
    }
}

I would like to add it into Data, obviously …

Thanks for your help
p

It might work if you use intents in Home Assistant. I did not try, but I think the siteId is a property.
The most easy way is setup MQTT :wink:

I’m trying to get something similar working and could do with some help please.

I’ve got a Raspberry Pi 3b+ set up with Rhasspy2.5.0 running in Docker. (standalone at present, working towards making it a satellite but that’s yet to come!) It’s working with Home Assistant in Docker which is doing the intent handling and returning a spoken reply where required, and this is working as expected. I also have Rhasspy already working (standalone) on my NUC in Docker. The two instances of Rhasspy have different siteId’s.
At present I’m using the simple approach of having a different intent name and matching automation in HA for each of the instances. This does work, but involves a fair bit of duplication, and I’d like to do something a bit more elegant.

I’ve tried to pick up the value of siteId and use that in a single HA automation with a template like this snippet…

indent preformatted text by 4 spaces
    action:
  - service: rest_command.rhasspy_speak
    data_template:
      ipnum: >
        {% if trigger.event.rhasspy_GetTime.siteId == "Master" %}
          http://192.168.1.12:12101
        {% elif trigger.event.rhasspy_GetTime.siteId == "RPi" %}
          http://192.168.1.160:12101
        {% endif %}

but although I don’t see errors, no speech comes back when I use this. I could well have the format all wrong - any automation/JSON experts out there?

I know there is an alternative way for HA to handle intents which is the “intent” approach - I haven’t tried this yet but will try to give it a go soon. Does anyone know if it can do what I’m proposing?

Edit: formatted code snippet better (I hope).

If you set up Rhasspy with an external MQTT broker that is also shared with Home Assistant, Rhasspy 2.5-pre sends TTS back to the satellite that initiated the intent. Make sure you have the following in your Home Assistant’s configuration.yaml:

snips:

You can then disable Intent Handling in Rhasspy (the Snips integration will listen on the correct MQTT topics and handle the intents), and then set up intent scripts like this:

intent_script:
  ChangeLightState:
    speech:
      type: plain
      text: 'OK, the light is now {{ state }}.'
    action:
      - service_template: 'light.turn_{{ state }}'
        data_template:
          entity_id: '{{ light }}'
1 Like

Events are slightly different compared to intents. Here’s the same intent above as an event:

automation:
- alias: "Rhasspy light state change"
  trigger:
    platform: event
    event_type: rhasspy_ChangeLightState
  action:
    service_template: 'light.turn_{{ trigger.event.data.state.value }}'
    data_template:
      entity_id: '{{ trigger.event.data.light.value }}'

Thank you very much for the hints. I’ll have another play later today. :smile:

I am already using an external MQTT broker, shared with HA, so that bit is in place and working.
I’ll add the snips: bit in configuration.yaml and carry on from there.