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

Add support for subscribing to updates by device MAC #327

Merged
merged 4 commits into from
Jan 22, 2023
Merged

Conversation

thecode
Copy link
Contributor

@thecode thecode commented Jan 8, 2023

Add options to subscribe for updates using device MAC (device ID)
Subscribing using device ID will help to support devices behind NAT, proxies, or if device IP changes
Implementation is backward compatible and allow subscribing for updates either by MAC or device IP, we can later drop the support for subscribing by IP.

Closes #182

Gen1:

  • CoAP contains the device ID in CoAP option 3332, for this parsing of options was added, logic for parsing options is based on https://github.com/chrysn/aiocoap/blob/master/aiocoap/options.py
  • For compatibility with older Gen1 devices that only include the last 6 chars of MAC, comparison only compare the last 6 MAC chars

Gen2:

  • Device ID is sent on every frame as src

Checked on multiple Gen1/Gen2 devices with various firmware versions for Gen1.
Update example.py to test subscribing by MAC, for testing with debug enabled:

python example.py --ip 192.168.1.75 -i -deb -m "ABCDEF123456"

@bdraco
Copy link
Member

bdraco commented Jan 18, 2023

All my Shelly Plus Plug US work fine with this change

Copy link
Collaborator

@bieniu bieniu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1L and Plug S work fine, looks good 👍

@thecode
Copy link
Contributor Author

thecode commented Jan 22, 2023

Thanks @bieniu @bdraco

@thecode thecode merged commit c5b6f78 into main Jan 22, 2023
@thecode thecode deleted the subscribe-by-mac branch January 22, 2023 20:37
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.

Support for proxy mode to support docker containers and reverse proxies
3 participants