8000 Add effect support for light strips by bdraco · Pull Request #293 · python-kasa/python-kasa · GitHub
[go: up one dir, main page]

Skip to content

Add effect support for light strips #293

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

Merged
merged 5 commits into from
Mar 21, 2022

Conversation

bdraco
Copy link
Member
@bdraco bdraco commented Jan 28, 2022

Closes #191

@bdraco bdraco force-pushed the kl430_effects branch 14 times, most recently from 71db428 to f78fcbd Compare January 28, 2022 19:26
Copy link
Member
@rytilahti rytilahti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I'm wondering if this should rather target the modularize branch to avoid making the future merge easier?

@bdraco
Copy link
Member Author
bdraco commented Jan 29, 2022

LGTM, but I'm wondering if this should rather target the modularize branch to avoid making the future merge easier?

How close is that ready to shipping?

@codecov-commenter
Copy link
codecov-commenter commented Jan 29, 2022

Codecov Report

Merging #293 (d79b7d7) into master (5bf6fda) will decrease coverage by 0.10%.
The diff coverage is 78.18%.

@@            Coverage Diff             @@
##           master     #293      +/-   ##
==========================================
- Coverage   82.15%   82.04%   -0.11%     
==========================================
  Files          12       13       +1     
  Lines        1317     1376      +59     
  Branches      195      202       +7     
==========================================
+ Hits         1082     1129      +47     
- Misses        196      205       +9     
- Partials       39       42       +3     
Impacted Files Coverage Δ
kasa/cli.py 59.74% <35.71%> (-0.86%) ⬇️
kasa/smartlightstrip.py 92.50% <84.21%> (-7.50%) ⬇️
kasa/effects.py 100.00% <100.00%> (ø)
kasa/smartbulb.py 94.33% <100.00%> (+0.14%) ⬆️
kasa/smartdevice.py 85.46% <0.00%> (-0.21%) ⬇️
kasa/protocol.py 90.43% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5bf6fda...d79b7d7. Read the comment docs.

@rytilahti
Copy link
Member

How close is that ready to shipping?

The API is backwards compatible, so I don't see why it couldn't be ready quite soon. I'll have to take a look at what should be cleaned prior releasing it come next month.

Have you tried the branch already? As it will involve much more I/O (and multi-module requests), it would be great if you could give it a try to see if it works on the devices you have.

@bdraco
Copy link
Member Author
bdraco commented Jan 29, 2022

Have you tried the branch already? As it will involve much more I/O (and multi-module requests), it would be great if you could give it a try to see if it works on the devices you have.

I think I did a while back, but I can give it another spin later today. Where is the additional I/O coming from?

@rytilahti
Copy link
Member
rytilahti commented Jan 29, 2022

I think I did a while back, but I can give it another spin later today. Where is the additional I/O coming from?

Each update cycle requests information from all supported modules (https://github.com/python-kasa/python-kasa/blob/modularize/kasa/smartbulb.py#L114), so the response payloads are bigger than they used to be in many cases.

edit: I just merged #278 - it would be interesting to hear if SmartDimmer still keeps working during the initial query for HS220, if you have it wired in. After #298 gets merged only the supported modules are requested in the follow-up update queries.

@bdraco
Copy link
Member Author
bdraco commented Jan 29, 2022

edit: I just merged #278 - it would be interesting to hear if SmartDimmer still keeps working during the initial query for HS220, if you have it wired in. After #298 gets merged only the supported modules are requested in the follow-up update queries.

I wired it up and it still works

@bdraco bdraco changed the title Add effect support for KL430 Add effect support for light strips Jan 30, 2022
@bdraco
Copy link
Member Author
bdraco commented Jan 30, 2022

@rytilahti I tested the modularize branch with the power strips and everything seems to work fine.

@bdraco
Copy link
Member Author
8000 bdraco commented Jan 30, 2022

Everything looks good with modularize

✅ HS110
✅ EP40
✅ HS300
✅ KP303
❌ HS220 - no entities
✅ HS220 -- turned ok to be ok.. was breakage due to a merge conflict

@bdraco
Copy link
Member Author
bdraco commented Jan 30, 2022

I'll rebase this once #299 merges

@rytilahti
Copy link
Member

Thanks for testing! Did you check if the emeter readings from HS300 were also working? That code path is something that may have issues as I feel it's implemented in a rather error-prone way..

I'll make it a mission to get the modularize merged back at latest by the end of the second week in February, but that will most likely happen already late next week.

@bdraco
Copy link
Member Author
bdraco commented Jan 30, 2022

Good call to check that as well. The switches work, but seeing an error with the strip power sensors

2022-01-30 14:53:03 ERROR (MainThread) [homeassistant.components.s
8000
ensor] Error while setting up tplink platform for sensor
Traceback (most recent call last):
  File "/Users/bdraco/home-assistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
    await asyncio.shield(task)
  File "/Users/bdraco/home-assistant/homeassistant/components/tplink/sensor.py", line 133, in async_setup_entry
    entities.extend(_async_sensors_for_device(child))
  File "/Users/bdraco/home-assistant/homeassistant/components/tplink/sensor.py", line 124, in _async_sensors_for_device
    return [
  File "/Users/bdraco/home-assistant/homeassistant/components/tplink/sensor.py", line 127, in <listcomp>
    if async_emeter_from_device(device, description) is not None
  File "/Users/bdraco/home-assistant/homeassistant/components/tplink/sensor.py", line 99, in async_emeter_from_device
    if (val := getattr(device.emeter_realtime, attr)) is None:
  File "/Users/bdraco/home-assistant/venv/lib/python3.9/site-packages/kasa/smartdevice.py", line 88, in wrapped
    return f(*args, **kwargs)
  File "/Users/bdraco/home-assistant/venv/lib/python3.9/site-packages/kasa/smartdevice.py", line 462, in emeter_realtime
    return EmeterStatus(self.modules["emeter"].realtime)
KeyError: 'emeter'

Copy link
Member
@rytilahti rytilahti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go 👍

@rytilahti rytilahti merged commit 58f6517 into python-kasa:master Mar 21, 2022
@rytilahti rytilahti added the enhancement New feature or request label Mar 21, 2022
rytilahti added a commit to rytilahti/python-kasa that referenced this pull request Mar 21, 2022
This is the last release prior restructuring the code to enable easier extendability by moving towards more modular architecture.
The most prominent change in this release is the support for effects on light strips.

[Full Changelog](python-kasa/python-kasa@0.4.1...0.4.2)

**Implemented enhancements:**

- Allow environment variables for discovery target, device type and debug [\python-kasa#313](python-kasa#313) (@rytilahti)
- Add 'internal\_state' to return the results from the last update query [\python-kasa#306](python-kasa#306) (@rytilahti)
- Drop microsecond precision for on\_since [\python-kasa#296](python-kasa#296) (@rytilahti)
- Add effect support for light strips [\python-kasa#293](python-kasa#293) (@bdraco)

**Fixed bugs:**

- TypeError: \_\_init\_\_\(\) got an unexpected keyword argument 'package\_name' [\python-kasa#311](python-kasa#311)
- RuntimeError: Event loop is closed on WSL [\python-kasa#294](python-kasa#294)
- Don't crash on devices not reporting features [\python-kasa#317](python-kasa#317) (@rytilahti)

**Closed issues:**

- SmartDeviceException: Communication error on system:set\_relay\_state [\python-kasa#309](python-kasa#309)
- Add Support: ES20M and KS200M motion/light switches [\python-kasa#308](python-kasa#308)
- New problem with installing on Ubuntu 20.04.3 LTS [\python-kasa#305](python-kasa#305)
- KeyError: 'emeter' when discovering [\python-kasa#302](python-kasa#302)
- RuntimeError: Event loop is closed  [\python-kasa#291](python-kasa#291)
- provisioning format [\python-kasa#290](python-kasa#290)
- Fix CI publishing on pypi [\python-kasa#222](python-kasa#222)
- LED strips effects are not supported \(was LEDs is not turning on after switching on\) [\python-kasa#191](python-kasa#191)

**Merged pull requests:**

- Add pyupgrade to CI runs [\python-kasa#314](python-kasa#314) (@rytilahti)
- Depend on asyncclick \>= 8 [\python-kasa#312](python-kasa#312) (@rytilahti)
- Guard emeter accesses to avoid keyerrors [\python-kasa#304](python-kasa#304) (@rytilahti)
- cli: cleanup discover, fetch update prior device access [\python-kasa#303](python-kasa#303) (@rytilahti)
- Fix unsafe \_\_del\_\_ in TPLinkSmartHomeProtocol [\python-kasa#300](python-kasa#300) (@bdraco)
- Improve typing for protocol class [\python-kasa#289](python-kasa#289) (@rytilahti)
- Added a fixture file for KS220M [\python-kasa#273](python-kasa#273) (@mrbetta)
@rytilahti rytilahti mentioned this pull request Mar 21, 2022
rytilahti added a commit that referenced this pull request Mar 21, 2022
This is the last release prior restructuring the code to enable easier extendability by moving towards more modular architecture.
The most prominent change in this release is the support for effects on light strips.

[Full Changelog](0.4.1...0.4.2)

**Implemented enhancements:**

- Allow environment variables for discovery target, device type and debug [\#313](#313) (@rytilahti)
- Add 'internal\_state' to return the results from the last update query [\#306](#306) (@rytilahti)
- Drop microsecond precision for on\_since [\#296](#296) (@rytilahti)
- Add effect support for light strips [\#293](#293) (@bdraco)

**Fixed bugs:**

- TypeError: \_\_init\_\_\(\) got an unexpected keyword argument 'package\_name' [\#311](#311)
- RuntimeError: Event loop is closed on WSL [\#294](#294)
- Don't crash on devices not reporting features [\#317](#317) (@rytilahti)

**Closed issues:**

- SmartDeviceException: Communication error on system:set\_relay\_state [\#309](#309)
- Add Support: ES20M and KS200M motion/light switches [\#308](#308)
- New problem with installing on Ubuntu 20.04.3 LTS [\#305](#305)
- KeyError: 'emeter' when discovering [\#302](#302)
- RuntimeError: Event loop is closed  [\#291](#291)
- provisioning format [\#290](#290)
- Fix CI publishing on pypi [\#222](#222)
- LED strips effects are not supported \(was LEDs is not turning on after switching on\) [\#191](#191)

**Merged pull requests:**

- Add pyupgrade to CI runs [\#314](#314) (@rytilahti)
- Depend on asyncclick \>= 8 [\#312](#312) (@rytilahti)
- Guard emeter accesses to avoid keyerrors [\#304](#304) (@rytilahti)
- cli: cleanup discover, fetch update prior device access [\#303](#303) (@rytilahti)
- Fix unsafe \_\_del\_\_ in TPLinkSmartHomeProtocol [\#300](#300) (@bdraco)
- Improve typing for protocol class [\#289](#289) (@rytilahti)
- Added a fixture file for KS220M [\#273](#273) (@mrbetta)
@rytilahti rytilahti mentioned this pull request Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LED strips effects are not supported (was LEDs is not turning on after switching on)
3 participants
0