Skip to content

Treat messages from unknown devices as implicit joins and discover IEEE addresses #73

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

Merged
merged 5 commits into from
Jul 9, 2021

Conversation

puddly
Copy link
Collaborator

@puddly puddly commented May 30, 2021

Devices that somehow manage to change their NWK address without notifying the coordinator are impossible to contact. Instead of dropping packets from them, we can discover their IEEE address and either update the NWK in zigpy's database or treat the device as a new join.

This allows for ZHA to be started up with a completely "unknown" network and for it to pick up devices as they're used.

@codecov-commenter
Copy link

codecov-commenter commented May 30, 2021

Codecov Report

Merging #73 (ca4572e) into dev (6ce31d7) will increase coverage by 0.01%.
The diff coverage is 98.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev      #73      +/-   ##
==========================================
+ Coverage   98.42%   98.44%   +0.01%     
==========================================
  Files          43       44       +1     
  Lines        3681     3719      +38     
==========================================
+ Hits         3623     3661      +38     
  Misses         58       58              
Impacted Files Coverage Δ
zigpy_znp/zigbee/application.py 96.18% <95.00%> (+0.07%) ⬆️
zigpy_znp/api.py 100.00% <100.00%> (ø)
zigpy_znp/commands/zdo.py 100.00% <100.00%> (ø)
zigpy_znp/utils.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6ce31d7...ca4572e. Read the comment docs.

@puddly
Copy link
Collaborator Author

puddly commented May 30, 2021

Combining this change with the zigpy initialization refactor (zigpy/zigpy#744) let me import most of my network into a fresh HA installation in like 30-40s after "rebooting" my house at the circuit breaker:

image

Aqara quick initialization also works quite well, all of my motion and temperature sensors were instantly initialized after poking the button. In the future it would be interesting to see if the zigpy topology scanner (or maybe some broadcast that every single device can reply to?) can be used to speed this up or automate it, for installations where physically cutting power isn't simple.

@MattWestb
Copy link

Interesting if the router is "rejoining" and ZHA is doing one topography scan and reading the neighbor table of the router then you is getting the coordinator is getting the address of the SED the router is having. The next is then the SED is doing one check in or reporting attribute (if the coordinator have the same IEEE) and the coordinator can configuring them.
The mesh shall living / working after one "master reset" and finding ways around devices that is not working also the coordinator if its is online.

By the way as normal great work done !!!!!

@Adminiuga
Copy link
Contributor

If we implement this at in zigpy, then in ZNP you would need to implement only ZDO_IeeeAddr_req handler?

@puddly
Copy link
Collaborator Author

puddly commented Jun 1, 2021

If we implement this at in zigpy, then in ZNP you would need to implement only ZDO_IeeeAddr_req handler?

Z-Stack for some reason omits the NWKAddrOfInterest field for this specific request (though it's included in most others??) so you can't ask 0x1234 for the NWK address of 0x5678. To be fair, you'd have to know that 0x5678 is a RFD and is a child of 0x1234, so you likely don't need to know its IEEE address.

@Adminiuga
Copy link
Contributor

I was thinking about sending the request directly to the unknown device, since the device just messaged and is listening for the incoming traffic.

Alternatively, could just define a method in zigpy and leave to the radio lib to implement it.

@puddly
Copy link
Collaborator Author

puddly commented Jun 1, 2021

Yeah, that's what my current implementation does. I think it's better to start using more ZDO commands from zigpy. Should allow for energy scanning and stuff like this to be implemented in zigpy instead of duplicated in every radio library.

@puddly puddly force-pushed the puddly/unknown-device-discovery branch from 86c0e3a to ca4572e Compare July 5, 2021 23:20
@puddly puddly merged commit 942b6ee into dev Jul 9, 2021
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.

4 participants