Every time I reboot my system, all the MQTT-based components fail to initialize. I know that mosquiitto is getting started at boot time, but must be starting after HA (or not early enough before). If I simply stop/start HA manually at that point, it connects up with the already running server.
I’m not very familiar with systemd scripts, but after some google work, I tried adding this line to the “[Unit]” section of /etc/systemd/system/[email protected]
I’ve been having the same issue with zoneminder and home assistant. Modifying the systemd files of each with Before and After lines has no effect. Would appreciate any input.
and is configured to start automatically at boot time with systemctl enable mosquitto
(And it does get started. After boot, I can see that it’s running, and if I restart HA it starts working because it’s able to connect to the broker)
That is different from mine, which uses init.d installed from the package, but as far as I can see it should work.
You can check to see if mosquitto was actually started before HA by checking the process id numbers. They are give in order so HA should be higher if it was started after mosquitto
$ ps -ef | grep mosquitto
$ ps -ef | grep hass
Is there anythnig in the mosquitto log file that would indicate it is slow startup?
Maybe there is something slowing the startup of mosquitto. Is there anything in the mosquitto log file (normally in /var/log/mosquitto/mosquitto.log) that would indicate a problem. Mine starts with
1490613437: mosquitto version 1.4.11 (build date Mon, 20 Feb 2017 22:47:27 +0000) starting
1490613437: Config loaded from /etc/mosquitto/mosquitto.conf.
1490613437: Opening ipv4 listen socket on port 1883.
1490613437: Opening ipv6 listen socket on port 1883.
1490613437: New connection from 192.168.0.25 on port 1883.
1490613437: New client connected from 192.168.0.25 as mysensors-1 (c1, k15).
1490613439: New connection from 192.168.0.19 on port 1883.
1490613439: New client connected from 192.168.0.19 as 433toMQTTto433 (c1, k15).
1490613443: New connection from ::1 on port 1883.
1490613443: New client connected from ::1 as Energenie Controller (c1, k60).
1490614496: New connection from ::1 on port 1883.
1490614496: New client connected from ::1 as paho/1D04E8882DD1483555 (c1, k60).
1490616171: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
Unfortunately the times haven’t been expanded in the mosquitto log, so comparing this to the start time of HA is going to need some work.
As an experiment, I moved the MQTT broker to another independent server. So the broker is running all the time, even when the HA system is rebooted. The MQTT components still fail to initialize at boot time. But once the system is up and I restart HA, then everything is fine. There must be “something” other than HA or MQTT that’s getting started in the wrong order, but I don’t know what that could be.
Hey guys,
I just installed a new raspberry pi, home-assistant and mosquitto.
I have the same issue as described above.
I added the mosquitto.service to the after condition of the homeassistant systemd unit, but still when I reboot the rpi mqtt is not working in HA and i need to manually restart HA. Then it is working fine.