Shelly integration & MQTT (via MacBook)

Hey Node RED community.

I'm on a beginners level using Node RED to monitor and control Shelly devices.
My setup at the moment is a Shelly Plus 1 which is connected to my network and I was setting up Node RED on my MacBook.

Now I'm a bit overwhelmed with all steps to do in order to control the Shelly (switching on and off)

Here's what I can say for sure.

  • Mosquitto v2.0.20 is installed with homebrew and the broker is running.
  • The IP's of MacBook ({MacBook-IP}.9) and Shelly device ({ShellyDevice-IP}.9) indicate that it's connected to the same network.
  • Shelly device runs with activated MQTT

Shelly device MQTT settings:

  • Connection type: No TLS
  • MQTT prefix: shellyplus1-{shellyID}
  • Server: {MacBook-IP}.9
  • Client ID: shellyplus1-{shellyID}
  • Username: {my-mqtt-user-name}
  • Password: {my-mqtt-user-password}

Node RED "mqtt out" node set to:

  • Topic: shellies/shellyplus1-{shellyID}/relay/0/command/
  • QoS: empty
  • Server: {MacBook-IP}.9 | Port: 1883 | Protocol: MQTT V3.1.1
  • Username: {my-mqtt-user-name}
  • Password: {my-mqtt-user-password}

Now when I'm deploying in Node RED, it shows "connecting" below the MQTT-node and I'm not able to trigger anything.

I would appreciate constructive hints for my issue as I assume setting up should be a straight forward thing but I'm lacking of background knowledge.

Thanks in advance :slight_smile:

Seems your not able to connect to the mqtt broker
mqtt2 has some security settings that are enabled by default, or your user and password are incorrect

have a look here for settings for mqtt config file.

Hey @E1cid.

Thanks for that.

I tried myself through. Found the config file, and uncommented
allow_anonymous true
and
listener 1883

I also found that bind_address 0.0.0.0 should be in there.

Unfortunately without success. Everything is still having the same outcome.

The node-red terminal message shows:
[info] [mqtt-broker:Switcher] Connection failed to broker: mqtt://172.20.10.9:1883

However, when I set localhost as Server in Node RED then I see

[info] [mqtt-broker:Switcher] Connected to broker: mqtt://localhost:1883

But that doesn't solve the Shelly issue.

Is this your Mac?
Does it have a static / reserved IP address? What address?
What is it's hostname and can you specify a hostname in the Shelly?
What is the IP address of the Shelly (which doesn't have to be static)?

Is this your Mac?

Yes

Does it have a static / reserved IP address? What address?

No, DHCP. The address is 172.20.10.9

What is it's hostname and can you specify a hostname in the Shelly?

What do you mean by hostname?

As to the Shelly. Here you have a screenshot how the MQTT setting looks (I just googled it):

What is the IP address of the Shelly (which doesn't have to be static)?

It's 172.20.10.2. I assume it gets assigned automatically. It is indeed possible to set a static IP address, Network mask, Gateway and DNS.

According to your shelly setting the server is 192.168.10.13
but your notebook is 172.20.10.9

The IP of the notebook(where mosquitto is installed) should match the IP of the server in the shelly settings. Which should be a local lan IP not your internet wan IP

You should be able to set static IP's in your router using the mac address of the device. The broker will need a static IP.

Please be aware that the image I posted above is googled and not a screenshot of my own screen. I just posted it for demonstration purposes.

A computer can be referred to on a network using either it's IP address or a hostname.
I don't know Macs but on my Linux computers the hostname is specified in /etc/hostname and can be shown with the hostname command.
For example:

pi@GlassPi:~ $ hostname
GlassPi

While the IP address may be set by the network DHCP server and might vary, the hostname is specified by the comouter itself and is thus fixed.

I asked about this because you may be able to specify the hostname rather than the IP address as the MQTT server (I have no idea if this will work for your Shelly).
It's more usual though for the MQTT broker to have a static IP address, or at least a reserved address in the router.

Screenshots can sometimes help us understand how a system is set up.
Not if they are a random photo from the internet though.