In need of mqtt help

Posted on
Tue Jul 27, 2021 6:22 pm
mpleeds offline
Posts: 46
Joined: Jul 02, 2012

Re: In need of mqtt help

Thanks to all for chiming in!

Per Aaron's suggestion, I inserted the Mac Mini IP (192.168.1.46) into Shelly, then rebooted Shelly, reloaded MQTT Connector and Shelly MQTT. Unfortunately, Indigo still unable to control relay. When I input my Mac Mini IP into MQTT explorer, I get a "disconnected from server" message. There seems to be some ambiguity as to which IP Shelly should use to point to the broker. Is there a unique IP for the MQTT Broker, and if so, how can it be retrieved ?

Screen Shot 2021-07-27 at 5.18.26 PM.png
Screen Shot 2021-07-27 at 5.18.26 PM.png (461.26 KiB) Viewed 550 times

Posted on
Tue Jul 27, 2021 6:47 pm
aaronlionsheep offline
Posts: 137
Joined: Feb 24, 2019
Location: Virginia, USA

Re: In need of mqtt help

mpleeds wrote:
Thanks to all for chiming in!

Per Aaron's suggestion, I inserted the Mac Mini IP (192.168.1.46) into Shelly, then rebooted Shelly, reloaded MQTT Connector and Shelly MQTT. Unfortunately, Indigo still unable to control relay. When I input my Mac Mini IP into MQTT explorer, I get a "disconnected from server" message. There seems to be some ambiguity as to which IP Shelly should use to point to the broker. Is there a unique IP for the MQTT Broker, and if so, how can it be retrieved ?

Screen Shot 2021-07-27 at 5.18.26 PM.png


Do you have any firewalls rules in place on your Mac mini that would prevent another device from connecting to it? Are you 100% certain that the IP address of your Mac mini is 192.168.1.46?

Networking consists of IP addresses and ports. Mosquito runs on port 1883 on your Mac mini that has an IP address on your Local Area Network (LAN) of 192.168.1.46, so any other device on your network will need to use that information to connect.

I can't see the rest of your MQTT Explorer window, but did you specify to connect to port 1883 also? This is either done by adding a colon to the IP address followed by the port (192.168.1.46:1883) or by filling out a port field. I don't use MQTT Explorer, so I'm not familiar with the user interface.

Also, you can run this command in your terminal to verify that Mosquito is running correctly and is bound to the correct interface on your Mac mini,
Code: Select all
netstat -anvp tcp | grep 1883


My output looks like:
Code: Select all
tcp4       0      0  *.1883                 *.*                    LISTEN      131072 131072   9852      0 0x0100 0x00000006
tcp6       0      0  *.1883                 *.*                    LISTEN      131072 131072   9852      0 0x0100 0x00000006

Posted on
Tue Jul 27, 2021 7:23 pm
mpleeds offline
Posts: 46
Joined: Jul 02, 2012

Re: In need of mqtt help

No firewalls. Yes, Mac Mini IP address confirmed in Orbi Router web interface and Mac Mini Network info.

Screen Shot 2021-07-27 at 5.57.34 PM.png
Screen Shot 2021-07-27 at 5.57.34 PM.png (42.3 KiB) Viewed 542 times


MQTT Explorer does have a separate port field, which is showing 1883.

Screen Shot 2021-07-27 at 5.59.06 PM.png
Screen Shot 2021-07-27 at 5.59.06 PM.png (94.9 KiB) Viewed 542 times


Ran command in Terminal with these results:

Mac-mini:~ mpleeds$ netstat -anvp tcp | grep 1883
tcp6 0 0 ::1.1883 ::1.62316 ESTABLISHED 398165 146808 1550 0 0x0102 0x00000004
tcp6 0 0 ::1.62316 ::1.1883 ESTABLISHED 407196 146808 21411 0 0x0102 0x00000000
tcp6 0 0 ::1.1883 *.* LISTEN 131072 131072 1550 0 0x0100 0x00000006
tcp4 0 0 127.0.0.1.1883 *.* LISTEN 131072 131072 1550 0 0x0100 0x00000006
Mac-mini:~ mpleeds$

Due to weak Z-wave signals at long distances, inconsistent Insteon performance, and the daunting prospect of making "hard-wire" runs throughout our 3+ acre property, I'm really motivated to get your plugin up and running through WiFi.
Attachments
Screen Shot 2021-07-27 at 6.06.21 PM.png
Screen Shot 2021-07-27 at 6.06.21 PM.png (19.04 KiB) Viewed 542 times

Posted on
Tue Jul 27, 2021 7:30 pm
aaronlionsheep offline
Posts: 137
Joined: Feb 24, 2019
Location: Virginia, USA

Re: In need of mqtt help

mpleeds wrote:
No firewalls. Yes, Mac Mini IP address confirmed in Orbi Router web interface and Mac Mini Network info.

Screen Shot 2021-07-27 at 5.57.34 PM.png


MQTT Explorer does have a separate port field, which is showing 1883.

Screen Shot 2021-07-27 at 5.59.06 PM.png


Ran command in Terminal with these results:

Mac-mini:~ mpleeds$ netstat -anvp tcp | grep 1883
tcp6 0 0 ::1.1883 ::1.62316 ESTABLISHED 398165 146808 1550 0 0x0102 0x00000004
tcp6 0 0 ::1.62316 ::1.1883 ESTABLISHED 407196 146808 21411 0 0x0102 0x00000000
tcp6 0 0 ::1.1883 *.* LISTEN 131072 131072 1550 0 0x0100 0x00000006
tcp4 0 0 127.0.0.1.1883 *.* LISTEN 131072 131072 1550 0 0x0100 0x00000006
Mac-mini:~ mpleeds$

Due to weak Z-wave signals at long distances, inconsistent Insteon performance, and the daunting prospect of making "hard-wire" runs throughout our 3+ acre property, I'm really motivated to get your plugin up and running through WiFi.


Ahah there is the problem. That last line shows that for ipv4, mosquito is listening on the 127.0.0.1 interface (loopback). This means that mosquito will only be able to accept connections from the same machine. This explains why you can connect to the broker using MQTT Explorer and MQTT Connector using the localhost as the host, but failures when trying to connect through an IP address.

Take a look at your configuration file for mosquito. The default location is /usr/local/etc/mosquitto/mosquitto.conf
Look for an entry for "listener". It accepts 2 parameters: a port followed by an address to bind to. You may need to set this to "listener 1883 0.0.0.0" in order to get mosquito to bind to an address that will allow other devices to connect. You will need to restart mosquito after adjusting the configuration.

0.0.0.0 means that it will bind to all network interfaces and allow connections from other devices on your LAN.

EDIT:
It looks like there were some "recent" changes to Mosquitto that defaults to bind to the loop-back address. There is some information in the "Breaking Changes" section of the release notes for 2.0.0: https://mosquitto.org/blog/2020/12/vers ... -released/
That indicates that you might also need to set "allow_anonymous true" as well. I have an older configuration file that doesn't have these "features", so mine binds to 0.0.0.0 as I would expect. I can play around with a new config file tomorrow if you are still having some issues with these 2 latest configuration suggestions.

Posted on
Tue Jul 27, 2021 7:56 pm
mpleeds offline
Posts: 46
Joined: Jul 02, 2012

Re: In need of mqtt help

Any suggestions as to:

1. Where to look for the Mosquitto configuration file?
2. How to change the "listener" port/address?
3. The command for restarting Mosquitto?

Is all of the above done through terminal? I don't have any prior experience in this area, but not afraid to open the hood and get my hands dirty.

Many thanks!

Posted on
Tue Jul 27, 2021 8:09 pm
aaronlionsheep offline
Posts: 137
Joined: Feb 24, 2019
Location: Virginia, USA

Re: In need of mqtt help

mpleeds wrote:
Any suggestions as to:

1. Where to look for the Mosquitto configuration file?
2. How to change the "listener" port/address?
3. The command for restarting Mosquitto?

Is all of the above done through terminal? I don't have any prior experience in this area, but not afraid to open the hood and get my hands dirty.

Many thanks!


1. The default location for that config file should be /usr/local/etc/mosquitto/mosquitto.conf - In the Menu bar of a Finder window, you can select "Go" and the "Go to folder" and enter "/usr/local/etc/mosquitto" and hopefully that takes you to a directory with Mosquitto.conf located there. You can open that file with TextEdit. You might need to right-click and select "Show original" on the config file. In Text Edit, you want to make sure you are in plain-text mode. After opening the file the file should look like a mono-spaced font similar to the font your terminal uses. If it doesn't, then go to Format > Make Plain Text. If there is an option for Make Rich Text, then you are already in plain text mode and should be good to make changes.
2. In the "Extra listeners" section about 40% of the way into the file, there is a line that starts with the word "listeners". It probably starts with a '#', so remove the '#' such that the word "listeners" is at the very start of its own line. You can add a space then "1883" and then another space and then "0.0.0.0". That single line should go from
Code: Select all
#listener

to
Code: Select all
listener 1883 0.0.0.0

In the section "Security" section about 70% of the way through, there is a line that might look like:
Code: Select all
#allow_anonymous true/false

and I think it should be set as:
Code: Select all
allow_anonymous true

3. If you installed Mosquitto through Brew (the common way), then I'm guessing you probably ran a command that looked like "brew services start mosquitto". You can try running "brew services stop mosquitto", make the config changes, and then run "brew services start mosquitto"

Posted on
Tue Jul 27, 2021 10:42 pm
mpleeds offline
Posts: 46
Joined: Jul 02, 2012

Re: In need of mqtt help

Brilliant -- these 2 mosquitto.conf changes did the trick.

Shelly1 relays and detached switch true/false input (tested with trigger) working flawlessly -- Garage doors, meet Shelly.

Thanks for creating this useful plugin and for getting me up and running!

Posted on
Wed Jul 28, 2021 11:38 am
tazswe offline
Posts: 160
Joined: Mar 13, 2017
Location: Sweden

Re: In need of mqtt help

The name localhost normally resolves to the IPv4 loopback address 127.0.0.1.
If I remember correctly the manual for setting up Mosquitto recommended to use localhost.

Maybe you shall mention in the Shellymqtt instructions to use the actual address and not localhost.


Sent from my iPad with Tapatalk

Who is online

Users browsing this forum: No registered users and 1 guest

cron