Any list of pre-made commands/automations?

Looking for a list of sentences I could put into sentences.ini and corresponding automations I could add to home assistant for basic functionality like getting the date/time, setting a timer, etc. Before I go and recreate the wheel just thought I’d see if anyone had something I could copy/paste.

Hi uglyfish,

Here’s an automation that will work with the built in GetTime sentence:

- id: '1690135052755'
  alias: Rhasspy-GetTime
  description: ''
  - platform: mqtt
    topic: hermes/intent/GetTime
  condition: []
  - service: mqtt.publish
      qos: 0
      retain: false
      topic: hermes/dialogueManager/endSession
      payload_template: '{"sessionId": "{{ trigger.payload_json.sessionId }}", "text":
        "It is ({{states("sensor.simple_time")}})"}'
  mode: single

You’ll need to create this sensor:

  - platform: template
        friendly_name: "Simple Time"
        value_template: >
         {% set t = states('sensor.time') %}
         {{ as_timestamp(now()) | timestamp_custom('%I:%M %p') }}

Hope this helps!

EDIT: Can ignore below, it’s working! Apparently I need to actually speak the response to get a spoken response back. I can’t just put it in the home page of the web UI with intent handling checked,

Thanks for the response! This seems to be mostly working, except for the final step of actually speaking it out loud.

Looking at the step details in the home assistnat log I get:

Executed: August 13, 2023 at 10:50:24 AM

domain: mqtt
service: publish
qos: 0
retain: false
topic: hermes/dialogueManager/endSession
sessionId: 45646a7e-8b5f-4c0a-8cdb-1852036e605b
text: It is (10:50 AM)
target: {}
running_script: false

But nothing plays on my speaker. If I manually put the It is (10:50 AM) text into the text to speech box in the rhasspy webUI it speaks it fine, but it doesn’t seem to want to pick it up from the MQTT topic. Any idea?

this is what the rhasspy log shows. As can be seen, it’s not picking up the response.

[DEBUG:2023-08-13 10:56:13,078] rhasspyserver_hermes: Sent 367 char(s) to websocket
[DEBUG:2023-08-13 10:56:13,077] rhasspyserver_hermes: Handling NluIntent (topic=hermes/intent/GetTime, id=97bbe2bb-6e62-4728-8dfc-1812b9e64a55)
[DEBUG:2023-08-13 10:56:13,077] rhasspyserver_hermes: ← NluIntent(input=‘what time is it’, intent=Intent(intent_name=‘GetTime’, confidence_score=1.0), site_id=‘Main’, id=‘d1607ecc-846c-464a-9597-188352d3c82f’, slots=[], session_id=‘d1607ecc-846c-464a-9597-188352d3c82f’, custom_data=None, asr_tokens=[[AsrToken(value=‘what’, confidence=1.0, range_start=0, range_end=4, time=None), AsrToken(value=‘time’, confidence=1.0, range_start=5, range_end=9, time=None), AsrToken(value=‘is’, confidence=1.0, range_start=10, range_end=12, time=None), AsrToken(value=‘it’, confidence=1.0, range_start=13, range_end=15, time=None)]], asr_confidence=None, raw_input=‘what time is it’, wakeword_id=None, lang=None)
[DEBUG:2023-08-13 10:56:13,031] rhasspyserver_hermes: Publishing 268 bytes(s) to hermes/nlu/query
[DEBUG:2023-08-13 10:56:13,030] rhasspyserver_hermes: → NluQuery(input=‘what time is it’, site_id=‘Main’, id=‘d1607ecc-846c-464a-9597-188352d3c82f’, intent_filter=None, session_id=‘d1607ecc-846c-464a-9597-188352d3c82f’, wakeword_id=None, lang=None, custom_data=None, asr_confidence=None, custom_entities=None)

Here is a wiki, which might be some help

1 Like

Wonderful. The reason it doesn’t work from the Home Page is because of the payload template. From the Rhasspy Home Page, speak the sentence, and then look at the JSON. Then, type the sentence, and then look at the JSON. You’ll see there is a difference in the two, at the end. When you speak the sentence, additional JSON is sent to HA. The automation I provided uses some of that JSON, (e.g. sessionId) which is parsed from the JSON being sent when publishing back to Rhasspy on the MQTT topic: hermes/dialogueManager/endSession. Well, if Rhasspy isn’t sending the sessionId (because there isn’t a “session” when you’re typing in the sentence on the Home Page) in the JSON, there isn’t a way to parse it out via the payload_template, and, well, you saw (or to phrase it better didn’t hear :slight_smile: ) the result.
Finally, the link romkabouter provided (and romkabouter is fantastic with his help, and extremely knowledgeable regarding Rhasspy) is a great resource. There’s a lot to wrap your head around in Rhasspy/HA, best way I found was to start with simple interactions/automations, and build from them.
Good luck, and if you get stuck, this forum is a very helpful place.

1 Like

Thanks JeffC! I’m having a lot of fun diving into this, and that moment in troubleshooting when something doesn’t just work but the why of it actually makes sense. Your explanation of SessionID makes sense, and was something I vaguely understood, but didn’t think to actually examine the JSON to see if it was missing.

So far I’ve gotten the following automations to work:

  1. Specific lights on and off
  2. Areas on or off (first one I made ‘from scratch’). Still need to figure a way to fine tune this to turn only lights on and off (and not e.g. a google home mini).
  3. Tell me the time (thanks for that one, getting that up and running was a great simple starting point for learning).
  4. Tell me the weather forecast from NWS.

Next (and honestly probably final) things I’m gonna try to get running:

  1. Play music from youtube music via Music Assistant.
  2. Create and view/read timers.
  3. A couple satellites. Thinking a basic one with a rhaspberry pi zero 3 and another jabra (when funds allow).
  4. Another satellite with a pi 3B+, another jabra, and maybe a touch screen display I have on hand. Figure getting that to display some useful stuff and serve as an input is an extra level of hassle, so that satellite comes second.

If prior experience is any indicator, none of these will come easily, but will be very satisfying.

For playing music from music assistant, one initial piece of the puzzle I’m struggling with is how to pass “wildcard” text with rhasspy. Like I know how to draft a sentence with a list of expected words, but I’m having trouble determining how/if it’s even possible for it to just pass along “whatever is between these two words” rather than something pre-defined.

Hmm… Not sure how you’re wanting to use “wild card text”. You can use “slots” to build a corpus of potential words (maybe related to music artist, genre, etc.) if there is a relatively finite number of “wild card words”.
There’s also “Open Transcription Mode” which does generalized speech to text:
I haven’t done anything with this functionality, so wouldn’t be a lot of help.
For the timer, take a look at this thread, and see the post by daleh:

Using slots probably isn’t going to work - there’s just too many artists, song names, etc for me to realistically build one that isn’t just a full dictionary. Looks like “open transcription” is a better word than “wildcard” for what I’m looking for. From a glance it looks like if I turn on open transcription then I lose custom commands, so that’s not really useful. What I need is some way to trigger open transcription only when needed. Such as when “play the song” is picked up, then it starts open transcribing until silence occurs, and passes that open transcription along as part of the data payload. I’ll have to dig some, but it doesn’t look like there’s built in functionality for that at this point, and implementing it is WAY beyond by knowledge or capacity. I’ll most likely just forgo initiating music playback via rhasspy, and instead queue it up on a phone, and then use rhasspy for play/pause. If it’s pointed at a decent playlist that’s actually not a terrible use case anyway, since that’s mostly a “keep me distracted while doing dishes” type thing, not serious music listening anyway.

Thanks for the link on the timer. That should definitely help me get going.