Skip to content

Fix iot strip turn on and off from parent #639

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
Jan 23, 2025

Conversation

Obbay2
Copy link
Contributor

@Obbay2 Obbay2 commented Jan 16, 2024

This doesn't break turning on and off individual plugs which are gotten with get_plug_by_index or get_plug_by_name.

This change is verified working on a real HS300 with hardware version 2.0 and firmware version 1.0.12.
Fixes #637

Copy link

codecov bot commented Jan 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.52%. Comparing base (fe88b52) to head (759eb09).
Report is 90 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #639   +/-   ##
=======================================
  Coverage   92.51%   92.52%           
=======================================
  Files         132      132           
  Lines        8163     8169    +6     
  Branches      833      837    +4     
=======================================
+ Hits         7552     7558    +6     
  Misses        449      449           
  Partials      162      162           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rytilahti
Copy link
Member

The current implementation works at least on my KP303, and my understanding was that it would work on other multi-socket devices. Doing this would cause extra I/O on those devices, so I'm wondering if this is just an issue with your specific hw/fw. @bdraco, does this work currently on your HS300?

@rytilahti rytilahti added enhancement New feature or request bug Something isn't working and removed enhancement New feature or request labels Mar 16, 2024
Copy link

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes.
Thank you for your contribution!

@github-actions github-actions bot added stale and removed stale labels Sep 28, 2024
@sdb9696 sdb9696 added the stale label Oct 2, 2024
@github-actions github-actions bot removed the stale label Oct 3, 2024
@sdb9696
Copy link
Collaborator

sdb9696 commented Dec 20, 2024

I can confirm turn on via the set_relay_state on the parent does not work for H300 2.0 (US) 1.0.12 Build 220121 Rel.175814.

I can also confirm that trying to update the H300 above with code like below from KasaSmartPowerStrip only updates the first child, although the author has confirmed that it does work with his HS300 1.0.6 Build 180627 Rel.081000:

  all_relay_command = '{"context":{"child_ids":' + plug_id_list_str + '},' + \
                         '"system":{"set_relay_state":{"state":' + str(state_int) + '}}}'

It's also confirmed by @bdraco that the official app does not have a switch on the parent and testing via wireshark confirms it makes individual requests to the children for emeter data etc.

So I think that as it seems the parent request or multiple child requests may only work on older versions, it would be simpler to just go for the solution in this PR rather than trying to do anything clever to work out if the device supports it.

@sdb9696 sdb9696 added this to the 0.9.1 milestone Dec 20, 2024
@sdb9696 sdb9696 modified the milestones: 0.9.1, 0.9.2 Dec 23, 2024
@sdb9696 sdb9696 requested a review from rytilahti January 3, 2025 18:22
Comment on lines +172 to +175
# IotStrip makes calls via it's children
expecting_call = feat.id not in internal_setters and not isinstance(
dev, IotStrip
)
Copy link
Member

Choose a reason for hiding this comment

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

This feels rather hacky, but maybe it's fine considering it's test code? Otherwise this looks good to me, but we may want to consider adding a master control for tapo strips in a separate PR to make it consistent.

@sdb9696 sdb9696 changed the title Fix smart strip turn on and turn off when no arguments are given in the CLI Fix iot strip turn on and off from parent Jan 23, 2025
@sdb9696 sdb9696 merged commit b701441 into python-kasa:master Jan 23, 2025
18 checks passed
@sdb9696 sdb9696 mentioned this pull request Jan 24, 2025
sdb9696 added a commit that referenced this pull request Jan 26, 2025
## [0.10.0](https://github.com/python-kasa/python-kasa/tree/0.10.0) (2025-01-26)

[Full Changelog](0.9.1...0.10.0)

**Release summary:**

This release brings support for many new devices, including completely new device types:

- Support for Tapo robot vacuums. Special thanks to @steveredden, @MAXIGAMESSUPPER, and veep60 for helping to get this implemented!
- Support for hub attached cameras and doorbells (H200)
- Improved support for hubs (including pairing & better chime controls)
- Support for many new camera and doorbell device models, including C220, C720, D100C, D130, and D230

Many thanks to testers and new contributors - @steveredden, @DawidPietrykowski, @Obbay2, @andrewome, @ryenitcher and @etmmvdp!

**Breaking changes:**

- `uses_http` is now a readonly property of device config. Consumers that relied on `uses_http` to be persisted with `DeviceConfig.to_dict()` will need to store the value separately.
- `is_color`, `is_dimmable`, `is_variable_color_temp`, `valid_temperate_range`, and `has_effects` attributes from the `Light` module are deprecated, consumers should use `has_feature("hsv")`, `has_feature("brightness")`, `has_feature("color_temp")`, `get_feature("color_temp").range`, and `Module.LightEffect in dev.modules` respectively. Calling the deprecated attributes will emit a `DeprecationWarning` and type checkers will fail them.
-  `alarm_volume` on the `smart.Alarm` module is changed from `str` to `int`

**Breaking changes:**

- Make uses\_http a readonly property of device config [\#1449](#1449) (@sdb9696)
- Allow passing alarm parameter overrides [\#1340](#1340) (@rytilahti)
- Deprecate legacy light module is\_capability checks [\#1297](#1297) (@sdb9696)

**Implemented enhancements:**

- Expose more battery sensors for D230 [\#1451](#1451)
- dumping HTTP POST Body for Tapo Vacuum \(RV30 Plus\) [\#937](#937)
- Add common alarm interface [\#1479](#1479) (@sdb9696)
- Add common childsetup interface [\#1470](#1470) (@sdb9696)
- Add childsetup module to smartcam hubs [\#1469](#1469) (@sdb9696)
- Add smartcam pet detection toggle module [\#1465](#1465) (@DawidPietrykowski)
- Only log one warning per unknown clean error code and status [\#1462](#1462) (@rytilahti)
- Add childlock module for vacuums [\#1461](#1461) (@rytilahti)
- Add ultra mode \(fanspeed = 5\) for vacuums [\#1459](#1459) (@rytilahti)
- Add setting to change carpet clean mode [\#1458](#1458) (@rytilahti)
- Add setting to change clean count [\#1457](#1457) (@rytilahti)
- Add mop module [\#1456](#1456) (@rytilahti)
- Enable dynamic hub child creation and deletion on update [\#1454](#1454) (@sdb9696)
- Expose current cleaning information [\#1453](#1453) (@rytilahti)
- Add battery module to smartcam devices [\#1452](#1452) (@sdb9696)
- Allow update of camera modules after setting values [\#1450](#1450) (@sdb9696)
- Update hub children on first update and delay subsequent updates [\#1438](#1438) (@sdb9696)
- Add support for doorbells and chimes [\#1435](#1435) (@steveredden)
- Implement vacuum dustbin module \(dust\_bucket\) [\#1423](#1423) (@rytilahti)
- Allow https for klaptransport [\#1415](#1415) (@rytilahti)
- Add smartcam child device support for smartcam hubs [\#1413](#1413) (@sdb9696)
- Add powerprotection module [\#1337](#1337) (@rytilahti)
- Add vacuum speaker controls [\#1332](#1332) (@rytilahti)
- Add consumables module for vacuums [\#1327](#1327) (@rytilahti)
- Add ADC Value to PIR Enabled Switches [\#1263](#1263) (@ryenitcher)
- Add support for cleaning records [\#945](#945) (@rytilahti)
- Initial support for vacuums \(clean module\) [\#944](#944) (@rytilahti)
- Add support for pairing devices with hubs [\#859](#859) (@rytilahti)

**Fixed bugs:**

- TP-Link HS300 Wi-Fi Power-Strip - "Parent On/Off" not functioning. [\#637](#637)
- Convert carpet\_clean\_mode to carpet\_boost switch [\#1486](#1486) (@rytilahti)
- Change category for empty dustbin feature from Primary to Config [\#1485](#1485) (@rytilahti)
- Report 0 for instead of None for zero current and voltage [\#1483](#1483) (@ryenitcher)
- Disable iot camera creation until more complete [\#1480](#1480) (@sdb9696)
- ssltransport: use debug logger for sending requests [\#1443](#1443) (@rytilahti)
- Fix discover cli command with host [\#1437](#1437) (@sdb9696)
- Fallback to is\_low for batterysensor's battery\_low [\#1420](#1420) (@rytilahti)
- Fix iot strip turn on and off from parent [\#639](#639) (@Obbay2)

**Added support for devices:**

- Add D130\(US\) 1.0 1.1.9 fixture [\#1476](#1476) (@sdb9696)
- Add D100C\(US\) 1.0 1.1.3 fixture [\#1475](#1475) (@sdb9696)
- Add C220\(EU\) 1.0 1.2.2 camera fixture [\#1466](#1466) (@DawidPietrykowski)
- Add D230\(EU\) 1.20 1.1.19 fixture [\#1448](#1448) (@sdb9696)
- Add fixture for C720 camera [\#1433](#1433) (@steveredden)

**Project maintenance:**

- Update ruff to 0.9 [\#1482](#1482) (@sdb9696)
- Cancel in progress CI workflows after new pushes [\#1481](#1481) (@sdb9696)
- Update test framework to support smartcam device discovery. [\#1477](#1477) (@sdb9696)
- Add error code 7 for clean module [\#1474](#1474) (@rytilahti)
- Enable CI workflow on PRs to feat/ fix/ and janitor/ [\#1471](#1471) (@sdb9696)
- Add commit-hook to prettify JSON files [\#1455](#1455) (@rytilahti)
- Add required sphinx.configuration [\#1446](#1446) (@rytilahti)
- Add more redactors for smartcams [\#1439](#1439) (@sdb9696)
- Add KS230\(US\) 2.0 1.0.11 IOT Fixture [\#1430](#1430) (@ZeliardM)
- Add tests for dump\_devinfo parent/child smartcam fixture generation [\#1428](#1428) (@sdb9696)
- Raise errors on single smartcam child requests [\#1427](#1427) (@sdb9696)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TP-Link HS300 Wi-Fi Power-Strip - "Parent On/Off" not functioning.
3 participants