Shelly (i3) CoIOT click events and VLAN / Subnet

Writing this to document the solution i found to missing coiot events on port 5683 from my shelly i3.

I followed the instructions, and setup unicast coiot messages to my hass_ip:5683 in the shelly config.

I have my shellies on a 10.0.1.x/24 subnet, and my home assistant install on 10.0.0.x/24

My hass install straddles both subnets / vlans, but since the shellies were getting a subnet mask of 255.255.255.0 (ie, on a /24), the CoIOT messages intended for hass were being routed via my default gateway.

I think this was why home assistant didn’t see any shelly.click events.

I enabled logging like so:

logger:
  default: info
  logs:
    aioshelly: debug
    aioshelly.coap: debug
    homeassistant.components.shelly: debug

and noticed in the logs that the CoapMessage had a source ip of the router, instead of the shelly’s ip:

DEBUG (MainThread) [aioshelly.coap] CoapMessage: ip=10.0.0.1 ... <--- the router 

Anyway, solved for now by giving the shellies a /16, ie a subnet mask of 255.255.0.0 so they can directly send to the home assistant IP without routing via the gateway.

Another possibly better option is to give the hass box a second IP on the shelly subnet and vlan and have coiot hit that directly.

Hope this helps someone, it annoyed me all morning.

That may actually indicate that you have not set up VLANs and subnets correctly.

I can confirm that configuring CoIoT on the Shelly devices with an IP address outside of their own subnet does indeed work correctly - if the network is setup correctly. Messages do indeed need to go via the gateway because that’s just how IP networks work: Any destination that is not in the same subnet is sent to the gateway so that the gateway can redirect the packets.

While this is a possible setup, it should not be necessary for making CoIoT work. Also, this setup may run the risk of introducing security issues that you wanted to prevent by setting up VLANs in the first place.

This is very good to know, thanks for replying – I’ve no idea why CoIoT wasn’t working when I had isolated /24s and traffic routed via my gateway (an iptables box). I was seeing the messages arrive at the home assistant machine, but no shelly.click events were firing.

I’m facing this because I just transitioned from an old custom docker setup of homeassistant to using HAOS.

Previously I was blocking traffic between subnets save for specific devices which could talk with the hass IP. I will have another go at getting coiot working in that arrangement.

1 Like