TINCANHACKS

Tech and AI work logged from a 1979 Airstream and wherever it's parked.

← index

The Heater Bridge Kept Moving

The diesel heater in the Airstream has a Bluetooth-to-MQTT bridge running on a Raspberry Pi. Home Assistant talks to it through a shell command with the Pi's IP address hardcoded. The Pi was on DHCP. Every time the lease changed, the heater integration broke. It had been .246. Then it was .240. The watchdog dutifully reported host_unreachable while the heater itself was fine.

On September 8 we gave it a permanent address, 192.168.50.10. The part that's easy to get wrong: you're changing the IP of the machine you're currently SSH'd into. Kill the connection mid-apply and you're on the couch with a laptop.

# migrate-static.py, condensed. host() runs the command on the Pi
# via ssh through the HA container, using the old address.
host('sudo arping -D -I eth0 -c 4 192.168.50.10')  # duplicate check first
host('sudo mkdir -p /root/heater-network-backup; '
     'sudo cp -a /etc/NetworkManager/system-connections '
     '/root/heater-network-backup/')
host('sudo nmcli connection modify <uuid> ipv4.method manual '
     'ipv4.addresses 192.168.50.10/24 ipv4.gateway 192.168.50.1')
host('sudo systemd-run --unit=heater-ip-apply --on-active=3 '
     '/usr/bin/nmcli connection up <uuid>')

That last line is the trick. The new address goes live on a three-second timer instead of inline, so the SSH session answering us survives its own network going away.

Then the follow-through. The HA config and the watchdog script both had the old address baked in. The update script asserted the old string was present, saved a .before-static-ip copy, and only then swapped it. For SSH trust it copied the authenticated host key from the old address rather than accepting a fresh network keyscan, which is the paranoid and correct move. The router side got handled in the same session: log into the Peplink, exclude .10 from the DHCP pool so nothing hands it out twice.

Verification was a small script that queried the HA API for the diesel sensor entities. Live status arriving about every two seconds, HA showing Standby, room 68F, watchdog healthy. No heater commands issued, no power cycling. The one honest gap in the notes: the duplicate-address check passed, but the router's DHCP exclusion wasn't confirmed at migration time.

The heater didn't notice. That was the goal.