rmoesbergen / openwrt-ha-device-tracker

OpenWRT device tracker for Home Assistant that actually works
107 stars 18 forks source link

Installed Version - Feature Request #33

Closed walberjunior closed 1 year ago

walberjunior commented 1 year ago

I would like to have a way to track the current version installed on the router.

Maybe create a sensor inside the HA containing the "ap_name" - "Version" And maybe a parameter inside presence-detector.settings.json to disable this option for those who don't want it:

   "version": false/true
rmoesbergen commented 1 year ago

It seems possible to create a device+entity in HA through the REST api. I'll look into it when I have more time.

rmoesbergen commented 1 year ago

@walberjunior This has been added to the latest version in main. The entity name in HA will be .presence_detector_version. If ap_name is not set, it will default to "openwrt_router"

walberjunior commented 1 year ago

Thanks

image

dckiller51 commented 1 year ago

@rmoesbergen I tested this version but got an error.

Sat Oct 14 12:07:53 2023 daemon.err presence-detector.py[13849]: Exception in thread Thread-1:
Sat Oct 14 12:07:53 2023 daemon.err presence-detector.py[13849]: Traceback (most recent call last):
Sat Oct 14 12:07:53 2023 daemon.err presence-detector.py[13849]:   File "/usr/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
Sat Oct 14 12:07:53 2023 daemon.err presence-detector.py[13849]:   File "/etc/config/presence-detector.py", line 229, in run
Sat Oct 14 12:07:53 2023 daemon.err presence-detector.py[13849]:     self._update_version_entity()
Sat Oct 14 12:07:53 2023 daemon.err presence-detector.py[13849]:   File "/etc/config/presence-detector.py", line 216, in _update_version_entity
Sat Oct 14 12:07:53 2023 daemon.err presence-detector.py[13849]:     response, ok = self._post(
Sat Oct 14 12:07:53 2023 daemon.err presence-detector.py[13849]:                    ^^^^^^^^^^^
Sat Oct 14 12:07:53 2023 daemon.err presence-detector.py[13849]:   File "/etc/config/presence-detector.py", line 105, in _post
Sat Oct 14 12:07:53 2023 daemon.err presence-detector.py[13849]:     with request.urlopen(req, timeout=5) as response:
Sat Oct 14 12:07:53 2023 daemon.err presence-detector.py[13849]:          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sat Oct 14 12:07:53 2023 daemon.err presence-detector.py[13849]:   File "/usr/lib/python3.11/urllib/request.py", line 216, in urlopen
Sat Oct 14 12:07:53 2023 daemon.err presence-detector.py[13849]:   File "/usr/lib/python3.11/urllib/request.py", line 525, in open
Sat Oct 14 12:07:53 2023 daemon.err presence-detector.py[13849]:   File "/usr/lib/python3.11/urllib/request.py", line 634, in http_response
Sat Oct 14 12:07:53 2023 daemon.err presence-detector.py[13849]:   File "/usr/lib/python3.11/urllib/request.py", line 563, in error
Sat Oct 14 12:07:53 2023 daemon.err presence-detector.py[13849]:   File "/usr/lib/python3.11/urllib/request.py", line 496, in _call_chain
Sat Oct 14 12:07:53 2023 daemon.err presence-detector.py[13849]:   File "/usr/lib/python3.11/urllib/request.py", line 643, in http_error_default

presence-detector.settings.json

{
  "hass_url": "http://192.168.2.XXXXX",
  "hass_token" : "hide",
  "interfaces": ["hostapd.phy0-ap0", "hostapd.phy1-ap0", "hostapd.phy2-ap0"],
  "filter_is_denylist": true,
  "filter": [""],
  "params": {},
  "ap_name": "WifiAP-02",
  "location": "home",
  "away": "not_home",
  "fallback_sync_interval": 60,
  "debug": false
}