We have just bought ourselves a static caravan and sited it about one hour drive from home - so it is close enough to go there if something needs doing, but not so close that we would call around every couple of days to check on it.
So I wanted a technological solution to allow me to monitor how it is, and in the winter tell it to put the heating on when we set off to go to it, so it is nice and warm when we get there.
The approach I have taken is:
- Do not rely on the caravan park's internet access, as this is reported to be quite unreliable
- I am using an old mobile phone with a Lebara sim (£5 per month for 5GB data).
- It runs as a mobile hotspot so that several devices can connect to it if necessary - I had to go into the android advanced settings for the hotspot to prevent it switching off after a short time with no devices connected (otherwise an electrical supply interruption can result in us losing communications, even when supplies are restored).
- This works very well - we have good wifi reception from the phone, even with it in the cupboard at the back of the caravan.
- Use a low power computer running Home Assistant to do monitoring and control.
- I had a Raspberry Pi Model 3B available so am using that - it draws about 2W during normal operation. It has the following main hardware and software components.:
- Sonoff Zigbee USB dongle (so I can use low cost battery powered zigbee devices)
- Home Assistant (run as a docker image)
- Mosquitto MQTT broker (run as a docker image). This also utilises a bridge to a MQTT broker on a remote server so I can publish caravan data to my home system periodically.
- Zigbee2mqtt (run as a docker image) to interface with Home Assistant (I am trying to standardise MQTT as my default way of communicating between small devices, rather than reinventing my own http based protocol each time). The configuration file for the mosquitto instance is mosquitto.conf.
- Create a VPN so that I can log into the caravan computer from home to change its configuration when I am not there.
- Caravan Server Configuration
- Use Docker Compose to set up the HomeAssistant, Zigbee2mqtt and Mosquitto containers, see the compose file docker-compose.yaml. Start with 'docker compose up -d' (the -d starts it as a daemon process so releases the terminal). Check they are running with 'docker container ls.'
- VPN Configuration
- The caravan server is behind a mobile phone network, so I can not just SSH into it. Instead I created a VPN using wireguard. A remote server acts as a hub and the caravan server and any other computers connect to that hub. Other computers can then SSH to the caravan server.
- This was much more difficult to get working than I had expected... Two particularly useful tutorials were one from Digital Ocean and ArchLinux.
- The big mistake I made was setting the AllowedIPs for both the Caravan and my Laptop Peers to have /24 netmask specifications. This meant that they were both asking for IPs in the range 10.0.1.0-255. So one worked and the other didn't. Setting the netmask specification to /32 instead meant that they only asked for their single specific IP address. So now I can ssh to the caravan server from my laptop, with the remote server acting as a bridge.
No comments:
Post a Comment