8000 Add support for T100 motion sensor by rytilahti · Pull Request #1079 · python-kasa/python-kasa · GitHub
[go: up one dir, main page]

Skip to content

Add support for T100 motion sensor #1079

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 2 commits into from
Jul 24, 2024
Merged

Add support for T100 motion sensor #1079

merged 2 commits into from
Jul 24, 2024

Conversation

rytilahti
Copy link
Member

Add support for T100 motion sensor.
Thanks to @DarthSonic for the fixture file!

Related to home-assistant/core#121256

@rytilahti rytilahti added the new device New device supported due to fixture being added label Jul 23, 2024
@rytilahti rytilahti added this to the 0.7.1 milestone Jul 23, 2024
Copy link
codecov bot commented Jul 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.19%. Comparing base (06ff598) to head (3d37614).
Report is 82 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1079      +/-   ##
==========================================
+ Coverage   92.17%   92.19%   +0.01%     
==========================================
  Files          85       86       +1     
  Lines        5928     5942      +14     
  Branches     1440     1441       +1     
==========================================
+ Hits         5464     5478      +14     
  Misses        358      358              
  Partials      106      106              

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

Comment on lines 12 to 13
REQUIRED_COMPONENT = None # we depend on availability of key
REQUIRED_KEY_ON_PARENT = "detected"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the key present on the parent hub get_device_info or is it only on the child T100 device_info?

Copy link
Member Author
@rytilahti rytilahti Jul 23, 2024

Choose a reason for hiding this comment

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

I'd guess it'd only be on the T100 device info. So we should probably either use _check_supported or mark sensitivity as the dependency for this?

Also, given the tests are passing here, I think we need to have some sort of test for this.. :-P

Copy link
Collaborator

Choose a reason for hiding this comment

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

How does it work for the contactsensor which also uses that REQUIRED_KEY_ON_PARENT?

Re tests we should maybe come up with a way to add the children to empty hub devices and pass them in instead of the child device directly.

Copy link
Collaborator
@sdb9696 sdb9696 left a comment

Choose a reason for hiding this comment

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

LGTM once @DarthSonic can confirm it works with his device!

@DarthSonic
Copy link

LGTM once @DarthSonic can confirm it works with his device!

This is beyond my knowledge of GitHub and python-kasa. Creating the fixture was task enough.

@sdb9696
Copy link
Collaborator
sdb9696 commented Jul 23, 2024

This is beyond my knowledge of GitHub and python-kasa. Creating the fixture was task enough.

Hey @DarthSonic, when you created the fixture presumably you installed python-kasa? Did you do it via pip? To install @rytilahti PR just run:

pip3 install "python-kasa[speedups] @ git+https://github.com/python-kasa/python-kasa.git@feat/t100_motion"

Then run:

kasa --host HUB_IP --username YOUR_UN --password YOUR_PW feature motion_detection

You should see the new motion detection item with the current state. Try to trigger some motion and then run the kasa command again to see if it changes.

@DarthSonic
Copy link
kasa --host HUB_IP --username YOUR_UN --password YOUR_PW feature motion_detection

I only get "Access denied". I am using Windows 11 and need to run "python3 -m ..." commands. I checked out branch with Git GUI for Windows.

@sdb9696
Copy link
Collaborator
sdb9696 commented Jul 23, 2024
python3 -m kasa.cli --host HUB_IP --username YOUR_UN --password YOUR_PW feature motion_detection

@DarthSonic
Copy link
python3 -m kasa.cli --host HUB_IP --username YOUR_UN --password YOUR_PW feature motion_detection

[bold red]No feature by name 'motion_detection'[/bold red]

@rytilahti
Copy link
Member Author

Try motion_detected

@DarthSonic
Copy link

Try motion_detected

Same: [bold red]No feature by name 'motion_detected'[/bold red]

I am on the proper branch I think:

image

@rytilahti
Copy link
Member Author

Yes, that's the correct branch! Try just feature without defining any name, and it will list all available features. I think it doesn't find it as it's a feature of the sensor, and not of the hub.

@DarthSonic
Copy link
DarthSonic commented Jul 23, 2024

Yes, that's the correct branch! Try just feature without defining any name, and it will list all available features. I think it doesn't find it as it's a feature of the sensor, and not of the hub.

        == Child Katzensensor Wohnzimmer ==

        == Primary features ==
        Motion detected (motion_detected): False

and it updates to "True" if triggered!

@rytilahti
Copy link
Member Author

Great, thanks for testing! Let's merge this for the next release :-)

@rytilahti rytilahti merged commit 055bbcc into master Jul 24, 2024
25 checks passed
@rytilahti rytilahti deleted the feat/t100_motion branch July 24, 2024 13:48
@DarthSonic
Copy link

@rytilahti Hi. Should this be implemented in Core 2024.7.4 already? If so, I do not see the new motion entity yet.

@sdb9696
Copy link
Collaborator
sdb9696 commented Jul 31, 2024

Hi, this is not in the 2024.7.4 release but it should make the 2024.8 beta.

@sdb9696 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new device New device supported due to fixture being added
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0