FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Support child devices in all applicable cli commands by sdb9696 · Pull Request #1020 · python-kasa/python-kasa · GitHub

Repository navigation

Support child devices in all applicable cli commands - #1020

Merged
rytilahti merged 11 commits into
masterfrom
feat/child_cli
Jul 2, 2024
Merged

rytilahti merged 11 commits into
masterfrom
feat/child_cli

Conversation

sdb9696 commented Jun 27, 2024 •
edited by rytilahti
Loading

Copy link
Copy Markdown
Contributor

Adds a new decorator that adds child options to a command and gets the child device if the options are set.

  • Single definition of options and error handling
  • Adds options automatically to command
  • Backwards compatible with --index and --name
  • --child allows for id and alias for ease of use
  • Omitting a value for --child gives an interactive prompt

Implements private _update to allow the CLI to patch a child update method to call the parent device update.

Example help output:

$ kasa brightness --help
Usage: kasa brightness [OPTIONS] [BRIGHTNESS]

  Get or set brightness.

Options:
  --transition INTEGER
  --child, --name TEXT            Child ID or alias for controlling sub-
                                  devices. If no value provided will show an
                                  interactive prompt allowing you to select a
                                  child.
  --child-index, --index INTEGER  Child index controlling sub-devices
  --help                          Show this message and exit.

Fixes #769

Comment thread kasa/cli.py Outdated
sdb9696 closed this Jun 28, 2024
sdb9696 reopened this Jun 28, 2024
Comment thread kasa/cli.py
sdb9696 force-pushed the feat/child_cli branch 2 times, most recently from e56d64c to 19e4011 Compare June 30, 2024 07:56

codecov Bot commented Jun 30, 2024 •
edited
Loading

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 95.20000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 91.98%. Comparing base (b8a87f1) to head (0e7da62).
Report is 81 commits behind head on master.

Files with missing lines Patch % Lines
kasa/cli.py 96.39% 4 Missing ⚠️
kasa/iot/iotstrip.py 66.66% 1 Missing ⚠️
kasa/smart/smartchilddevice.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1020      +/-   ##
==========================================
+ Coverage   91.45%   91.98%   +0.53%     
==========================================
  Files          84       84              
  Lines        5743     5762      +19     
  Branches     1397     1395       -2     
==========================================
+ Hits         5252     5300      +48     
+ Misses        382      356      -26     
+ Partials      109      106       -3     

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

sdb9696 changed the title Allow Passing child parameters to all commands Support child devices in all cli commands Jun 30, 2024
sdb9696 added the enhancement New feature or request label Jun 30, 2024
sdb9696 marked this pull request as ready for review June 30, 2024 09:51
sdb9696 changed the title Support child devices in all cli commands Support child devices in all applicable cli commands Jun 30, 2024

rytilahti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks nice, some quick comments inline.

Trying to turn on the thermostat doesn't work through on (as setting the state is done using a different command), but it's not an issue for this PR.

Comment thread kasa/cli.py
Comment thread kasa/cli.py Outdated
Comment thread kasa/cli.py
Comment thread kasa/cli.py Outdated
sdb9696 requested a review from rytilahti July 2, 2024 07:39
sdb9696 added this to the 0.7.1 milestone Jul 2, 2024

rytilahti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM, thanks! 👍

rytilahti linked an issue Jul 2, 2024 that may be closed by this pull request
rytilahti merged commit 9cffbe9 into master Jul 2, 2024
rytilahti deleted the feat/child_cli branch July 2, 2024 13:11
sdb9696 mentioned this pull request Jul 31, 2024
sdb9696 added a commit that referenced this pull request Jul 31, 2024
## [0.7.1](https://github.com/python-kasa/python-kasa/tree/0.7.1) (2024-07-31)

[Full Changelog](0.7.0.5...0.7.1)

**Release highlights:**
- This release consists mainly of bugfixes and project improvements.
- There is also new support for Tapo T100 motion sensors.
- The CLI now supports child devices on all applicable commands.

**Implemented enhancements:**

- Expose reboot action [\#1073](#1073) (@rytilahti)
- Decrypt KLAP data from PCAP files [\#1041](#1041) (@clstrickland)
- Support child devices in all applicable cli commands [\#1020](#1020) (@sdb9696)

**Fixed bugs:**

- Fix iot light effect brightness [\#1092](#1092) (@sdb9696)
- Enable setting brightness with color temp for smart devices [\#1091](#1091) (@sdb9696)
- Do not send light\_on value to iot bulb set\_state [\#1090](#1090) (@sdb9696)
- Allow erroring modules to recover [\#1080](#1080) (@sdb9696)
- Raise KasaException on decryption errors [\#1078](#1078) (@sdb9696)
- Update smart request parameter handling [\#1061](#1061) (@sdb9696)
- Fix light preset module when list contains lighting effects [\#1048](#1048) (@sdb9696)
- Handle module errors more robustly and add query params to light preset and transition [\#1036](#1036) (@sdb9696)
- Fix credential hash to return None on empty credentials [\#1029](#1029) (@sdb9696)

**Added support for devices:**

- Add support for T100 motion sensor [\#1079](#1079) (@rytilahti)

**Project maintenance:**

- Bump project version to 0.7.0.5 [\#1087](#1087) (@sdb9696)
- Fix generate\_supported pre commit to run in venv [\#1085](#1085) (@sdb9696)
- Fix intermittently failing decryption error test [\#1082](#1082) (@sdb9696)
- Fix mypy pre-commit hook on windows [\#1081](#1081) (@sdb9696)
- Update RELEASING.md for patch releases [\#1076](#1076) (@sdb9696)
- Use monotonic time for query timing [\#1070](#1070) (@sdb9696)
- Fix parse\_pcap\_klap on windows and support default credentials [\#1068](#1068) (@sdb9696)
- Add fixture file for KP405 fw 1.0.6 [\#1063](#1063) (@daleye)
- Bump project version to 0.7.0.3 [\#1053](#1053) (@sdb9696)
- Add KP400\(US\) v1.0.4 fixture [\#1051](#1051) (@gimpy88)
- Add new HS220 kasa aes fixture [\#1050](#1050) (@sdb9696)
- Add KS205\(US\) v1.1.0 fixture [\#1049](#1049) (@gimpy88)
- Add KS200M\(US\) v1.0.11 fixture [\#1047](#1047) (@sdb9696)
- Add KS225\(US\) v1.1.0 fixture [\#1046](#1046) (@sdb9696)
- Split out main cli module into lazily loaded submodules [\#1039](#1039) (@sdb9696)
- Structure cli into a package [\#1038](#1038) (@sdb9696)
- Add KP400 v1.0.3 fixture [\#1037](#1037) (@gimpy88)
- Add L920\(EU\) v1.1.3 fixture [\#1031](#1031) (@rytilahti)
- Update changelog generator config [\#1030](#1030) (@sdb9696)
pillarsdotnet pushed a commit to pillarsdotnet/python-kasa that referenced this pull request Oct 22, 2026
Adds a new decorator that adds child options to a command and gets the
child device if the options are set.

- Single definition of options and error handling
- Adds options automatically to command
- Backwards compatible with `--index` and `--name`
- `--child` allows for id and alias for ease of use
- Omitting a value for `--child` gives an interactive prompt

Implements private `_update` to allow the CLI to patch a child `update`
method to call the parent device `update`.

Example help output:
```
$ kasa brightness --help
Usage: kasa brightness [OPTIONS] [BRIGHTNESS]

  Get or set brightness.

Options:
  --transition INTEGER
  --child, --name TEXT            Child ID or alias for controlling sub-
                                  devices. If no value provided will show an
                                  interactive prompt allowing you to select a
                                  child.
  --child-index, --index INTEGER  Child index controlling sub-devices
  --help                          Show this message and exit.
```

Fixes python-kasa#769
pillarsdotnet pushed a commit to pillarsdotnet/python-kasa that referenced this pull request Oct 22, 2026
## [0.7.1](https://github.com/python-kasa/python-kasa/tree/0.7.1) (2024-07-31)

[Full Changelog](python-kasa/python-kasa@0.7.0.5...0.7.1)

**Release highlights:**
- This release consists mainly of bugfixes and project improvements.
- There is also new support for Tapo T100 motion sensors.
- The CLI now supports child devices on all applicable commands.

**Implemented enhancements:**

- Expose reboot action [\python-kasa#1073](python-kasa#1073) (@rytilahti)
- Decrypt KLAP data from PCAP files [\python-kasa#1041](python-kasa#1041) (@clstrickland)
- Support child devices in all applicable cli commands [\python-kasa#1020](python-kasa#1020) (@sdb9696)

**Fixed bugs:**

- Fix iot light effect brightness [\python-kasa#1092](python-kasa#1092) (@sdb9696)
- Enable setting brightness with color temp for smart devices [\python-kasa#1091](python-kasa#1091) (@sdb9696)
- Do not send light\_on value to iot bulb set\_state [\python-kasa#1090](python-kasa#1090) (@sdb9696)
- Allow erroring modules to recover [\python-kasa#1080](python-kasa#1080) (@sdb9696)
- Raise KasaException on decryption errors [\python-kasa#1078](python-kasa#1078) (@sdb9696)
- Update smart request parameter handling [\python-kasa#1061](python-kasa#1061) (@sdb9696)
- Fix light preset module when list contains lighting effects [\python-kasa#1048](python-kasa#1048) (@sdb9696)
- Handle module errors more robustly and add query params to light preset and transition [\python-kasa#1036](python-kasa#1036) (@sdb9696)
- Fix credential hash to return None on empty credentials [\python-kasa#1029](python-kasa#1029) (@sdb9696)

**Added support for devices:**

- Add support for T100 motion sensor [\python-kasa#1079](python-kasa#1079) (@rytilahti)

**Project maintenance:**

- Bump project version to 0.7.0.5 [\python-kasa#1087](python-kasa#1087) (@sdb9696)
- Fix generate\_supported pre commit to run in venv [\python-kasa#1085](python-kasa#1085) (@sdb9696)
- Fix intermittently failing decryption error test [\python-kasa#1082](python-kasa#1082) (@sdb9696)
- Fix mypy pre-commit hook on windows [\python-kasa#1081](python-kasa#1081) (@sdb9696)
- Update RELEASING.md for patch releases [\python-kasa#1076](python-kasa#1076) (@sdb9696)
- Use monotonic time for query timing [\python-kasa#1070](python-kasa#1070) (@sdb9696)
- Fix parse\_pcap\_klap on windows and support default credentials [\python-kasa#1068](python-kasa#1068) (@sdb9696)
- Add fixture file for KP405 fw 1.0.6 [\python-kasa#1063](python-kasa#1063) (@daleye)
- Bump project version to 0.7.0.3 [\python-kasa#1053](python-kasa#1053) (@sdb9696)
- Add KP400\(US\) v1.0.4 fixture [\python-kasa#1051](python-kasa#1051) (@gimpy88)
- Add new HS220 kasa aes fixture [\python-kasa#1050](python-kasa#1050) (@sdb9696)
- Add KS205\(US\) v1.1.0 fixture [\python-kasa#1049](python-kasa#1049) (@gimpy88)
- Add KS200M\(US\) v1.0.11 fixture [\python-kasa#1047](python-kasa#1047) (@sdb9696)
- Add KS225\(US\) v1.1.0 fixture [\python-kasa#1046](python-kasa#1046) (@sdb9696)
- Split out main cli module into lazily loaded submodules [\python-kasa#1039](python-kasa#1039) (@sdb9696)
- Structure cli into a package [\python-kasa#1038](python-kasa#1038) (@sdb9696)
- Add KP400 v1.0.3 fixture [\python-kasa#1037](python-kasa#1037) (@gimpy88)
- Add L920\(EU\) v1.1.3 fixture [\python-kasa#1031](python-kasa#1031) (@rytilahti)
- Update changelog generator config [\python-kasa#1030](python-kasa#1030) (@sdb9696)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Extend cli to allow defining --child across all relevant commands

2 participants


Back | FazBrowse Home | New Git URL