Hermes/hotword/<id>/detected sensor undefined


I have a small problem. I have defined in config.yaml several mqtt sensors that catch the different statuses from wakeword to session end. So I’m trying to find the best trigger for me to optimize my voice control and related automations.

Now when I read the wakeword detection in the sensor, it is always undefined even though the topic gets content. Likewise, the sensor for the Intents is undefined.

What have I overlooked or not considered?

Here is my .yaml:

    - name: "RhasspyWakeUp"
      state_topic: "hermes/hotword/porcupine_raspberry-pi/detected"
    - name: "RhasspyStartListening"
      state_topic: "hermes/dialogueManager/sessionStarted"
    - name: "RhasspyStopListening"
      state_topic: "hermes/dialogueManager/sessionEnded"
    - name: "RhasspyIntentFinished"
      state_topic: "hermes/intent/#"
    - name: "RhasspyFailedListening"
      state_topic: "hermes/nlu/intentNotRecognized"

And here is the message:
Message 5 received on hermes/hotword/porcupine_raspberry-pi/detected at 6:55:

    "modelVersion": "",
    "modelType": "personal",
    "currentSensitivity": 0.7,
    "siteId": "livingroom.wzsite1",
    "sessionId": null,
    "sendAudioCaptured": null, 
    "lang": null,
    "customEntities": null

Best regards

That is because the json cannot be used as a state for a MQTT sensor in Home Assistant.

You must define the payload_available and payload_not_available

Hi @romkabouter , thank you for your response.

This is really interesting, because all other sensors are storing json data from their topics.

Sensor RhasspyStartListening on topic hermes/dialogueManager/sessionStarted:

O, that is strange indeed then.
The only other thing I can think of is the topic. The wakeword has an underscore and a hypen in it.
I do not know if that causes issues, but it is a difference.

Yes, it is^^

Basically, I only need the site ID, since this is passed as a parameter in automations and scripts, and partly by concatination it performs an action corresponding to the room as a service.

Do you have an idea how I can assign a concrete attribute from the payload to a sensor?

Well, the software I created uses this topic:

hermes/hotword/toggleOff as can be found here

It gives the siteId an a reason, when the reason is “dialogueSession” it indicated a hotword detection.

Some valuable info might be found here:

Check the onMqttMessage method

1 Like

Thank you @romkabouter , i will take a look at this

I found a other simple solution, maybe someone else can need it:

in config.yaml:

        - name: "RhasspyWakewordDetected"
          state_topic: "hermes/hotword/porcupine_raspberry-pi/detected"
          value_template: "{{ value_json.siteId }}{{ now() | as_timestamp | string }}" #ensure the stored data is unique to use the on_change trigger

in my automations and scripts i am using the value_template:

value_template: "{{ states('sensor.rhasspywakeworddetected').split('.')[0] }}"

Maybe there are better solutions, but for me it works like it should and mute my device instantly when wakeword is detected.