Home Assistant over s2s VPN

Hi All,

I’m currently playing around with hosting home assistant remotely on a site to site vpn connection which I manage - all is working fine, and Home Assistant can connect to all my entities as if it was on the local network - however can anyone recommend any tuning that needs to take place as although I can see and control all my entities - I have a number of automations which when triggered, fire commands to a large number of entities - for example, turn lights on at sunset (20 devices) - over a mixture of protocols, such as MQTT and direct wifi connections - not all of them successfully fire.

Last night, I had 2 lights over MQTT which didn’t respond - and a Shelly device which never got the message.

I would assume all these messages go via UDP, so Home Assistant just ‘fires and forgets’ - but has anyone else got Home Assistant working nicely over VPN? Latency is approx 11ms.

Thanks
Leacho

I wouldn’t focus on the VPN, if it’s stable.
MQTT is plain tcp.

Check the HA logs, automation traces, and MQTT actual values to debug.

Thanks @koying - I’ve checked the trace and indeed I get the following error when trying to turn off a wifi switch:

Stopped because an error was encountered at 30 August 2021, 21:30:05 (runtime: 5.05 seconds)

Communication error

This is where I assumed that the traffic was UDP, but if its TCP is there any way to get Home Assistant to re-try the attempt? Not sure why the communication was lost - I’ve had no packet loss according to my monitoring.

Thanks
Leacho

If the VPN is set up properly there should be no reason why it won’t work from a network perspective. A VPN basically just expands/connects internal networks over public lines via encryption and encapsulation. As long as routing, DNS, etc. is working properly and nothing is blocked on the way (e.g. by the VPN device, which might also be a firewall) then there should be no reason on this side. There is of course more delay than on local networks and udp/icmp/etc might get dropped by the VPN device when not configured properly.

Why don’t you try staggering the turn ons at sunset? Even if its not what you ultimately want, it might help isolate the error.

Thanks @da_syygy and @nickrout - I think its more the randomness of which devices get messages that worries me - never had an issue when it was running locally - but I will do some more testing over the VPN to see if the issues persist.

Thanks for coming back to me all.
Leacho

Hi All,

Looks like this has been resolved - it looks like the VPN was dropping UDP traffic, so a cheeky little reconfiguration and its all working now as expected.

Thanks
Leacho