-
Notifications
You must be signed in to change notification settings - Fork 9
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
Advertise state changes instead of needing to ask for SCAN_RSP #15
Comments
@bdraco, I am using passive scanning only for my SwitchBot contact sensors (no connections). The manufacturer data broadcast seems to include motion and contact flags, and two 16-bit timers, respectively, counting since their last state change (~ The motion sensor seems to hold it's state for ~30 seconds; and I receive advertisements in quick succession in response to any state change. Maybe @donavanbecker can help illuminate the format and describe why only the |
@dcousens I am not sure. I actually don't work for SwitchBot. I just maintain the nodejs repos. If someone wants to enhance node-SwitchBot, I would be happy 😀 to merge the pull request! |
Interesting! Out of curiosity, where did you source the documentation in this repository from? |
@dcousens thats good news. How do you determine it's a contact sensor with only passive scans? |
Also do you have any docs / code to parse the manufacturer data ? |
@bdraco I determine the devices address, from it's first appearance on powering on, with the company identifier I don't have other Switchbot products for now, so I don't know if you can reasonably disambiguate them if you're thinking of automating discovery.
Maybe I'll create a pull request for @donavanbecker as suggested, but I don't have any documentation other than what I have determined myself. |
Looks like we are all in the same boat on this. Having docs for the manufacturer data would be a major improvement for the 3000+ users we have using the Home Assistant integration. |
This all came from the wiki that was on the python-host repo. Just moved for easier access and updating. |
Danielhiversen/pySwitchbot#152 I can confirm the I figured out 4 of the values in live testing. motion_detected = bool(mfr_data[7] & 0b10000000)
contact_open = bool(mfr_data[7] & 0b00010000)
button_count = mfr_data[12] & 0b00001111
is_light = bool(mfr_data[7] & 0b01000000) I still don't have a way to identify the specific device though. |
I managed to write It looks like the battery data isn't there though. They are all there if anyone wants to lift them : https://github.com/Danielhiversen/pySwitchbot/tree/master/switchbot/adv_parsers |
@bdraco Wanna create a PR for node-SwitchBot? 😀 |
If I didn't have a giant backlog of other work to get done I'd be happy to do that. Sadly I'll be digging myself out of the hole for a while since adding the Bluetooth integration to Home Assistant has taken up about 10x more work than I expected 🙈 |
Totally understandable, could you update this documentation? For people to better follow? |
@bdraco from my recent testing, contact_open = bool(mfr_data[7] & 0b00110000) |
It looks like now have parsers for all the manufacturer data values in pySwitchbot so I'm going to close this. Thanks to everyone who provided input. |
Current Situation
When a contact sensor or other changes state, it would be great if it advertised the change immediately instead of having to ask for a scan response. This would make the Home Assistant work with passive scanning and reflect changes right away which would allow us to solve home-assistant/core#82795
Currently the scan response data can be stale since there is a race between when the contact sensor changes state and the scan response is received which leads to stale and incorrect states being seen.
Proposed Change
See above
Additional Context
No response
The text was updated successfully, but these errors were encountered: