Accessing HA data from outside of home network?

Hi all, I’ve recently installed and set up HA on a Raspberry Pi to monitor solar, battery, thermostat and some smart power strips. I’m gradually getting a handle on how the system works.

I have a project in mind which would require monitoring my solar stats to trigger some actions on a web server. I wondered what setup people recommend to access HA data from outside of my LAN? (Actually, as I’m writing this, I’m guessing I should be able to access an API from my Sigen or Envoy accounts, which are already in the cloud, and which I use in HA for monitoring solar. But I am interested in other HA stats too, potentially.)

A google search shows some options for using HA remotely. I would prefer not to have another subscription account (Nabu Casa), so interested to hear what other means people are using to access HA, and particularly its API, remotely.

HA has a rest api which I use to get some weather events. You add them to your configuration.yaml.

sensor:
  - platform: rest
    resource: https://mywebsite.com/api.php
    unique_id: '1767353573409'
    name: "Attic Temperature"
    value_template: "{{ value_json.attic_temp }}"
    unit_of_measurement: "°C"
  - platform: rest
    resource: https://api.open-meteo.com/v1/forecast?latitude=25.0633&longitude=32.7475&current=wind_speed_10m,wind_gusts_10m&forecast_days=1
    unique_id: '1767455273123'
    name: "Wind Speed"
    value_template: "{{ value_json.current.wind_speed_10m }}"
    unit_of_measurement: "km/h"
  - platform: rest
    resource: https://api.open-meteo.com/v1/forecast?latitude=25.0633&longitude=32.7475&current=wind_speed_10m,wind_gusts_10m&forecast_days=1
    unique_id: '1767455563254'
    name: "Wind Gusts"
    value_template: "{{ value_json.current.wind_gusts_10m }}"
    unit_of_measurement: "km/h"

EDIT: Sorry - I see you’re looking for the other way around. You can use webhooks. I’ve never tried it, so I can’t really help.

1 Like

There are two APIs you can use:

  1. REST API | Home Assistant Developer Docs

  2. WebSocket API | Home Assistant Developer Docs

I use a VPN.

Thanks for this… I was wondering about how to access my Raspberry pi, which is just running in my home LAN, from a web server which is outside the LAN. I guess I have to assign the Pi a fixed IP and expose it to the web via my router? I will look into it.

OK, does that give your local network a web-facing IP somehow? Does it require paying for a VPN service? Thanks, just getting up to speed with this.

Edit: nevermind, I managed to completely misunderstand the request :smile:

Secure Home Assistant Remote Access with DuckDNS and NGINX (Step-by-Step)

If you want to avoid exposing a port for HA, you could use Webhooks as Tom mention, with that you can send from HA, to the other websever, which then need a Service or App to handle Webhooks. So big question is Are you admin on that webserver, and allowed to fix the required installation there, or you just want to “feed” an API , etc ?

My router can act as a VPN server. So I have configured it to act as a VPN server. My router can also register with a DDNS service - this essentially give a hostname that resolves to the internet facing IP address of the router. On my phone I configure the VPN client using the hostname from the DDNS provider and then enter the super long shared encryption key. Then when I activate the VPN on the phone, it works like the phone is on my local WiFi.

1 Like

Look at Zerotier.
ZeroTier is a virtual network that lets your devices—anywhere in the world connect as if they were on the same LAN.

Hi, Which VPN server do you have options to run in your Router ?

It has OpenVPN

Ok, I have also +4 four choice, but some of them actually requires a VPN Account, and some even a “local” installed server

I also did find that OpenVPN Or IPSec was the Way to go, as WireGuard And in Particular PPTP Was Not good choices

Thanks for all the suggestions, I haven’t had a chance to follow up on this yet but will post an update if I have results to report.