Forwarding mi gateway multicasts from remote locations

Actually, this article is the memory for myself. Article describes notes on setting up network infrastructure with remote xiaomi mi gateways, so the openhab will still receive multicasts with sensors updates also from remote endpoints.

Network setup

Keeping in mind multicast idea, the only option to get those updates is to join openhab to remote sites via some VPN supporting L2 layer. Good example of free vpn supporting L2 — OpenVPN.

Once we get smart gateway multicast on openhab box, next challenge would be to join multiple sources on a single network interface.

As OpenHab does not support multicast listening on multiple interfaces, and 224.0.0.50 group can’t be routed using igmpproxy, pimd or smcroute — the workable choice is to configure Bridge Networking on opehab server, combining local ethernet (eth0) together with VPN interface (tap0)

Now a bit of “configuration” meat.

Openhab Server — Bridge Networking

Let’s configure bridge on openhab box. Note, that eth0, which corresponds to your physical network card does not obtain ip address and instead delegates that task to bridge.

/etc/network/interfaces

Remote site — OpenVPN server

If for any reason you don’t have such router, this means you would need to place one more box on remote site (possible — the similar raspberry pi) and install OpenVPN there.

Openhab Server — Openvpn Client

/etc/openvpn/client.conf

On up we join interface to bridge, on down — drop.

up.sh

down.sh

Openhab Server — Validating setup

Openhab Server — Persisting configuration changes

Thus I prefer to configure openhab via file configuration, with set of deployment batches, that provision openhab server with updates. All configuration changes are stored in a private git repository.

Additionally, ansible plays are used for initial box configuration (zsh shell, docker daemon, prometheus exporters, openvpn configuration and so on)

This allows me to easy recover openhab state in case of sudden failure.

Some code snippets can be found at https://github.com/Voronenko/openhab-remote-xiaomi

Tips and tricks

VS Code extension I find really helpful to code smart home configuration as a code

--

--

Software engineer, with project management background. Founder @ softasap.com — cool automation for the people :) — have a problem that needs to be solved?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vyacheslav Voronenko

Software engineer, with project management background. Founder @ softasap.com — cool automation for the people :) — have a problem that needs to be solved?