External MQTT not working

I had a working Base & Satellite setup … and then I tried adding HermesLedControl and a second satellite … and it turned to custard. I am now reinstalling the first satellite from scratch and taking it very step-by-step, with…

  • Raspberry Pi 3B with reSpeaker 4-mic HAT with HinTak drivers. Tested the mic and headphone with arecord | aplay OK
  • Satellite is running Raspberry Pi OS Lite and Rhasspy (without Docker or venv) using a SSL terminal session to run “rhasspy -profile en” from command line.
  • My Base station is a RasPi 4 running HA OS with Rhasspy and a few other add-ons.

I got back to a working system using Internal MQTT, and Remote HTTP for STT, Intent and TTS processing. A beep when I say “Porcupine”, the text of the command and the intent being displayed on both the satellite and base systems. :grinning: :joy: :smiling_face_with_three_hearts:

However my end goal is multiple satellites, and to use the LEDs on the mic boards, so I change to a shared External MQTT … such as the HA add-on.

  • HA’s MQTT add-on to default settings (port 1833)
  • Rhasspy on both Base and Satellite set to External MQTT, IP address of the Base station, and port 1883

Restart Rhasspy. Lets go a step further … power cycle both machines and check they come up without errors. Base station’s HA Mosquitto broker log shows it initialising and

1632260881: New client connected from 172.30.32.1 as 1tZPLffFtAR8Ps5ukaoMgx (p2, c1, k60, u'homeassistant').
1632260923: New connection from 172.30.32.1 on port 1883.

I have also installed mosquitto on my desktop PC, but when I try to connect I get …

don@Muscle:~$ mosquitto_sub -h 192.168.1.98 -p 1883 -d -t rhasspy/audioServer/# -t hermes/audioServer/#
Client (null) sending CONNECT
Client (null) received CONNACK (0)
Client (null) sending SUBSCRIBE (Mid: 1, Topic: rhasspy/audioServer/#, QoS: 0, Options: 0x00)
Client (null) sending SUBSCRIBE (Mid: 1, Topic: hermes/audioServer/#, QoS: 0, Options: 0x00)
Client (null) received SUBACK
Subscribed (mid: 1): 128, 128
Client (null) sending DISCONNECT
All subscription requests were denied.
don@Muscle:~$

I don’t understand why, since this same command worked correctly with the satellite’s IP and port.

On the Base system, the HA Rhasspy add-on’s log shows no errors and the usual flood of [DEBUG] messages, including the services succeeding to connect to MQTT broker, eg

[DEBUG:2021-09-22 07:48:43,683] asyncio: Using selector: EpollSelector
[DEBUG:2021-09-22 07:48:43,686] rhasspyasr_kaldi_hermes: Connecting to 192.168.1.98:1883
[DEBUG:2021-09-22 07:48:43,699] asyncio: Using selector: EpollSelector
[DEBUG:2021-09-22 07:48:43,701] rhasspyasr_kaldi_hermes: Connected to MQTT broker
[DEBUG:2021-09-22 07:48:43,703] rhasspyasr_kaldi_hermes: Subscribed to hermes/asr/toggleOff

So far, all good at the base station.

Now to the satellite and start Rhasspy from command line. All services seem to have started and connected to MQTT without any errors, also indicated by the “New connection from 192.168.1.95 on port 1883.” messages in the Base station’s MQTT log.

At speaking the wake word “porcupine”, the satellite’s console adds

[DEBUG:2021-09-22 08:20:51,293] rhasspywake_porcupine_hermes: -> HotwordDetected(model_id='/usr/lib/rhasspy/usr/local/lib/python3.7/site-packages/pvporcupine/resources/keyword_files/raspberry-pi/porcupine_raspberry-pi.ppn', model_version='', model_type='personal', current_sensitivity=0.5, site_id='sat-1', session_id=None, send_audio_captured=None, lang=None, custom_entities=None)
[DEBUG:2021-09-22 08:20:51,297] rhasspywake_porcupine_hermes: Publishing 320 bytes(s) to hermes/hotword/porcupine_raspberry-pi/detected

However that is the end of it. Nothing more is logged to the console while speaking a command, or waiting >2 minutes for a timeout.

Clicking any button on the satellite’s web interface continues the console log.
[Play Recording] pops up and clears its message.
Download WAV would send a 44 byte file.
Clicking the web interface’s [Log] button pops up a window which has no contents.

Satellite’s profile now is:

{
    "dialogue": {
        "satellite_site_ids": "sat-1",
        "system": "rhasspy",
        "volume": "0.75"
    },
    "intent": {
        "remote": {
            "url": "http://192.168.1.98:12101/api/text-to-intent"
        },
        "satellite_site_ids": "sat-1",
        "system": "remote"
    },
    "microphone": {
        "arecord": {
            "device": "plughw:CARD=seeed4micvoicec,DEV=0",
            "siteId": "sat-1",
            "udp_audio_port": "12203"
        },
        "system": "arecord"
    },
    "mqtt": {
        "enabled": "true",
        "host": "192.168.1.98",
        "site_id": "sat-1"
    },
    "sounds": {
        "aplay": {
            "device": "plughw:CARD=Headphones,DEV=0",
            "volume": "0.7"
        },
        "system": "aplay"
    },
    "speech_to_text": {
        "remote": {
            "url": "http://192.168.1.98:12101/api/speech-to-text"
        },
        "satellite_site_ids": "sat-1",
        "system": "remote"
    },
    "text_to_speech": {
        "remote": {
            "url": "http://192.168.1.98:12101/api/text-to-speech"
        },
        "satellite_site_ids": "sat-1",
        "system": "remote"
    },
    "wake": {
        "porcupine": {
            "udp_audio": "12203"
        },
        "satellite_site_ids": "sat-1",
        "system": "porcupine"
    }
}

The only difference I noticed (apart from the order of components being rearranged) is that the MQTT section on both Base and satellite now have MQTT enabled set to true, and the base stations IP address as host.

Clicking [Wake Up] button gives no beep, a “Listening for command” pop-up which times out, and in the console

DEBUG:2021-09-22 08:40:57,191] rhasspyserver_hermes: -> HotwordDetected(model_id='default', model_version='', model_type='personal', current_sensitivity=1.0, site_id='sat-1', session_id=None, send_audio_captured=None, lang=None, custom_entities=None)
[DEBUG:2021-09-22 08:40:57,192] rhasspyserver_hermes: Publishing 197 bytes(s) to hermes/hotword/default/detected
[DEBUG:2021-09-22 08:40:57,194] rhasspyserver_hermes: Waiting for intent (session_id=None)
[DEBUG:2021-09-22 08:40:57,196] rhasspyserver_hermes: Subscribed to hermes/error/nlu
[ERROR:2021-09-22 08:41:27,227] rhasspyserver_hermes: 
Traceback (most recent call last):
  File "/usr/lib/rhasspy/usr/local/lib/python3.7/site-packages/quart/app.py", line 1821, in full_dispatch_request
    result = await self.dispatch_request(request_context)
  File "/usr/lib/rhasspy/usr/local/lib/python3.7/site-packages/quart/app.py", line 1869, in dispatch_request
    return await handler(**request_.view_args)
  File "/usr/lib/rhasspy/rhasspy-server-hermes/rhasspyserver_hermes/__main__.py", line 943, in api_listen_for_command
    async for response in core.publish_wait(handle_intent(), [], message_types):
  File "/usr/lib/rhasspy/rhasspy-server-hermes/rhasspyserver_hermes/__init__.py", line 995, in publish_wait
    result_awaitable, timeout=timeout_seconds
  File "/usr/lib/rhasspy/usr/local/lib/python3.7/asyncio/tasks.py", line 449, in wait_for
    raise futures.TimeoutError()
concurrent.futures._base.TimeoutError

So I must be missing something.

  • Configuration works with Internal MQTT. Only change is to External MQTT

  • Minimal configuration and both systems rebooted to reduce chance of other things having side-effects

  • The HA MQTT add-on’s log is showing connections from 172.30.32.1 on port 1883 (from Rhasspy in the other Docker container also on the base station), 192.168.1.95 on port 1883 (the satellite), and 192.168.1.99 on port 1883 (my desktop - but disconnecting immediately) - so the IP address and port are correct.

I really would appreciate your help on this. Thanks

Can you also post you base profile?

If the base has a different siteid then the satelites, you need all the sat id’s filled in the “Satellites Id’s” fields across the base settings.

The wake word work, because that is local on the satellite.

HA MQTT add-on on base station is just default configuration (no site_id) :

Base station’s Rhasspy profile is

{
    "intent": {
        "satellite_site_ids": "sat-1,sat-2",
        "system": "fsticuffs"
    },
    "mqtt": {
        "enabled": "",
        "host": "192.168.1.98",
        "site_id": "base"
    },
    "speech_to_text": {
        "satellite_site_ids": "sat-1,sat-2",
        "system": "kaldi"
    },
    "text_to_speech": {
        "satellite_site_ids": "sat-1,sat-2",
        "system": "larynx"
    }
}

192.168.1.98 is the IP address of the Base station machine.

There is no site_id in rhasspy’s MQTT section, so it must be picking it up from the Site_id above. Surely the MQTT site_id must be different for each machine ?

You are correct that the satellite is recognising the wakeword and displaying 2 DEBUG messages on the console. Nothing else shows on the console (not even a timeout error) until I speak the wakeword again or click something on the web GUI. This seems unusual, because with Internal MQTT there are a heap more messages displayed. Could the log be redirected ?

I think the problem must be related to the MQTT connection since (a) it doesn’t seem to be recording any audio, and (b) the STT, Intents and TTS are all still using Remote HTTP.

Thank for your assistance

Indeed, the site_id is picked from the setting siteId above the various settings.
But you sat’s should be comma separated in ALL settings, you have them only on intent, speech_to_text and text_to_speech so on some you do not have them listed (Dialogue Managment for example)

I can imagine, but when you set is so internal you basically have set base and sat the same.,
Therefore Satellite Id’s are not needed in that case.

Are you suggesting that the base and satellites should have the same siteID ? As you mentioned, Site_Id is probably not needed for Internal MQTT since only the localhost will be using it … but surely when using an External MQTT they all need to be different and unique so that the client and server can keep track of where messages came from and replies go back to.

Yes, because the Base is only providing STT, intent and TTS services to the clients.
Looking back at the documentation I see the examples show Dialog Manager enabled on the Base instead of the Satellite - my bad !
I am left wondering which Rhasspy is actually doing what – but that isn’t the issue at the moment.

Unfortunately enabling Dialog Manager on the Base and disabling on the satellite (as per the base-satellite example in the docs) made no difference whatsoever.

No, but if you have 1 base and 1 satellite it is possible to use the same id.

Did you also fill in the satliite id’s on the base?

Base station’s Rhasspy profile currently is:

{
    "dialogue": {
        "satellite_site_ids": "sat-1, sat-2",
        "system": "rhasspy"
    },
    "intent": {
        "satellite_site_ids": "sat-1, sat-2",
        "system": "fsticuffs"
    },
    "mqtt": {
        "enabled": "true",
        "host": "192.168.1.98",
        "site_id": "base"
    },
    "speech_to_text": {
        "satellite_site_ids": "sat-1, sat-2",
        "system": "kaldi"
    },
    "text_to_speech": {
        "satellite_site_ids": "sat-1, sat-2",
        "system": "larynx"
    }
}

meanwhile, in the HA MQTT add-on’s log (on the base 192.168.1.98):

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] mosquitto.sh: executing... 
[20:33:32] INFO: SSL is not enabled
[cont-init.d] mosquitto.sh: exited 0.
[cont-init.d] nginx.sh: executing... 
[cont-init.d] nginx.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[20:33:32] INFO: Starting NGINX for authentication handling...
[20:33:33] INFO: Starting mosquitto MQTT broker...
1632479613: mosquitto version 1.6.12 starting
1632479613: |-- *** auth-plug: startup
[20:33:34] INFO: Successfully send discovery information to Home Assistant.
[20:33:34] INFO: Successfully send service information to the Supervisor.
1632479613: Config loaded from /etc/mosquitto/mosquitto.conf.
1632479613: Loading plugin: /usr/share/mosquitto/auth-plug.so
1632479613:  ├── Username/password checking enabled.
1632479613:  ├── TLS-PSK checking enabled.
1632479613:  └── Extended authentication not enabled.
1632479613: Opening ipv4 listen socket on port 1883.
1632479613: Opening ipv6 listen socket on port 1883.
1632479613: Opening websockets listen socket on port 1884.
1632479613: Warning: Mosquitto should not be run as root/administrator.
1632479613: mosquitto version 1.6.12 running
1632479613: New connection from 127.0.0.1 on port 1883.
1632479613: Socket error on client <unknown>, disconnecting.
1632479614: New connection from 192.168.1.95 on port 1883.
1632479614: New client connected from 192.168.1.95 as auto-4FBAE637-E71D-3316-C3B1-283ECC4E3031 (p2, c1, k60).
1632479617: New connection from 192.168.1.95 on port 1883.
1632479617: New client connected from 192.168.1.95 as auto-51636333-B20A-C6FC-0BA5-7821A3C232A0 (p2, c1, k60).
1632479619: New connection from 192.168.1.95 on port 1883.
1632479619: New client connected from 192.168.1.95 as auto-17845AE3-A664-7A1A-068B-4962A4447B5F (p2, c1, k60).
1632479619: New connection from 192.168.1.95 on port 1883.
1632479619: New client connected from 192.168.1.95 as auto-6D07594F-3171-45BF-5E6F-9F0813DCA5B8 (p2, c1, k60).
1632479634: New connection from 192.168.1.93 on port 1883.
1632479634: New connection from 192.168.1.93 on port 1883.
1632479634: New connection from 192.168.1.93 on port 1883.
1632479634: New client connected from 192.168.1.93 as auto-C730F601-F365-AF1D-2686-22DAAC81CBA1 (p2, c1, k60).
1632479634: New connection from 192.168.1.93 on port 1883.
1632479634: New connection from 192.168.1.93 on port 1883.
1632479634: New client connected from 192.168.1.93 as auto-8E20B1DD-1CCE-31D2-F388-6C49F8A50A3A (p2, c1, k60).
1632479634: New client connected from 192.168.1.93 as auto-52213D19-003D-FDF8-0CBE-D61DCBAE7015 (p2, c1, k60).
1632479634: New client connected from 192.168.1.93 as auto-1328B211-38D0-19B2-07B6-45DA67F8248B (p2, c1, k60).
1632479634: New client connected from 192.168.1.93 as auto-72C91D5A-0609-8CBA-3974-9135BB573CD2 (p2, c1, k60).
1632479638: New connection from 172.30.32.1 on port 1883.
401: Unauthorized1632479638: Socket error on client <unknown>, disconnecting.
1632479639: New connection from 172.30.32.1 on port 1883.
1632479639: Socket error on client <unknown>, disconnecting.
1632479641: New connection from 172.30.32.1 on port 1883.
1632479641: Socket error on client <unknown>, disconnecting.
1632479645: New connection from 172.30.32.1 on port 1883.
1632479645: Socket error on client <unknown>, disconnecting.
1632479653: New connection from 172.30.32.1 on port 1883.
1632479653: Socket error on client <unknown>, disconnecting.
1632479669: New connection from 172.30.32.1 on port 1883.
1632479669: Socket error on client <unknown>, disconnecting.
1632479701: New connection from 172.30.32.1 on port 1883.
1632479701: Socket error on client <unknown>, disconnecting.
1632479711: New connection from 172.30.32.1 on port 1883.
1632479711: New client connected from 172.30.32.1 as auto-A75485CC-17C0-1473-35FD-B40436240343 (p2, c1, k60).
1632479713: New connection from 172.30.32.1 on port 1883.
1632479713: New client connected from 172.30.32.1 as auto-664E9726-608F-E555-2F75-EB2CBAD4CE98 (p2, c1, k60).
1632479713: New connection from 172.30.32.1 on port 1883.
1632479713: New client connected from 172.30.32.1 as auto-389261ED-F7D1-4DDE-5E7A-A8A8E213DFC9 (p2, c1, k60).
1632479714: New connection from 172.30.32.1 on port 1883.
1632479714: New client connected from 172.30.32.1 as auto-0CF9AC7B-1BB5-3376-E6AA-BB56695204F3 (p2, c1, k60).
1632479714: New connection from 172.30.32.1 on port 1883.
1632479714: New client connected from 172.30.32.1 as auto-977F51F0-AFE8-5559-2DBB-A8B2CEF11EE1 (p2, c1, k60).
1632479765: New connection from 172.30.32.1 on port 1883.
1632479765: Socket error on client <unknown>, disconnecting.
1632479839: New connection from 192.168.1.99 on port 1883.
1632479839: New client connected from 192.168.1.99 as auto-FF8142F4-9CFB-9DD5-6D8A-2C0CDE0C4D2F (p2, c1, k60).
1632479839: Client auto-FF8142F4-9CFB-9DD5-6D8A-2C0CDE0C4D2F disconnected.
1632479883: New connection from 192.168.1.99 on port 1883.
1632479883: New client connected from 192.168.1.99 as auto-0024FBE8-7995-E7BC-35B2-9BC4F7442A1C (p2, c1, k60).
1632479885: New connection from 172.30.32.1 on port 1883.
1632479885: Socket error on client <unknown>, disconnecting.
1632479914: Socket error on client auto-17845AE3-A664-7A1A-068B-4962A4447B5F, disconnecting.
1632479914: Socket error on client auto-51636333-B20A-C6FC-0BA5-7821A3C232A0, disconnecting.
1632479914: Socket error on client auto-6D07594F-3171-45BF-5E6F-9F0813DCA5B8, disconnecting.
1632479915: Socket error on client auto-4FBAE637-E71D-3316-C3B1-283ECC4E3031, disconnecting.
1632479915: New connection from 192.168.1.95 on port 1883.
1632479915: New client connected from 192.168.1.95 as auto-13D34F18-D6A7-90A0-5D74-E669C0460434 (p2, c1, k60).
1632479920: New connection from 192.168.1.95 on port 1883.

192.168.1.98 is the Base station (on which the MQTT broker is running)
172.30.32.1 is the Rhasspy instance in Docker on the Base station
192.168.1.95 is “sat-1”
192.168.1.93 is “sat-2”

I am concerned about the number of “401: Unauthorized” and “socket error”, so I tried monitoring the MQTT broker from my desktop PC on 192.168.1.99 :

$ mosquitto_sub -h 192.168.1.98 -p 1883 -d -t rhasspy/# -t hermes/#
Client (null) sending CONNECT
Client (null) received CONNACK (0)
Client (null) sending SUBSCRIBE (Mid: 1, Topic: rhasspy/#, QoS: 0, Options: 0x00)
Client (null) sending SUBSCRIBE (Mid: 1, Topic: hermes/#, QoS: 0, Options: 0x00)
Client (null) received SUBACK
Subscribed (mid: 1): 128, 128
Client (null) sending DISCONNECT
All subscription requests were denied.

It seems that the problem is with the MQTT broker - or at least the way I am trying to connect to it. Since this will all be operating in my home LAN I assume TLS encryption is not necessary … but do I need to add users and passwords ? What else am I missing ?

I found it !!

Apparently user and password is necessary to use the HA MQTT Broker Add-on ! I put in the details for HA’s only user (me) and it works ! Trimmed the satellite’s profile down to:

{
    "handle": {
        "satellite_site_ids": "sat-1",
        "system": "hass"
    },
    "home_assistant": {
        "url": "http://192.168.1.98:8123/"
    },
    "intent": {
        "system": "hermes"
    },
    "microphone": {
        "arecord": {
            "device": "plughw:CARD=seeed4micvoicec,DEV=0",
            "siteId": "sat-1",
            "udp_audio_port": "12203"
        },
        "system": "arecord"
    },
    "mqtt": {
        "enabled": "true",
        "host": "192.168.1.98",
        "password": "mypassword",
        "site_id": "sat-1",
        "username": "me"
    },
    "sounds": {
        "aplay": {
            "device": "plughw:CARD=Headphones,DEV=0",
            "volume": "1"
        },
        "system": "aplay"
    },
    "speech_to_text": {
        "system": "hermes"
    },
    "text_to_speech": {
        "system": "hermes"
    },
    "wake": {
        "porcupine": {
            "udp_audio": "12203"
        },
        "satellite_site_ids": "sat-1",
        "system": "porcupine"
    }
}

Base station’s Rhasspy profile is:

{
    "dialogue": {
        "satellite_site_ids": "sat-1, sat-2",
        "system": "rhasspy"
    },
    "intent": {
        "satellite_site_ids": "sat-1, sat-2",
        "system": "fsticuffs"
    },
    "mqtt": {
        "enabled": "true",
        "host": "192.168.1.98",
        "password": "mypassword",
        "site_id": "base",
        "username": "me"
    },
    "speech_to_text": {
        "satellite_site_ids": "sat-1, sat-2",
        "system": "kaldi"
    },
    "text_to_speech": {
        "satellite_site_ids": "sat-1, sat-2",
        "system": "larynx"
    }
}

Rebooted everything, and one last test … and …
Screenshot from 2021-09-25 14-33-22

:grinning: :smiley: :grinning_face_with_smiling_eyes: :grin: :laughing:

Thank you romkabouter for your assistance.

Now on to Hermes LED Control to get some indication of when the Pi Zero has finished booting, and is ready to listen for the wakeword.

Great that is works!

Just one question, why do you have a “base” AND the HA Addon?
The Addon can function as a base perfectly fine.

It seems you use the BASE including a MQTT broker, that is not needed at all.
So I am a bit confused on your setup.

This is mine:

  • HA MQTT Addon (indeed I use credentials(
  • HA Rhasspy Addon: Functions as a server, connecting to the HA MQTT broker external. This Addon does all the work, has Sound Recording disabled because it does not have a mic.
  • Some Satellites (esp32 devices, but could also be rhasspy on a pi or something)

If you use the HA addon as a server, you can use your Pi which currently is base as an extra satellite.
But if you current setup works fine then that is good as well obviously :slight_smile:

Romkabouter, I am also confused. What do you mean by “base” ? Are you thinking that “base” means a NUC or NAS ?

I am using “Base station” term from the Rhasspy documentation to refer to the main machine running Home Assistant, but also as the siteId of the Rhasspy instance running on it. My Base station is:

  • Raspberry Pi 4 running Home Assistant OS (so can’t attach a mic)
  • with Home Assistant MQTT and Rhasspy add-ons
  • Rhasspy add-on uses the MQTT add-on as its External MQTT broker

I now have 2 Satellites:

  1. RasPi 3B with reSpeaker 4-mic HAT running RasPi OS lite and Rhasspy (not Docker)
  2. RasPi Zero with Adafruit Voice Bonnet (to be changed to reSpeaker 2-mic HAT) running RasPi OS lite and Rhasspy (not Docker)

Ah so that is my confusion indeed :smiley:

Somewhere down the line I thought you had HA and another Pi/NUC/NAS with Rhasspy on it :smiley: