Pretty new to this HASS business, have loads of fun exploring all the possibilities, but running into an issue with MQTT.
I have 2 rPi’s, one with HASS installed (IP *.29). I would like to send values from and to the rPi without HASS. I figured out MQTT would be a great way to do this. So I installed mosquitto on both PI’s and am able to send message back and forth: mosquitto_sub -d -t dev/test //On either rPi
mosquitto_pub -d -t dev/test -m "test" //On the Hass rPi
Now I would like to be able to send/receive these messages with HASS. I add the following line to my config file:
mqtt:
broker: 10.0.0.29
When I now try to subscribe to the MQTT, I get error: connection refused. From both rPi’s.
The only way to resolve the error is to reinstall mosquitto.
What am I messing up?
Thanks!
Edit: Same issue when I try to add these to the mosquitto config:
allow_anonymous false
password_file /etc/mosquitto/pwfile
listener 1883
Mhmmm, it seems to be an issue with mosquitto not starting at boot. Everything seems to be in place, but I still need to manually start mosquitto. Anyone?
There are a couple of things in your post that are not clear, so I would like to make sure everyone is not talking at cross purposes
.[quote=“boneless, post:1, topic:19338”]
So I installed mosquitto on both PI’s
[/quote]
You only need one MQTT broker running on your network. This is normally running on the machine with HA running on it, as then you only have to keep this machine running for MQTT connections to work, as well as HA. But you can install it elsewhere.
All connections from all machines go to this one broker on the network.
If you do this without the -h option, it connects to the broker on the machine it was run on. This does not automatically communicate with a broker on another machine.
To connect to the broker on the HA machine from the remote machine do
$ mosquitto_sub -h 10.0.0.29 -d -t dev/test
If you do have a broker on the second pi, it won’t hurt but will confuse you if you accidentally connect to it, so you can disable it with
You are right. I already added the host part while connecting from the second rPi and that works. It turned around a removed mosq. from the HASS rPi, changed the settings in HASS to point to the second rPi and that works for me. I just noticed some more people with the same issue where mosquitto not starting.
Now I run into another issue. I run the broker on the 2nd rPi and have added that config to HASS. I can publish messages from HASS and receive them on the other end.
Now when I try to add a sensor:
# Example configuration.yml entry
sensor:
- platform: mqtt
state_topic: "home/bedroom/temperature"
And reload the configuration, it ends up in an eternal loading loop. When I reboot, HASS never loads. The config checks out. What am I doing wrong now…
Okay, I am a dingus…
I think the problem was that I the standard sensor for weather from YR was declared longer up. I was trying to declare another sensor longer down. That is a no-no. Argh!