-
Notifications
You must be signed in to change notification settings - Fork 54
Add Class to discover all switchbots, all curtain bots or all bot (woHand) #23
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
Conversation
…add get is calibrated to main switchbot class.
…l for all device updates.
|
Hi @Danielhiversen, I'm done with this pull request. Could you please review if you get a chance? Thank you. |
Danielhiversen
left a comment
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.
Some initial comments.
@Jan108 Any comments? time_between_update_command will be removed
|
For later, please do not include any formatting changes. Makes it difficult to review and see actual changes. |
Co-authored-by: Daniel Hjelseth Høyer <mail@dahoiv.net>
Co-authored-by: Daniel Hjelseth Høyer <mail@dahoiv.net>
|
I have a working prototype Hass integration that makes use of a coordinator to update states of all devices (I have >8 switchbots) and it updates without any btle errors. This might help to indicate the logic behind the changes? https://github.com/RenierM26/ha-switchbot-curtain/tree/main/custom_components/switchbot-curtain Once I've managed to add "send commands" to the coordinator I will submit pull requests on hass. BLE is a real pain to figure out ways to properly time all adapter commands. (you can literally only issue 1 command at a time with the pygatt based python libraries) |
|
I think you should make a DataHandler class with functions: Would that make sense for you? |
No problem. Created a new class for these and modified method in SwitchbotDevice for single MAC scan. |
|
The When with the new code this is no longer a problem we can remove it. But if this still can happen, I would say the library should take care of this and not hass or the libaray user. |
Hi @Jan108 and @Danielhiversen , Pretty sure I solved this problem with the binary AND which I found in the node-switchbot code. (Pesky things these binary trees) Just busy testing a few conditions to confirm. |
|
Hi @Jan108 and @Danielhiversen, If reading of service data occur while the curtain is moving, it literately returns the curtain position at that time. Battery and other data is also returned correctly. |
… can be specified on scanning methods. -Add basic error handling to prevent key errors on discovery exceptions.
|
Hi @Danielhiversen, Think I addressed all of your suggestions. Please have a look when you get a chance? Thank you. |
Danielhiversen
left a comment
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.
Great. Thanks 👍
I do not think GetSwitchbotDevices is a very good name, but I do not have any better suggestion :)
SwitchbotDeviceDiscovery? |
-Added discovery method.
-All updates are now handled by single advertisement scan.
This should allow discovery and coordinator based updates in hass integration.
model number (first byte of 16b service data):
"c" = Curtain
"H" = WoHand or otherwise known as bot.
"T" = woSensorTH or otherwise known as temp/humidity sensor. (I don't have one and can't test the output)
Returns python dict with all device data of type with single scan.
Example of single curtain (json formated - easier to format in notepad ++):
Returns python dict with all device data of type with single scan.
Example of returned data for switchbot bot(json formatted - easier to format in notepad ++):