GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||
GeezerVison is showing github.com — Do not do update() in discover_single by sdb9696 · Pull Request #542 · python-kasa/python-kasa Conversation
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@ ## master #542 +/- ## ========================================== + Coverage 81.63% 81.74% +0.11% ========================================== Files 28 28 Lines 2417 2421 +4 Branches 683 685 +2 ========================================== + Hits 1973 1979 +6 + Misses 383 382 -1 + Partials 61 60 -1 ☔ View full report in Codecov by Sentry. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@bdraco friendly ping to keep you in the loop. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I'm not sure we can take the device update out without breaking the power strips, unless we pass the device type in. As soon as I get home, I'll review this and tested, as you may already be doing that and I just can't see it on my mobile. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
All the child plugs show as unavailable without the update |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
diff --git a/kasa/discover.py b/kasa/discover.py index 9883ad2..2ce408d 100755 --- a/kasa/discover.py +++ b/kasa/discover.py @@ -326,6 +326,11 @@ class Discover: if ip in protocol.discovered_devices: dev = protocol.discovered_devices[ip] dev.host = host + # If the device has children we have + # to update the device since we will + # otherwise have missing children + if dev.sys_info.get("child_num"): + await dev.update() return dev elif ip in protocol.unsupported_devices: raise UnsupportedDeviceException( This fixes the powerstrips. It would be better to abstract this as a property in the smart device object |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The power strips are really poorly responsive since we switch to the 5s interval because it updates all the children every time one is switched |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Actually that one is on the same subnet 😢 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The device sets up fine if I change the timeout to 10 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I fixed the power strips being overloaded with too many requests in home-assistant/core#103668 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Rather than doing it that way I've included a check to see if the type is SmartStrip. This is to future proof for klap/tuya devices that will kwarg: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I don't anticipate subnet related issues with UDP |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I think this will still break with any devices that have children that are not smart strips since its the children that need to be updated. I don't think there are any other devices that I have that have children though |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I couldn’t see children properties on any other device types. Do you think there are others? Maybe the smartlightstrip? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I think only tplink can answer that, but they all have suggested change bdraco@638a9b5 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@sdb9696 Can you fix the conflicts here? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
71ada4f to
bdf088b
Compare
bdf088b to
f7627fe
Compare
|
I will revert HA to use this and than test after dinner |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Ok that's done and includes your suggested changes for adding the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Are there any klap devices that have children that we know of at this point? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Not that we know of. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I think its ok to avoid the update for the klap devices unless its otherwise needed. We can always add support for klap devices with children in a future update |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
But you can't access the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
It looks like we call update_from_discover_info for klap devices as well. Does self._last_update = info not get set for these devices ? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
It's a limited set of properties, not the full sys_info list. If you try to access properties not in the limited list it will error. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Thats annoying. Since we only support children on the power strips, maybe go back to what you had before but move it behind the has_children property and take off |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
So the has_children property in smartdevice checks if it’s a lightstrip instance instead of looking at child_num? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Its the only the power strips (DeviceType.Strip) that have children (yes the names are confusing) not the light strips (DeviceType.LightStrip) Something like this diff --git a/kasa/smartdevice.py b/kasa/smartdevice.py index 6461f33..d019912 100755 --- a/kasa/smartdevice.py +++ b/kasa/smartdevice.py @@ -411,11 +411,14 @@ class SmartDevice: sys_info = self._sys_info return str(sys_info["model"]) - @property # type: ignore - @requires_update + @property def has_children(self) -> bool: """Check if the device has children devices.""" - return bool(self._sys_info.get("child_num")) + # Ideally we would check for the 'child_num' key in sys_info, + # but devices that speak klap do not populate this key via + # update_from_discover_info so we check for the devices + # we know have children instead. + return self.is_strip @property # type: ignore @requires_update |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Yes sorry, meant strip. Makes sense, will update tomorrow am. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ok that's done |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks @sdb9696
Will push to my production and test shortly
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Took a few tries, but the power strip did eventually set up so this is good to go. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.