Skip to content

Expose PIR enabled setting for iot dimmers #1174

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 7 commits into from
Oct 31, 2024
Merged

Conversation

rytilahti
Copy link
Member

@rytilahti rytilahti commented Oct 18, 2024

This adds PIR enabled feature to iot dimmers, making it possible to enable and disable the motion detection.
This requires testing to make sure it is working, so marking it as a draft for now.
This has now been confirmed to work on ES20M (#1215).

Requested in https://community.home-assistant.io/t/tp-link-ks220m-smart-swich-with-motion-and-light-sensors-support/340376/46

Homeassistant PR: home-assistant/core#129393

@rytilahti rytilahti added the enhancement New feature or request label Oct 18, 2024
Copy link

codecov bot commented Oct 18, 2024

Codecov Report

Attention: Patch coverage is 68.75000% with 5 lines in your changes missing coverage. Please review.

Project coverage is 92.56%. Comparing base (4aec9d3) to head (16234b1).
Report is 217 commits behind head on master.

Files with missing lines Patch % Lines
kasa/iot/modules/motion.py 68.75% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1174      +/-   ##
==========================================
+ Coverage   92.49%   92.56%   +0.06%     
==========================================
  Files          99       99              
  Lines        6532     6548      +16     
  Branches     1615      702     -913     
==========================================
+ Hits         6042     6061      +19     
+ Misses        373      367       -6     
- Partials      117      120       +3     

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

@rytilahti rytilahti marked this pull request as ready for review October 29, 2024 09:33
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.

For consistency with the smart modules tests, the test files should live in kasa/tests/iot/modules, other than that LGTM!

@rytilahti rytilahti enabled auto-merge (squash) October 31, 2024 10:40
@rytilahti rytilahti merged commit 9975bbf into master Oct 31, 2024
26 of 28 checks passed
@rytilahti rytilahti deleted the feat/pir_feature branch October 31, 2024 10:41
@eternalliving
Copy link

eternalliving commented Nov 2, 2024

I was unable to get the PIR module to show with the KS200M. It doesn't show under modules when querying dev.modules in a script.

Using kasa feature on cli does show the ambient_light feature though, but still no PIR.

Note: the KS200M isn't a dimmer, but does have motion and ambient light sensors.

Would this be better posted as an issue?

@rytilahti
Copy link
Member Author

Yes, please create a new issue for this. It'd also be great if you could provide a fixture file (described in the contributing docs), just in case it differs from the existing ones.

Iirc, the necessary modules are only initialized for devices that are considered as dimmers. So the fix involves finding a nice way to get this detected as such, as most kasa devices do not provide a way to detect supported features.

@sdb9696 sdb9696 added this to the 0.7.7 milestone Nov 4, 2024
@sdb9696 sdb9696 mentioned this pull request Nov 4, 2024
sdb9696 added a commit that referenced this pull request Nov 4, 2024
## [0.7.7](https://github.com/python-kasa/python-kasa/tree/0.7.7) (2024-11-04)

[Full Changelog](0.7.6...0.7.7)

**Release summary:**

- Bugfix for child device device creation error with credentials_hash
- PIR support for iot dimmers and wall switches.
- Various small enhancements and project improvements.

**Implemented enhancements:**

- Add PIR&LAS for wall switches mentioning PIR support [\#1227](#1227) (@rytilahti)
- Expose ambient light setting for iot dimmers [\#1210](#1210) (@rytilahti)
- Expose PIR enabled setting for iot dimmers [\#1174](#1174) (@rytilahti)
- Add childprotection module [\#1141](#1141) (@rytilahti)
- Initial trigger logs implementation [\#900](#900) (@rytilahti)

**Fixed bugs:**

- Fix AES child device creation error [\#1220](#1220) (@sdb9696)

**Project maintenance:**

- Update TC65 fixture [\#1225](#1225) (@rytilahti)
- Update smartcamera fixtures from latest dump\_devinfo [\#1224](#1224) (@sdb9696)
- Add component queries to smartcamera devices [\#1223](#1223) (@sdb9696)
- Update try\_connect\_all to be more efficient and report attempts [\#1222](#1222) (@sdb9696)
- Use stacklevel=2 for warnings to report on callsites [\#1219](#1219) (@rytilahti)
- parse\_pcap\_klap: various code cleanups [\#1138](#1138) (@rytilahti)
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.

3 participants