ha-glinet4-integration

A HomeAssistant custom component for GL-inet routers that uses their API version 4.

Working - in alpha, breaking changes very likely.

Contributions are welcome, for ideas see the TODO list below or the various #TODOs in the code.

Features

  • Device tracker for devices connected directly or indirectly to a Gl-inet router.
    • Note, modern phones use MAC address randomisation when they connect to WiFi, you will need to disable this for your home wifi only on android and iphone
  • Control all configured wireguard clients with a switch.

Installation

  1. Create a new folder in config/custom_components called glinet
  2. Copy manually, or clone the files in this repo into that folder git clone https://github.com/HarvsG/ha-glinet-integration.git . (The . at the end is important)
  3. Reboot homeassistant
  4. Add the new Glinet integration under Devices and services
  5. Edit the host path with you router IP - ensure you keep the http://
  6. Add your router admin page login password (not your WIFI password). Placeholder is GL-inet's default goodlife, but this should be changed.

Dev set up

  1. Set up the vscode homeassistant core dev setup
  • Or you could just use a running install of homeassistant (restarts are required for a lot of changes)
  1. Run once to generate directories
  2. create a config/custom_components/glinet directory
  3. git clone https://github.com/HarvsG/ha-glinet-integration.git .
  4. Note, the vscode git tracker will track the parent repo (ha core), but command line git will still work within the glinet dir
  5. You may need to config a new ssh key inside the container. Use this - this will be overwitten if you rebuild the container

TODO

  • Auto detect router IP for config flow - assume it is the default gateway, test an enpoint that doesn't require auth (/model or /hello), fallback to default 192.168.8.1
  • Add switches for wireguard and open vpn (client and server), done for wireguard client, but we can probably do all programatically rather than repeating boilerplate
    • worth considering you can have multiple clients, most of the API endpoints act on the last used client config. Can we get a list from the API and create switches for all? Maybe (router/vpn/status?)
  • Support HACS - lets get some more features working first
  • Allow deletion of unhelpful device tracker devices/entities, docs, example
  • Clean, comment and refactor code
  • Add tests - will need to mock the API
  • Allow reconfig for password changes - currently have to delete and re-add integration
  • Look into using https instead of http
  • Add features:
    • Upload/Download sensors
    • Internet reachable sensors (remember that API timesout when internet not reachable)
    • Public IP sensor
    • Diagnostic sensors for stats in (/router/status) such as uptime, LAN IP and memory useage
  • Consider features

Tested on

  • Beryl MT3000
  • Convexa B1300

Depends on

https://github.com/HarvsG/gli4py