I’m trying to set up Home Assistant for my campervan and have it work in a variety of weird connectivity situations.
Here’s the basic setup in my campervan:
4G router providing Wifi network and Internet access (currently using hotspot on an old Android phone)
Raspbbery Pi 4 running HA
ESP32 ESPHome node running sensors, switches, Bluetooth proxy etc.
Here are some scenarios I want to cover:
Everything running as per above in a local network, connected to the Internet - easy
Everything running as per above in a local network, but without Internet (when I’m with my campervan in remote areas with no 4G coverage)
When I’m not using my campervan and it’s parked at home, I want to move the Raspbbery Pi to my house because it drains too much power and will deplete my battery (it doesn’t get enough solar charging when parked at home during winter). In this case, the ESPHome node and Raspberry Pi with HA will be running in different local networks, but both connected to the Internet.
So the challenge is to set up some infrastructure so that both scenario 2 and 3 can work without updating any configuration. I can forward ports or use some other remote servers that I have online to bridge the connections, but the problem seems to be to configure ESPHome try to connect both locally or over the Internet.
Some ideas I have:
Set up Wireguard on the ESPHome so that it can create a network with HA either over Internet or in the same local network. Can I configure Wireguard to attempt a local connection first, falling back to doing it over the Internet if fails?
Similarly, I can try to setup an MQTT broker, with the ESP node trying to connect locally at first, falling back to doing over the Internet if it fails. Can ESPHome be configured to try multiple MQTT broker addresses?
Maybe I can solve either of the above on the DNS level. Have some DNS query that returns both the Internet IP and a local network IP, connecting the either one (ideally it would prioritize the local one). Is this something I can do on a rooted Android with hotspot? Would need to work without Internet access too.
Run some sort of load balancer on the Android device for Wireguard / mqtt which would attempt to route connections first locally, falling back to Internet.
I have 2 networks defined 1 for “home pc’s” 1 for HA
for example 10.10.10.x for home with 10.10.10.1 being the gateway 10.10.11.x = HA and esp node(s)
on the router(s) you need to define a route to both lan’s so 10.10.10.x device can talk to 10.10.11.x (both ways)
the networks part allows multiple wifi hotspots to be define(d)
An total different way would be to add RTC modules and battery voltage measurement(s) and just shutting down when the batttery is near empty (sending an allert) only to wake at intervalls (and check if an update is waiting if power is sufficiantly available)
you could also trigger (low)power mode when your home wifi is in reach (geofencing)
I know there are other solutions with these kinds of (2nd) home situations … just search (i don’t have one)
Having to (manually) change use_address is exactly what I’m trying to avoid.
I like your RTC module idea (taken a quick look at WittyPi / Sleepy Pi), will do some more research on it. It does have an unfortunate side effect of not having HA always online, but does elegantly solve other problems instead (built-in 5v source, keeping it on in case of battery reserve, current sensor).
You mentioned low-power mode when home, I thought the Pi doesn’t have any low-power / hibernation capabilities. Do you mean something specifically, or just trying to save power by any means possible?
first off just be aware I am not implying you should lose functionality in anysense but having a MOSCOW list (acronym for Must have, need to have and nice to have list)
use_address is intended as a once in a blue moon use case.
I hope you are triggered to re-evaluate the power drain in general, if you use esp node(s) in the mobile thing, it might be more usefull to run telephone cable from device to device with the rs485 or canbus protocol (just examples) instead of using wifi, there is even BLE or LORA
RTC just means in this case instead of running days on 4W because you measure every minute, one switches to every 15min to hour intervals extending the use time of the same 4W. there are always trade-offs.
for RPI i really don’t know if they can hibernate, but HA is not intended to “sleep” so maybe a you need to do a work around to reduce power needs or switch to an alternative solution, the most crude solution is to power down and have an esp32/arduin (at-tiny) do a wakeup (powerbutton press) every 12 hours… and shutdown after an hour ?
Anyway there are more mobile users with same situation