MQTT with RPi offline (docker)

Hello,

Today i would show a new voice assistant, totally offline… i combined, in a Raspberry, Rhasspy, Home Assistant and Mosquitto. It worked well at home.
But, when I turn the RPi on, in a new site, nothing append ! And, when I go back to home… it works !
I am a bit confused… I suspect a problem with IP (the site where nothing append was wifi free). Here the logs :

    main()
  File "/usr/lib/rhasspy/rhasspy-homeassistant-hermes/rhasspyhomeassistant_hermes/__main__.py", line 59, in main
    hermes_cli.connect(client, args)
  File "/usr/lib/rhasspy/rhasspy-hermes/rhasspyhermes/cli.py", line 93, in connect
    client.connect(args.host, args.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 727, in create_connection
    raise err
  File "/usr/lib/python3.7/socket.py", line 716, in create_connection
    sock.connect(sa)
SError: [Errno 113] No route to host

I saw here and there that the MQTT IP adress must be the RPi one (withe docker).
If so, how Rhasspy+HA+Mosquitto work totally offline ? Which host should I filled in Rhasspy (and HA/Mosquitto) settings ?
I assume localhost won’t work ?

And my HA logs if this should help :

2022-05-23 20:18:01 WARNING (Recorder) [homeassistant.components.recorder.util] The system could not validate that the sqlite3 database at //config/home-assistant_v2.db was shutdown cleanly
2022-05-23 20:18:02 WARNING (Recorder) [homeassistant.components.recorder.util] Ended unfinished session (id=110 from 2022-05-23 17:30:02.493299)
2022-05-23 20:18:34 WARNING (MainThread) [homeassistant.setup] Setup of tag is taking over 10 seconds.
2022-05-23 20:18:34 WARNING (MainThread) [homeassistant.setup] Setup of counter is taking over 10 seconds.
2022-05-23 20:18:34 WARNING (MainThread) [homeassistant.setup] Setup of input_boolean is taking over 10 seconds.
2022-05-23 20:18:34 WARNING (MainThread) [homeassistant.setup] Setup of media_source is taking over 10 seconds.
2022-05-23 20:18:34 WARNING (MainThread) [homeassistant.setup] Setup of system_health is taking over 10 seconds.
2022-05-23 20:18:34 WARNING (MainThread) [homeassistant.setup] Setup of zone is taking over 10 seconds.
2022-05-23 20:18:34 WARNING (MainThread) [homeassistant.setup] Setup of input_select is taking over 10 seconds.
2022-05-23 20:18:34 WARNING (MainThread) [homeassistant.setup] Setup of input_text is taking over 10 seconds.
2022-05-23 20:18:34 WARNING (MainThread) [homeassistant.setup] Setup of logbook is taking over 10 seconds.
2022-05-23 20:18:34 WARNING (MainThread) [homeassistant.setup] Setup of timer is taking over 10 seconds.
2022-05-23 20:18:39 WARNING (MainThread) [homeassistant.components.ssdp] Failed to setup listener for fe80::42:33ff:fe80:119d: [Errno 22] Invalid argument
2022-05-23 20:18:39 ERROR (MainThread) [homeassistant.components.mqtt] Failed to connect to MQTT server due to exception: [Errno 113] Host is unreachable
2022-05-23 20:18:40 ERROR (MainThread) [homeassistant.components.updater] Error requesting Home Assistant update data: Cannot connect to host www.home-assistant.io:443 ssl:default [Try again]
2022-05-23 20:18:40 ERROR (MainThread) [metno] Access to https://aa015h6buqvih86i1.api.met.no/weatherapi/locationforecast/2.0/complete returned error ‘ClientConnectorError’
2022-05-23 20:21:22 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from localhost (::1). (Mozilla/5.0 (X11; CrOS armv7l 13597.84.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.187 Safari/537.36)
2022-05-23 20:23:06 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with

Thanks

Offline does not mean no network, it means no internet connection.
In your log from Home Assistant, you can see that HA tries to connect with internet, in your case metno and update.

As for Rhasspy and MQTT, localhost can be used but if you want to use Rhasspy you can also set it to internal and then Rhasspy should work.
The question is however what the system needs to be doing without any network (aka wifi) connection?

In that case, home assistant should reach internal MQTT ? Wich IP should I fill to access it ?
I will verify if containers Rhasspy and HA are both in “bridge”…

It will command zwave/zigbee devices (shutters, light…). It would be install in “public housing” : this allows to have confort’s Automation, without internet and fees (and expensive google/alexa equipement…)

So how would you reach home assistant UI without wifi?
I think you need a wifi network, but that does not mean you have to connect it to internet.

I plug a screen and a keyboard/mouse the RPi to access GUI. In that way, I could reach HA, but unfortunately not for Rhasspy GUI…

I would not change my goals to fit Rhasspy’s technic (for that, Google/Alexa are better), but I aim to find a solution in order to have a really standalone/offline solution.

I need a prototype without wifi connection to show how a open source solution could work.
In a second time, I hope to succeed in implement Rhasspy’s apk on a smartphone (so, with wifi and internet…).

To give you some perspective, I’m working in a social housing company. I think confort and modern flat should be affordable not only if you have enought money. A flat with automation and voice control commands is a way to reach this confort.
I have a project with 24 accommodation / housing. Each of them has light, shutters, temperature, presence, and fire detection zigbee devices. Everythings is connect with a hub (ogga.fr). However, the vocal command is only possible with private solution (Google/Amazon).
I would like to promote other way, like Rhasspy : open source, rgpd compliant, free…

The hardware prototype without wifi is a way to expose a handable/concrete solution (and get my colleagues adhesion).

So, to go back to technic, is any one could give me a direction for this standalone solution (container Rhasspy, ha, mosquitto) ?

Thanks you really much !

If you can reach HA via an ip adress or host name, use that in Rhasspy. That should be ok. I also recommend using the HA and then MQTT and Rhasspy as an addon.

That app needs a connection to a Rhasspy server, it is not standalone. I do not know it you are aware of that.

1 Like

I didn’t know… Thanks for the warning ! However, thé company should do that… Something to remember !

Unfortunately no… I will try again !

What company are you referring to?

Well, docker is a hard way for me… perhaps with docker IP (172…) it should work. Unfortunately, I didn’t succeed.
I try an other way : hassio + rhasspy add on.

rest_command:
  rhasspy_play:
    url: 'http://localhost:12101/api/play-wav'
    method: 'POST'
    payload: '{{ payload }}'

This seems working (event send to HA, HA send something to rhasshpy), except :

[ERROR:2022-06-03 16:58:39,844] rhasspyserver_hermes: [Errno 2] No such file or directory: ‘/media/Bienchessoi.wav’

Where should I should redirect hermes to play a wav file (in /usr/share/hassio/media) ?
Path /home/pi/Musique/Bienchessoi.wav doesn’t work either.

Thanks for your advice !
Damien

My company should do it