-
-
Notifications
You must be signed in to change notification settings - Fork 221
Re-add protocol_class parameter to connect #551
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
Re-add protocol_class parameter to connect #551
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #551 +/- ##
==========================================
+ Coverage 82.24% 82.27% +0.03%
==========================================
Files 30 30
Lines 2461 2466 +5
Branches 692 694 +2
==========================================
+ Hits 2024 2029 +5
Misses 379 379
Partials 58 58 ☔ View full report in Codecov by Sentry. |
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.
LGTM, thanks 👍
Hi, could you merge this please @rytilahti? Are you going to publish a release soon? |
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.
So I didn't want to rush on merging this to give some time for second thoughts.. Which led me to think that it might be a good idea for potential extensibility to create an enum instead of using a directly class type for defining the wanted protocol. I'm not yet completely sure about what's the best approach, but I think it makes sense to try to relieve downstreams from importing internal classes (like the protocol ones) if this library extends to cover other transport protocols like for those cams and tapo devices.
About the new release, I might be able to squeeze a release out on the weekend but I can't make promises due to some upcoming deadlines.
Ok fair enough. I was thinking about how this would be stored in and re-used in HA. As it seems to be the discovery info that determines the protocol, one approach could be to create a protocol factory (either in it's own module or as part of the discovery module). This could take a parameter of the pydantic What do you think? ping @bdraco, for context here it seems that some kasa EP25 devices are starting to use the TAPO protocol |
I think its a good idea to store the discovery results in some way in HA so we can reconnect easily, but I would be very nervous about relying on pydantic to do the serialization / deserialization as I've had so many problems with pydantic changes and breakage that I no longer use it in new code. A simple data structure that is JSON serializable would probably be the best as it would make it easy to work for most systems and HA |
Hi @rytilahti, any further thoughts on whether we can merge this yet? I think we’re going to need it for the Klap HA PR to work after @bdraco moves the integration to use |
This looks good to me and worth merging. My only worry is that adding such "low-level" things (like importing custom protocols / initializing them) may not be acceptable for homeassistant.. So I was thinking, maybe we could create a very simple container for all necessary connection parameters ( As long as we keep this backwards compatible, we can easily extend it without needing to touch homeassistant code. Basically, What we basically need is the following information to construct a device from zero, right?
What do you think? |
It seems the move of
connect()
out of discovery dropped theprotocol_class
parameter needed to create devices with different protocols. I've re-added it pretty much as per before.