This custom-component allows to create automatically a ngrok tunnel. So, if your Home Assistant server is behind a CGNAT (no way to have a public IPv4), this custom-component helps to get access to the Home Assistant web interface.
- Copy all the ".py" files into your "/config/custom_components/ngrok" folder.
- Your configuration should look like:
config
custom_components
ngrok
__init__.py
- Remember to reboot Hassio (or Home Assistant)
Add your Ngrok details to configuration.yaml
- auth_token [Mandatory] copy here the auth token assigned by ngrok
- os_version [Mandatory] you can choose from:
- Linux (ARM) [Default, Raspberry Pi]
- Mac OS X
- Linux
- Mac (32-Bit)
- Windows (32-Bit)
- Linux (32-Bit)
- FreeBSD (64-Bit)
- FreeBSD (32-Bit)
- ip_address [Mandatory] the local ip addreess (e.g. 192.168.x.y)
- port: [Mandatory] the local port (e.g. 8123)
- protocol: [Mandatory] http or https
- scan_interval: [Optional] seconds between two consecutive checks of ngrok configuration. Default is 60 seconds.
- install_dir: [Optional] directory where ngrok will be installed. Default is '.ngrock'
Your configuration should look like:
ngrok:
auth_token: !secret ngrok_auth_token
os_version: 'Linux (ARM)'
ip_address: !secret ngrok_ip_address
port: !secret ngrok_port
protocol: 'http'
If everything work, you should see under "/lovelace/hass-unused-entities" a new state like this:
How to be informed once your Home Assistant get a public url?
- The best way is to create an automation that sends a Telegram message, as soon as Home Assistant gets a public url or when it changes.
- To enable it, you need first to activate the Telegram component;
- Then, edit your automations.yaml file:
- alias: "Ngrok Public URL"
hide_entity: true
initial_state: 'true'
trigger:
platform: state
entity_id: ngrok.public_url
action:
- service: notify.telegram
data:
title: '*Server*'
message: 'Current public url: {{ states.ngrok.public_url.state }}'
To enable debug diagnostics, add this to your configuration.yaml:
logger:
default: WARNING
logs:
ngrok: DEBUG