lambchop01 / hassio_ngrok

This custom-component allows to create automatically a ngrok tunnel and keep it open. So, if you are under a CGNAT (no way to have a public IPv4), this custom-component helps to get access to the Home Assistant web interface.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hassio_ngrok

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.

Install

  1. Copy all the ".py" files into your "/config/custom_components/ngrok" folder.
  • Your configuration should look like:
config
  custom_components
    ngrok
      __init__.py
      
  1. Remember to reboot Hassio (or Home Assistant)

Configuration

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:
    1. Linux (ARM) [Default, Raspberry Pi]
    2. Mac OS X
    3. Linux
    4. Mac (32-Bit)
    5. Windows (32-Bit)
    6. Linux (32-Bit)
    7. FreeBSD (64-Bit)
    8. 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'

State

If everything work, you should see under "/lovelace/hass-unused-entities" a new state like this:

ngrok.public_url

Automation

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 }}'      

Debug

To enable debug diagnostics, add this to your configuration.yaml:

logger:
  default: WARNING
  logs:
    ngrok: DEBUG

About

This custom-component allows to create automatically a ngrok tunnel and keep it open. So, if you are under a CGNAT (no way to have a public IPv4), this custom-component helps to get access to the Home Assistant web interface.

License:Apache License 2.0


Languages

Language:Python 100.0%