Skip to main content

Remote Access

Remote access to Home Assistant allows you to control your smart home from anywhere, increasing security and efficiency. Setting it up through services like Home Assistant Cloud or Cloudflare Tunnel ensures easy and secure connection without complex configuration.

HA remote

Configuration Options

There are three main methods for setting up remote access to Home Assistant, each with its specific pros and cons. Your choice should depend on your preferences regarding user-friendliness, cost, security, and other factors. The following table provides a quick overview of these methods:

MethodUser-FriendlinessCostOwn Domain RequiredSupports HA DevelopmentConfiguration ComplexitySecurity
Home Assistant CloudVery HighPaid
(7.5EUR / month)
LowHigh
Cloudflare TunnelHighFree (with upgrade options)MediumHigh
Public IP and PortsLowFreeHighVariable

1. Home Assistant Cloud (Nabu Casa cloud)

This method is the most user-friendly and directly supports the development of Home Assistant through your service payment. You don't need to worry about obtaining your own domain, as the service provides you with an address using their domain.

2. Cloudflare Tunnel (part of Cloudflare Zero Trust)

Recommended for those who want to set up remote access themselves, offering a free solution with upgrade options. It requires you to have your own domain.

3. Public IP Address and Port Exposure (HTTP/HTTPS)

This method is the most complex and requires the most technical knowledge. It provides the most control, but security is variable and depends on proper configuration and adherence to security practices.

Cloudflare Tunnel

Free or not?

If you need to set up Home Assistant on a subdomain like ha.subdomain.domain.com, unfortunately, the basic version of Cloudflare won't suffice, and you'll need to prepare $10 / month.

Cloudflare Account and Domain

  • Create an Account: First, you need to create an account with Cloudflare. Instructions for registration can be found here.
  • Domain Setup: You need a domain managed through Cloudflare DNS. Detailed steps are here.
  • Automatic DNS Records: Manual addition of DNS records is not necessary; everything is set up automatically using the HA Cloudflare Tunnel add-on.

Installing the Cloudflare Tunnel Add-on

  • In Home Assistant, go to Settings -> Add-ons -> Add-on Store.

  • Click the three dots in the top right corner and select Repositories.

  • Add the repository: https://github.com/brenner-tobias/ha-addons

    Home Assistant - Cloudflare addon

  • After adding the repository, you should be able to find the Cloudflare Tunnel add-on in the add-on store. Click on it and then on Install.

    Home Assistant - Cloudflare addon

  • After installation, open the add-on settings and fill in External Home Assistant Hostname with the desired address.

    Home Assistant - Cloudflare addon

    info

    Optionally, you can set the parameter Additional Hosts, which allows adding other services through the same tunnel. The condition is that they must be on the same network.

  • Save changes in the configuration and restart the add-on.

    -----------------------------------------------------------
    Add-on: Cloudflared
    Use a Cloudflare Tunnel to remotely connect to Home Assistant without opening any ports
    -----------------------------------------------------------
    Add-on version: 4.2.10
    You are running the latest version of this add-on.
    System: Home Assistant OS 11.1 (amd64 / qemux86-64)
    Home Assistant Core: 2023.11.1
    Home Assistant Supervisor: 2023.10.1
    -----------------------------------------------------------
    Please, share the above information when looking for help
    or support in, e.g., GitHub, forums or the Discord chat.
    -----------------------------------------------------------
    [16:29:53] INFO: Checking add-on config...
    [16:29:53] INFO: Checking for existing certificate...
    [16:29:53] NOTICE: No certificate found
    [16:29:53] INFO: Creating new certificate...
    [16:29:53] NOTICE:
    [16:29:53] NOTICE: Please follow the Cloudflare Auth-Steps:
    [16:29:53] NOTICE:
    Please open the following URL and log in with your Cloudflare account:

    https://dash.cloudflare.com/argotunnel?aud=&callback=https%3A%2F%2Flogin.cloudflareaccess.org...

    Leave cloudflared running to download the cert automatically.
  • Click through to add to the correct domain, and a new tunnel should appear - you can check in the Cloudflare menu Zero Trust -> Access -> Tunnels.

    Cloudflare tunnel

  • Check the add-on log to ensure everything went smoothly

    ...
    Created tunnel homeassistant with id 1cd49b62-xxxx-xxxx-xxxx-xxxxxxxxxx
    [17:28:21] INFO: Checking for existing tunnel...
    [17:28:21] INFO: Existing tunnel with ID 1cd49b62-xxxx-xxxx-xxxx-xxxxxxxxxx found
    [17:28:21] INFO: Checking if existing tunnel matches name given in config
    [17:28:21] INFO: Existing Cloudflare Tunnel name matches config, proceeding with existing tunnel file
    [17:28:21] INFO: Creating config file...
    [17:28:22] INFO: Validating config file...
    Validating rules from /tmp/config.json
    OK
    [17:28:22] INFO: Creating DNS entry ha.your-domain.com...
    2023-11-07T16:28:23Z INF Added CNAME ha.your-domain.com which will route to this tunnel tunnelID=1cd49b62-xxxx-xxxx-xxxx-xxxxxxxxxx
    [17:28:23] INFO: Creating DNS entry ha-test.your-domain.com...
    2023-11-07T16:28:24Z INF Added CNAME ha-test.your-domain.com which will route to this tunnel tunnelID=1cd49b62-xxxx-xxxx-xxxx-xxxxxxxxxx
    [17:28:24] INFO: Finished setting up the Cloudflare Tunnel
    tip

    As you can see in the log above, the tunnel is created for two instances of Home Assistant - this is possible. It is useful, for example, if you have a test environment.

  • You will need to edit the configuration.yaml file and add the trusted_proxies section

    configuration.yaml
    http:
    use_x_forwarded_for: true
    trusted_proxies:
    - 172.30.33.0/24
  • Restart Home Assistant and try to log in using the new address https://ha.your-domain.com

Comments