I have a router made by Gl-inet. Their routers run a modified version of OpenWRT. As part of their modification they have a very full featured API, everything from client lists to VPN status. It even accepts POSTS to change many states.
VPN control (OVPN, WG, ShadowSocks)
LTE Modem control incl SMS
Client lists
Firewall and port forwarding
Public IP
BLE controller
I am thinking about developing an integration for these routers. However I’m not sure where to start. One could certainly use it for presence detection as a start.
What class of device would it be? Local polling? Or best to build several separate integrations for the different functions?
There is no python library for the API - should I start there?
Can anyone point me in the direction of an integration that has done something similar so I can know where to start?
Edit: I have now made a first draft that does device tracking only.
Depends on your final goal, if you want to push your integration into core home assistant, pypi based python library is a must. If you are fine to stick with hacs, you can embed the api into integration. I am lazy and usually going with second approach.
Regarding multiple entities vs multiple integrations, you can go with one integration and multiple sensors/entities and users can always disable the ones they don’t need.
Hi HarvsG
Great stuff - I have a small island in the Bahamas and I use the GliNet 750v2 as a failure internet device. I love the GliNet devices - they are great! Would love to be able to send sms from it, as it is presently my failover of my ptp net connection to the mainland (main island). Would love to test it out as I leave for the island on Thursday and will be there for 4 weeks.
Assuming you have python 3.8 get started with from gli_py import GLinetmy_router = GLinet("YOUR_ROUTER_PASSWORD", base_url="http://192.168.8.1/cgi-bin/api/")
@wreuvers I would appreciate any errors you get with the SMS functions, my router doesn’t have a modem at the moment so I haven’t been able to test it.
I do not have a python environment setup, although it is something on my long string of things I need to learn. Once your integration is ready to be used in HA, even if not stable, I’d love to help test it. And if you are ever in the Bahamas (the Abacos), you are welcome to spend a few days on our island - it’s paradise with a bunch of cool tech stuff
Hi, wow that sounds amazing!! The integration is now working (for me) so is ready to test. You can copy the files to your custom configuration file. You will also have to edit manifest.json to have a version number. Then you should be good to go.
Hi HarvsG
I have only ever installed via HACS. So I gave this try by creating a folder in custom_components called gli_py, added the files to it, and added a new manifest.json which I edited. How do I “access” it? or Use it?
Thanks
Wayne
Fine - ish. There was an update to a dependency for the python package which broke it. So I have have to downgrade uplink to 0.9.5 every time I update HA.
I have not tested OpenWRT integration with Glinet products. And since a recent version it doesn’t come with LUCI out of the box but there is a one-click install. At the very least if you were to flash Beryl with a pure OpenWRT it would work.
Do report back with your success/failure.
I started developing this not for precedence detection - already sorted with the luci integration (or so I hope) but more to develop VPN and connection controls in future