Shelly Integration - Cant add Shelly (1 Gen) -cannot_connect

Hello Community,

I currently have the following setup:

Home Assistant Supervisor V 2024.11.4 is running on a server located in Network A (10.0.0.0/24).

My IoT devices, including a Shelly 1PM, are in Network B (192.168.188.0/23).

Network A and Network B are connected via an Layer 2 OpenVPN tunnel.

Configuration details:

I’ve configured the IP routes so that all traffic to 224.0.0.0/4 (Multicast) is forwarded to Network A.

Additionally, all traffic to 192.168.188.0/23 is also routed through Network A.

Current status:

Home Assistant successfully discovers many devices via Multicast (e.g., DLNA servers, a Teufel radio, an AirGradient air quality meter), indicating that the Multicast forwarding is working properly.

Problem:

My Shelly 1PM is not automatically discovered.

When I attempt to add the Shelly manually using its IP address, I receive the error: “cannot_connect.”

I found an unsupported custom integration on GitHub(ShellyForHASS), which successfully discovers and integrates the Shelly device, but I’d prefer to use the official Shelly integration.

Question:

Does anyone know why the official Shelly integration is not working in this setup? Any ideas or suggestions?

Thanks in advance for your help!

You need to bridge the networks as mDNS has been designed, for security reasons, to work on a single subnet.

Check this thread which uses Avahi to bridge mDNS subnets: Bridging mDNS between networks - #5 by castillofrancodamian - Installing and Using OpenWrt - OpenWrt Forum

For Avahi: https://avahi.org

You can configure the device via MQTT, look here GitHub - bieniu/ha-shellies-discovery: Script that adds MQTT discovery support for Shellies devices

Why would I need to set up a bridge for this? If I run the command sudo ip route add 224.0.0.0/4 dev tap0, am I essentially instructing the system to route all multicast traffic (including mDNS) through tap0? Does this mean that all auto-discovered devices, except for Shelly, are simply not using mDNS?

I’m a bit unclear about what exactly needs to be done. Home Assistant has its own Docker bridge network (hassio), but under Settings > System > Network > Network Adapter, I notice the enp0s6 adapter is listed. This seems strange, as Home Assistant is supposed to run in an isolated Docker container.

I also wonder why I can’t directly select the tap0 adapter in Home Assistant’s network settings.

Thanks for the suggestion but that is not the direction I want to use. I would like to continue using the cloud connection with my Shelly 1PM and MQTT+Cloud is not possible with the first generation.

mDNS cannot cross subnets by design. The bridging is to bridge mDNS not the actual subnets.

I’ve now tried bridging the whole setup with Hassio, the enp0s6, and tap0 networks together (with the help of an Avahi Docker container), but unfortunately, it hasn’t made any difference.

As soon as I disable the route that should redirect all broadcast traffic to tun0, Home Assistant can no longer find any auto discovery devices(even if avahi is active)

However, theoretically, the Shelly integration (if I add it manually) should work even without mDNS multicast, right? After all, why would this integration need multicast if I’m providing the device’s IP address?

It might be easier to approach this from the other side—couldn’t I somehow make Home Assistant automatically direct its broadcast traffic to tap0? There is that setting option (as shown in the picture in my last post), and if I manage to get tap0 to appear there and select it, that might be enough.

Yes Shelly will work without mDNS with a static IP. Have you enabled CoAP on the Shelly?

Yes, I did activitate coap and entered the IP of the server (the server from network a gets a normal IP from the DHCP address range due to the layer 2 tunneling from the router in network b).

Whenever I try to add shelly (I enter the IP address and click on add) home assistant tries to reach shelly and gets answers (about 15 packets go back and forth between home assistant and shelly) and then throws me a connection failed or cannot_connect message.

I would guess this is a security related issue and would suggest you check your network security settings. Alternatively try to move the shelly to the 10.x subnet and see if it plays ball.