Home assistant core + Rasspy configuration

id: '1622913354480'
alias: SpotifyPlay
description: ''
trigger:
  - platform: event
    event_type: rhasspy_SpotifyPlay
condition: []
action:
  - service: media_player.media_play
    target:
      area_id: living_room
      device_id: 5aaf4542ff34d8d28c52f5d1c985adaa
      entity_id: media_player.spotify_rockman_sg
  - service: mqtt.publish
    data:
      topic: hermes/dialogueManager/endSession
      payload_template: >-
        {"sessionId": "{{trigger.event.data._intent.sessionId}}", "text": "Ok,
        I  will pause the song"}
mode: single

Hi Romkabouter,
Is this the correct setup in automation?

Looks ok to me, did you try it?

For your understanding, you can add as much services as you need in the actions.
But for correctly end the session from Rhasspy with an answer to the correct satellite (or server if no sats), a message must be published to the Rhasspy server with the sessionID

I assume you have Rhasspy mqtt set to the same broker as Home Assistant (so external and not internal)
If not, do so, otherwise it still will not work

Yes, I tried and still not getting any response as Rhasspy MQTT is internal. So I have change it to External now. Encounter below error:
MQTT_External_error

Here is my MQTT External setting that encounter the above error.
MQTT_Setting

You must the the host as IP address and port 1883

After changing to port 1883 at rhasspy external MQTT, still encounter same "RuntimeError: Failed to connect to MQTT broker. Not sure what else is the issue here?

Do you have set the right ip adress and are you running the MQTT addon in Home Assistant?
The ipadress must be the ipadress of your HA instance, running the MQTT addon (since you are running Home Assistant OS)

You need a MQTT connection between Home Assistant and Rhasspy. The both need to be connected to the same broker.

You are right. I saw on HA server log that Mosquitto Core failed to login to HA. And also Rhasspy is looping in HA thus unable to launch Rhasspy Web UI now.

Let me look into these 2 issue before I can resume. Will try and give you a update again in 30 mins time.

Add this in the addon configuration:
image

Create a folder in “mosquitto” in share (accessable via samba, so install that addon as well)

Add a file acl.conf with this contents:

acl_file /share/mosquitto/accesscontrollist

Add a file accesscontrollist with this contents:

user homeassistant
topic readwrite #

user addons
topic readwrite #

user paul
topic readwrite #

replace paul with the user you want rhasspy to be able to login.
I think it also needs to be a user in HA, so you can use your own user as well

You can also read this on the Documentation tab form the addon :slight_smile:

Use the same user and password in Rhasspy and it should work

Both Rhasspy Add-On as per my below setup has crashed for the same reason as soon as I enable MQTT External. It goes on infinite loop and taking up 95% cpu power.

  1. HA docker with Rhasspy Add-On
  2. HA OS with Rhasspy Add-On

Prior to this, all were running well except last leg of TTS from HA to Rhasspy.

Too tired to proceed further. May need to do the whole setup from scratch all over again once I rest enough. Good night and thanks for your help.

Do you have two setups?

Hi Romkabouter,
Yes I started with HA Docker and realised that HA doesn’t come default Supervisor. Thus I managed to install from GitHub the Supervisor in order to get Rhasspy as an Add-On. This build only have default HTTP.

However, I have HA warning on the Supervisor tab now that either my Raspbain version or Supervisor is unsupported.

Thus as a back-up worrying my above build will be end of life, I have flash another SD card of HA OS with Rhasspy as Add-On with SSL and HTTPS turned-on.

And I manage to replicate all the functions of Rhasspy Wake word > Intent Recognition > STT > Intent Handling as Event > HA Automation and was working fine. Only missing part is HA TTS > Rhasspy Audio Out which I couldn’t get it working.

And now I read a post what back Nov '20 by maleko on how to undo the external MQTT. So I manage to revert back Rhasspy internal MQTT on my 2 builds. So now I am back where I am post changing to external MQTT.

And after some check on my HA automation codes, spotted a minor syntax on “payload_template” which I have corrected.

Thereafter, I have done more Rhasspy > HA testing and spotted this error in row #3 on HA Rhasspy log as per below. It seems like the session has pre-mature termination before HA can perform MQTT Publish. Correct me if I am wrong?

[DEBUG:2021-06-12 18:18:40,402] rhasspyasr_kaldi_hermes: Receiving audio
[DEBUG:2021-06-12 18:18:40,402] rhasspywake_porcupine_hermes: Receiving audio
[ERROR:2021-06-12 18:19:08,160] rhasspydialogue_hermes: Session timed out for site default: default-porcupine_raspberry-pi-7ae06341-6b9a-43cb-acdd-30d7aa939263
[DEBUG:2021-06-12 18:19:08,162] rhasspydialogue_hermes: -> AsrStopListening(site_id='default', session_id='default-porcupine_raspberry-pi-7ae06341-6b9a-43cb-acdd-30d7aa939263')
[DEBUG:2021-06-12 18:19:08,162] rhasspydialogue_hermes: Publishing 105 bytes(s) to hermes/asr/stopListening
[DEBUG:2021-06-12 18:19:08,168] rhasspydialogue_hermes: -> DialogueSessionEnded(termination=DialogueSessionTermination(reason=<DialogueSessionTerminationReason.TIMEOUT: 'timeout'>), session_id='default-porcupine_raspberry-pi-7ae06341-6b9a-43cb-acdd-30d7aa939263', site_id='default', custom_data='porcupine_raspberry-pi')
[DEBUG:2021-06-12 18:19:08,168] rhasspydialogue_hermes: Publishing 183 bytes(s) to hermes/dialogueManager/sessionEnded
[DEBUG:2021-06-12 18:19:08,171] rhasspydialogue_hermes: -> HotwordToggleOn(site_id='default', reason=<HotwordToggleReason.DIALOGUE_SESSION: 'dialogueSession'>)
[DEBUG:2021-06-12 18:19:08,172] rhasspydialogue_hermes: Publishing 50 bytes(s) to hermes/hotword/toggleOn
[DEBUG:2021-06-12 18:19:08,220] rhasspyasr_kaldi_hermes: <- AsrStopListening(site_id='default', session_id='default-porcupine_raspberry-pi-7ae06341-6b9a-43cb-acdd-30d7aa939263')
[DEBUG:2021-06-12 18:19:08,220] rhasspywake_porcupine_hermes: <- HotwordToggleOn(site_id='default', reason=<HotwordToggleReason.DIALOGUE_SESSION: 'dialogueSession'>)
[DEBUG:2021-06-12 18:19:08,220] rhasspywake_porcupine_hermes: Enabled
[DEBUG:2021-06-12 18:19:08,220] rhasspyasr_kaldi_hermes: Stopping listening (session_id=default-porcupine_raspberry-pi-7ae06341-6b9a-43cb-acdd-30d7aa939263)
[DEBUG:2021-06-12 18:19:08,236] rhasspywake_porcupine_hermes: Receiving audio

If you have set Rhasspy to internal again, there will be no messages coming in from Home Assistant to Rhasspy after the intent is recognized and after a while a timeout occurs.

They need to be on the same broker, that is why you need Rhasspy to connect to an external broker.
Have you tried installing the MQTT addon yet?

Got it. Working on installing and configure Mosquitto MQTT again. Will keep you post. Thanks.

After turning back on external MQTT, again Rhasspy is looping again and crash. Unable to restart until I reset back to internal MQTT. Very strange to have such behaviour.

What are your settings?
Can you connect ok with another cliënt?

Here is my Rhasspy external MQTT setting.

And each time I get the below socket error in Rhasspy log after 10 tries to connect and then final message of “Failed to connect MQTT broker”.

socket.gaierror: [Errno -2] Name or service not known
[DEBUG:2021-06-12 23:41:53,306] rhasspyserver_hermes: Connecting to http://“HA ip address”:1883 (retries: 2/10)
[ERROR:2021-06-12 23:41:52,303] rhasspyserver_hermes: mqtt connect
Traceback (most recent call last):
  File "/usr/lib/rhasspy/rhasspy-server-hermes/rhasspyserver_hermes/__init__.py", line 289, in start
    self.client.connect(self.host, self.port)
  File "/usr/lib/rhasspy/.venv/lib/python3.7/site-packages/paho/mqtt/client.py", line 937, in connect
    return self.reconnect()
  File "/usr/lib/rhasspy/.venv/lib/python3.7/site-packages/paho/mqtt/client.py", line 1071, in reconnect
    sock = self._create_socket_connection()
  File "/usr/lib/rhasspy/.venv/lib/python3.7/site-packages/paho/mqtt/client.py", line 3522, in _create_socket_connection
    return socket.create_connection(addr, source_address=source, timeout=self._keepalive)
  File "/usr/lib/python3.7/socket.py", line 707, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/lib/python3.7/socket.py", line 748, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
[DEBUG:2021-06-12 23:41:52,301] rhasspyserver_hermes: Connecting to http://“HA ip address”:1883 (retries: 1/10)
[ERROR:2021-06-12 23:41:51,298] rhasspyserver_hermes: mqtt connect
Traceback (most recent call last):
  File "/usr/lib/rhasspy/rhasspy-server-hermes/rhasspyserver_hermes/__init__.py", line 289, in start
    self.client.connect(self.host, self.port)
  File "/usr/lib/rhasspy/.venv/lib/python3.7/site-packages/paho/mqtt/client.py", line 937, in connect
    return self.reconnect()
  File "/usr/lib/rhasspy/.venv/lib/python3.7/site-packages/paho/mqtt/client.py", line 1071, in reconnect
    sock = self._create_socket_connection()
  File "/usr/lib/rhasspy/.venv/lib/python3.7/site-packages/paho/mqtt/client.py", line 3522, in _create_socket_connection
    return socket.create_connection(addr, source_address=source, timeout=self._keepalive)
  File "/usr/lib/python3.7/socket.py", line 707, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/lib/python3.7/socket.py", line 748, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
[DEBUG:2021-06-12 23:41:51,295] rhasspyserver_hermes: Connecting to http://“HA ip address”:1883 (retries: 0/10)
[DEBUG:2021-06-12 23:41:51,295] rhasspyserver_hermes: Starting core