Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 2 bugs with Unknown Devices Sensor #156

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

illuzn
Copy link

@illuzn illuzn commented Jul 5, 2024

Addresses issues #154 and #153.

Unknown Devices Logic

https://github.com/illuzn/ha-edgeos/blob/cc9678c575eea992d070038aa6cb4d0e7ec94a2a/custom_components/edgeos/data_processors/device_processor.py#L146-L208

The _update_leased_devices and _set_devices logic was incorrect.
When a device first connects (or the integration is loaded), it will be added to the _devices variable as connected. For all such existing devices, the is_leased attribute does not change e.g. if it disconnects then _set_devices is not called and it remains in the list of _devices with is_leased set to True.

This corrects that logic by:

  1. When _update_leased_devices is called, all _devices set is_leased to False.
  2. When set_devices is called:
    (a) if it is a new device it is added as normal; or
    (b) if it is an existing known device (e.g. a device connects, disconnects then reconnects some time later), the existing data is used with is_leased set to true.

I considered the possibility to simply delete the entirety of _devices using for example clear() but decided against it since that might give rise to further issues.

Unknown devices leased attribute

During the refactor, the dict leased_devices was erroneously written directly to attributes instead of under the subkey leased (which corresponds to the CONST DHCP_SERVER_LEASED) .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant