Categories
Communications Computers English Networking Routers

OpenWrt: Monitor your IPv6 Status

I recently had a full outage of IPv6 on my Deutsche Glasfaser fibre-based internet line that lasted for more than 3.5 months. I only found out by chance, which I found very frustrating. If it happens again I want to be notified immediately, so I built an automation that has the following architecture:

  • OpenWrt-based router/internet gateway sends event every time WAN interface changes with respect to IPv6
  • Event lands in an MQTT broker
  • Home Assistant: set up sensor based on messages sent to MQTT topic
  • Home Assistant: set up automation if IPv6 status sensor changes to “broken”

Here’s the details:

First we need events to be generated if and when the status of our WAN interface (more specifically the IPv6-specific interface named wan6) changes. We can easily and elegantly accomplish this by using the “Hotplug” mechanism built into Linux and OpenWrt. I had to write a script that parses the IPv6 status on changes of the wan6 interface and determines the IPv6 assignment and delegation of a prefix. If these are not available, then the status is “unhealthy.”

Here’s my script which I deployed as /etc/hotplug.d/iface/99-ipv6-monitor:

Categories
Computers deutsch Smart Home

vzlogger an mehrere HA-Instanzen anbinden

Ich habe mir vor einer Weile eine zweite Home Assistant (HA)-Instanz als “Testsystem” angelegt, um neue Integrationen, Updates, etc. zunächst gefahrlos testen zu können, ohne mein Produktivsystem zu gefährden. Dabei hatte ich ein Problem: Mein Stromzähler ist über einen Infrarot-Lesekopf und das Tool “vzlogger” an HA angebunden. vzlogger sendet die Messwerte dabei über das MQTT-Protokoll an den Broker in HA, Mosquitto. Leider kann vzlogger nur eine MQTT-Senke bedienen. Was also tun?

Ganz einfach: Es gibt bei MQTT-Brokern das Konzept der “Bridge“. Ein MQTT-Broker tritt dabei seinerseits als MQTT-Client auf, der sich gegen einen anderen MQTT-Broker verbindet. Er kann dann dorthin Nachrichten senden oder von dort empfangen. Und genau diese Konstruktion habe ich nun genutzt, um die Werte meines Stromzählers durch die Testinstanz aus der Produktivinstanz auszulesen und im Testsystem verfügbar zu machen.