Shelly 2 PM and mqtt integration

Hello community, some months ago I did a mqtt config to control all my lights with the wall switches and shelly. I have several Shelly 1 v3 and Shelly 2.5. I had to change one of them (Shelly 2.5 model) with a Shelly 2 PM. I did the same config as per other Shelly 2.5 (GUI is quite different, but all data should be there):

Then in HA I left the original config in mqtt section:

    - name: "Cameretta Interruttore"
      state_topic: "shellies/shelly25-cameretta/relay/1"
      command_topic: "shellies/shelly25-cameretta/relay/1/command"
      qos: 0
      payload_on: "on"
      payload_off: "off"
      retain: false
    - name: "Ingresso Cameretta Interruttore"
      state_topic: "shellies/shelly25-cameretta/relay/0"
      command_topic: "shellies/shelly25-cameretta/relay/0/command"
      qos: 0
      payload_on: "on"
      payload_off: "off"
      retain: false

So every time the wall switch will be used, HA will receive the input and use an automation to switch on/off the light.

Problem is that currently I’m not able to recognize the Shelly 2 PM in HA, so no automation is triggered.

From the Shelly integration I can see what reported below. Obviously I double/triple checked the username/password. Anyway all other Shelly works perfect.

2023-09-26 08:08:32: New connection from on port 1883.
2023-09-26 08:08:32: Client shelly25-cameretta already connected, closing old connection.
2023-09-26 08:08:32: New client connected from as shelly25-cameretta (p2, c1, k60, u'mqtt_user').
2023-09-26 08:10:03: New connection from on port 1883.
error: received null username or password for unpwd check
2023-09-26 08:10:03: Client auto-F345C7B7-94C0-AAE6-765F-CB2790840739 disconnected, not authorised.

Could someone help me to integrate via mqtt the new shelly 2.5 PM? Cause now I cannot switch on 2 lights in my house :slight_smile:
As I wrote, many months are passed (maybe years), is there any other method to integrate Shelly? Currently I’m using the native integration.

Thank you

If you are using the core Shelly installation why are you setting up mqtt?

Navigate to the local IP address of your Shelly device, Settings >> Connectivity >> Outbound WebSocket and check the box Enable Outbound WebSocket, under server enter the following address:

ws:// + Home_Assistant_local_ip_address:Port + /api/shelly/ws (for example: ws://, click Apply to save the settings.

1 Like

Thank you very much, I enabled the Outbound WebSocket and now it works. Sorry, I missed it on documentation. In this way I also disabled the mqtt on new Shelly 2 PM and it still works. I had enabled the mqtt about 2 years ago cause probably HA didn’t support such integration.

Now I have another issue. I tried to disable mqtt on Shelly 1 v3, and add them to the core Shelly integration. I re-created the automation and they work fine from HA, i.e. pressing the switch, the light will be switched on/off. Unfortunately when I use the wall switch there are a long delay so light will be switched off after many seconds. I got an alert on HA that say that cannot communicate with the Shelly and CoIoT should be enabled. I check it and CoIoT is enabled.

There is no Outbound WebSocket on Shelly 1 and for now I rollback to mqtt, but I would like to disable mqtt at all on all my shelly. I don’t understand why I got this issue!

Did you also specify the unicast address as per the instructions for GEN 1 devices?

1 Like

YES, and the best you don’t even need to waste time with mqtt anymore :dancing_men:

Ether go with shelly integration and use web socket or install esphome on your shellys and go with the native api :rocket:

Sure I did it and reboot the shelly, now I restarted also HA and it works! Thank you!

This is what I would like to do, remove the mqtt on HA and shelly, and enable also cloud on shelly.
I did it right now with 1 Shelly and I notice then a very little delay when I press the wall switch compared with mqtt, anyway it’s acceptable.

Switching your loads over the internet utilizing other peoples computers? Not what I suggested. :stop_sign:

I advise for local control with full ownership running your own *ware on the device :point_right:

Thanks I’ll check it

It’s really not necessary unless you want to do some more advanced automation on the device.

Shelly are one of the few companies that respect the user’s right to have local control and that is exactly what the core integration does.

I see, however I noticed a little delay in command execution when I use the wall switch (light toggle) compared with mqtt. Nothing dramatic and I can live with it cause it’s a very little delay. Maybe I can try to disable cloud on shelly since I don’t need it and I don’t see any reason to leave it enabled.
However, the most important thing is that now everything work as expected.

If your command to toggle is send hundreds or thousands of kilometers through the world wide web :cloud: that is expected. :man_shrugging:

Some users btw. claim that the esphome native api performs faster than mqtt :point_down:

It’s not if they are using the core integration.

Screenshot 2023-09-28 at 22-39-55 Shelly