elad-bar / ha-edgeos

Integration with EdgeOS (Ubiquiti)
132 stars 24 forks source link

Sensor 'unknown_devices' only increases but never decreases #154

Open basstp opened 5 months ago

basstp commented 5 months ago

After a recent update of ha-edgeos (i sadly don't know which version i was using previously), the sensor 'unknown_devices' does not decrease any more.

Details

When a DHCP lease is given out, the sensor increases as it should (for example from 0 to 1). When the client leaves the network the sensor however stays at 1 and does not go back to 0. This is also true with multiple devices (the sensor goes from 1 to 2, but never back to 1). I can however get the sensor back to the correct value by reloading the integration.

Currently using ha-edgeos 2.1.7, my edgerouter x is at version 2.0.9-hotfix.7

I already tried reinstalling ha-edgeos via HACS but that did not seem to help.

Debug logs

I poked around in the debug logs and found that the info seems to be retrieved correctly from the edgerouter, but the sensor 'unknown_devices' doesnt update correctly.

Here are some snippets from the debug log. I initially had 0 clients connected, then 1 client:

Snippet of debug log ```` ... "dhcp_stats": { "dhcp-server-stats": { "TEMP-Main": { "pool_size": "100", "leased": "0", "available": "100" }, "Gast-DHCP": { "pool_size": "20", "leased": "1", "available": "19" } } }, "dhcp-leases": { "dhcp-server-leases": { "TEMP-Main": "", "Gast-DHCP": { "10.1.8.21": { "expiration": "2024/06/06 21:52:30", "pool": "Gast-DHCP", "mac": "**:**:**:**:**:**", "client-hostname": "*************" } } } }, "lastUpdate": "2024-06-06T23:51:51.613939" ... "System": { "host-name": "edgerouterx", "time-zone": "Europe/Berlin", "ntp": { "0.ubnt.pool.ntp.org": null, "1.ubnt.pool.ntp.org": null, "2.ubnt.pool.ntp.org": null, "3.ubnt.pool.ntp.org": null }, "hwnat": true, "dpi": true, "export": true, "dhcp-server-leases": 1, "level": "operator" } ... { "disabled": false, "disabled_by": null, "entity_category": null, "device_class": null, "original_device_class": null, "icon": null, "original_icon": "mdi:help-network-outline", "unit_of_measurement": "Devices", "state": { "entity_id": "sensor.edgerouterx_unknown_devices", "state": "1", "attributes": { "state_class": "measurement", "10.1.8.21": "**:**:**:**:**:** (*************)", "unit_of_measurement": "Devices", "icon": "mdi:help-network-outline", "friendly_name": "EDGEROUTERX Unknown Devices" }, "last_changed": "2024-06-06T21:38:44.756282+00:00", "last_reported": "2024-06-06T21:38:44.756282+00:00", "last_updated": "2024-06-06T21:38:44.756282+00:00" } }, ... ````

When the client disconnects I now should have 0 clients again, but the sensor still thinks the client is there:

Snippet of debug log ```` ... "dhcp_stats": { "dhcp-server-stats": { "TEMP-Main": { "pool_size": "100", "leased": "0", "available": "100" }, "Gast-DHCP": { "pool_size": "20", "leased": "0", "available": "20" } } }, "dhcp-leases": { "dhcp-server-leases": { "TEMP-Main": "", "Gast-DHCP": "" } }, "lastUpdate": "2024-06-06T23:53:52.590464" ... "System": { "host-name": "edgerouterx", "time-zone": "Europe/Berlin", "ntp": { "0.ubnt.pool.ntp.org": null, "1.ubnt.pool.ntp.org": null, "2.ubnt.pool.ntp.org": null, "3.ubnt.pool.ntp.org": null }, "hwnat": true, "dpi": true, "export": true, "dhcp-server-leases": 0, "level": "operator" } ... { "disabled": false, "disabled_by": null, "entity_category": null, "device_class": null, "original_device_class": null, "icon": null, "original_icon": "mdi:help-network-outline", "unit_of_measurement": "Devices", "state": { "entity_id": "sensor.edgerouterx_unknown_devices", "state": "1", "attributes": { "state_class": "measurement", "10.1.8.21": "**:**:**:**:**:** (*************)", "unit_of_measurement": "Devices", "icon": "mdi:help-network-outline", "friendly_name": "EDGEROUTERX Unknown Devices" }, "last_changed": "2024-06-06T21:38:44.756282+00:00", "last_reported": "2024-06-06T21:38:44.756282+00:00", "last_updated": "2024-06-06T21:38:44.756282+00:00" } }, ... ````

(I have replaced my MAC address and hostname with *** for privacy reasons.) You can see that the information is retrieved correctly:

However the sensor.edgerouterx_unknown_devices still shows the client.


I hove I have given enough information to hunt down this bug. Thanks! :)

Mark79864 commented 5 months ago

Same issue I'm having. Glad I'm not the only one.

illuzn commented 4 months ago

Fixed in #156