openhab-remote-xiaomi
Notes on setup openhab supporting receiving multicasts from remote xiaomi gateway endpoints
Network setup
Xiaomi smarthome gateways after recent firmware update no longer provides REST interface for updates. Instead, it provides updates purely in local network using multicast to group 224.0.0.50 and port 9898.
This requires us to
a) Connect to remote site using L2 layer, using vpn that supports that scenario (for example openvpn)
b) As OpenHab does not support multicast listening on multiple interfaces, and 224.0.0.50 can't be routed using igmpproxy, pimd or smcroute - the only choice is configuring Bridge Networking on opehab server, combining local ethernet (eth0) together with VPN interface (tap0)
Openhab Server - Bridge Networking
Note, in some systems, like Raspbian necessary package might not be installed. Check additionally.
https://gist.github.com/e838843cfa96d36c71731dda851bce0e
/etc/network/interfaces
https://gist.github.com/f23e2a38ea478cfaa24c5054be636337
Openhab Server - Openvpn Client
/etc/openvpn/client.conf
https://gist.github.com/0b6a42ca00b48f02b92d82aa5b91bafb
up.sh https://gist.github.com/0b1eb351506dd53acf07de25e3413f5e
down.sh https://gist.github.com/fac4f7af367c90dbfc543258825f488d
Openhab Server - Validating setup
https://gist.github.com/a0668206d54674ccde53bac9529545de
Openhab Server - Persisting configuration changes
I am running home automation on simple Raspberry PI 3. It has one drawback - for 24/7 work termals are not good even with passive cooling. SD card potentially might die quite soon, hardware - depends on plate cooling quality.
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
Remote site - OpenVPN server
Ideally, you might have router that already supports L2 OpenVPN. Routers supporting custom firmwares (Padawan, Openwrt, Tomato - for sure), Microtics and so on.
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 same raspberry pi) and install OpenVPN there.
Tips and tricks
Design patterns
https://community.openhab.org/tags/designpattern
VS Code extension