-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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 Snooz BLE devices #78790
Conversation
Ideally the user knows nothing about the connected state of the device. I'm not sure how these devices work as I don't have one, but since the esphome devices have low connection limits and most bluetooth dongles start to fail with > 3-4 usually we don't stay connected to the device unless we know we are going to send commands. At least for switchbots we disconnect after 20s if they haven't sent any more commands https://github.com/Danielhiversen/pySwitchbot/blob/36b03594762311942558c364ccb6b9aa6731d84a/switchbot/devices/device.py#L207 I haven't checked the lib to see if you are holding the connection for a long time or not but given the disconnect call I expect it is. If you can't get the state from the advertisements, you are probably stuck with an always connected state like led_ble |
@bdraco Unfortunately, the state isn't included in the advertisements. The lib does hold a connection for a long time - how about a config setting "use persistent connection"? When disabled, it would disconnect devices after a specified command timeout like you mentioned for switchbot. I originally spent a good amount of time adding connection resilience to the lib since in testing it was somewhat painful for a 5-6 second command delay for "cold start" connections. I understand that not all users may want to have a persistent connection especially if the hardware is limited. |
If the device pushes updates via notify it is ok to hold the connection. If it doesn't it might be better to poll every so often instead. It looks like it gets push updates https://github.com/AustinBrunkhorst/pysnooz/blob/61d5ffe1a115acd567781d22664e9998bf3fbf77/src/pysnooz/api.py#L98 I wouldn't add an option to disable the connection since it will make the integration more complex and probably not the best UX. Instead, maybe document that it needs a persistent connection |
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: J. Nick Koston <nick@koston.org>
I think the code may pass all the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retested with library bump 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address the comments in a new PR. Thanks!
Proposed change
Add support for Snooz BLE devices.
Thoroughly tested on multiple generations of the White Noise Machine model.
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: