Can you use ESPHome devices outside your WiFi network?

Hello all,

I can’t find the answer to this question anywhere:
Is it possible to use Esphome when it is not connected to the same WiFi as Home Assistant is running on?

I would like to monitor the energy usage of my vacation home. At first I thought it should be a piece of cake getting it to connect to Home Assistant running in my primary home. But I’m starting to get the feeling it is actually not possible. Am I overlooking something?

As an alternative I’ve been looking into doing it using mqtt instead. I have a test setup running now and Mosquitto is receiving the messages sent from the Esp8266. But I’m stuck on how to actually turn that into a HA sensor that I can use for Energy Monitor.

Could someone point me into the right direction for my requirements? Can it be done with Esphome + DSMR component? Or do I need to use mqtt?

I have nearly 10 years of experience with Arduino and have been using the ESP8266 ever since it came out. But Home Assistant and MQTT is new to me.

Thanks in advance!

1 Like

If using the API the esphome device serves on port 6053. Tunnel that port through a VPN and it should be fine.

For MQTT, it should just work out of the box. Do you have discovery turned on discovery in your HA MQTT integration.

VPN is the answer, but there are several types of VPN setup.
You can connect a client to a single host, a client to a network, a network to a network.
The connection is going through the internet, but VPN makes it so that the connection could be considered your own network cable between the two parts.

Some of the VPN setups have special requirements like certain ports or protocols that needs to be supported by the network devices, both at your ends and at the ISPs parts that lay between those ends.

VPN is not a home assistant specific topic, so if you have discussion or support sites for your locel ISPs, then they might be better to provide you with info to what you can can’t do with VPN on your specific setup adn what type VPN you should choose.

1 Like

I will look into that tunneling vpn option. Sounds like “Hamachi” I used in my teen years to trick games into thinking me and my friends were on the same LAN (and thus not needing a valid CD-key =p).

It seems like the easiest way to achieve what I want. I’ll tinker with it. Thanks for the hint!

Hamachi is a VPN, so yes. :slight_smile:

Hamachi was like magic! VPN without port forwarding.

Its a sort of a special type of setup, because both ends make an outgoing VPN connection to a website, which then links those two connections together.
Outgoing connections are generally allowed through the firewall and NAT setups, so its easy.

The VPN you are looking should probably be a setup without that middleman, since its both a security risk and a potential cause for failures.
It makes it a bit more complicated to setup, but the end result is better for the current case.

An update:

I didn’t get the VPN option to work. I simply don’t understand it well enough yet. From what I have googled, the esp8266 is not powerful enough to handle VPN encryption/decryption. So I guess that is why you said it should be a site-to-site vpn. But as far as I understand it, that would make all the Internet traffic from Home 1 be routed through Home 2. And I don’t want that. I only want the traffic between the esphome in Home 1 and the HA Pi in Home 2 to be connected.

I did get it to work by simply forwarding the ports 8266 and //esphomeport// to the ip-address of the ESPHome and using the “use_address” config option to point to a duckdns domain. But as I understand it this is considered unsafe? What are the risks I am exposing myself to this way?

Thanks!

The amount of data exchanged between the two sites connected with a VPN can usually be controlled with the firewalls.
You might also have a VPN option in your router/firewall that can make that VPN connection.

With your current setup you might have open you internal network somewhat to the internet.
It depends on your firewall configuration.
The risk is that your server has or might get security holes that now can be exploited.
If you do decide to use the current setup, then atleast minimize it to the single port and even better limit it to the remote homes IP, if possible. A static IP for the remote home would be preferable for this.

Any solution yet?

Read the thread, the answer is there.

1 Like

Why not use a public MQTT broker?