GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add Dimmer Configuration Support by ryenitcher · Pull Request #1484 · python-kasa/python-kasa

Conversation

@ryenitcher

@ryenitcher ryenitcher commented Jan 25, 2025

Copy link
Copy Markdown
Contributor
  • Add: Support for configuring minimum dimming level.
  • Add: Support for configuring dimmer ramp rate.
  • Add: Support for configuring dimmer gentle fade time.
  • Add: Support for configuring dimmper fade time.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ryenitcher

ryenitcher commented Jan 25, 2025

Copy link
Copy Markdown
Contributor Author

Hopefully breaking out the dimmer configuration into a feature from the module is acceptable.

I've tested this against an KS220, and it appears to work well, but I can look into adding proper tests for this if the change seems reasonable to you.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ryenitcher

ryenitcher commented Jan 25, 2025

Copy link
Copy Markdown
Contributor Author

This should cover #1464

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@codecov

codecov Bot commented Jan 25, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.71%. Comparing base (09e73fa) to head (f010a3b).
Report is 15 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1484      +/-   ##
==========================================
+ Coverage   92.64%   92.71%   +0.06%     
==========================================
  Files         149      150       +1     
  Lines        9428     9524      +96     
  Branches      957      968      +11     
==========================================
+ Hits         8735     8830      +95     
+ Misses        497      496       -1     
- Partials      196      198       +2     

☔ 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.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rytilahti rytilahti linked an issue Jan 25, 2025 that may be closed by this pull request
Dimmer Calibration? NOT Presets #1464
Closed
@rytilahti rytilahti added the enhancement New feature or request label Jan 26, 2025
rytilahti
rytilahti requested changes Jan 26, 2025
View reviewed changes

@rytilahti rytilahti left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Looks really great and it's nice to see also older devices getting some love, thanks @ryenitcher! 💯

I added some comments (which likely apply for all these settings) inline, let me know if you think those changes make sense or not. On tests, it would be great to have some, either test_motion.py or test_ambientlight.py could be a good starting point.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread kasa/iot/modules/dimmer.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread kasa/iot/modules/dimmer.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread kasa/iot/modules/dimmer.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread kasa/iot/modules/dimmer.py Outdated

:param min: The minimum dimming level, in the range 0-51.
"""
if (min < 0) or (min > 51):

@rytilahti rytilahti Jan 26, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Suggested change
if (min < 0) or (min > 51):
if min < 0 or min > 51:

Is it really up to 51 and not 50? In any case, no need for parentheses here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@ryenitcher ryenitcher Jan 26, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Yeah if you use the app to set the dimmer trim to max, it sets the value to 51, which surprised me as well. The API rejects 52 as a value though, so it has to end on 51. Perhaps there is a special bypass mode on the triac or something for no dimming, and that's a special value used to denote that?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rytilahti reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@rytilahti rytilahti Jan 26, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Could be something special indeed, but we can keep it as it is and adjust when someone chimes in with an issue report :)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@sdb9696 sdb9696 Jan 26, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Could be worth adding a small comment here about the tested app behaviour.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread kasa/iot/modules/dimmer.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread kasa/iot/modules/dimmer.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread kasa/iot/modules/dimmer.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

ryenitcher added 2 commits January 26, 2025 13:46
@ryenitcher
Add Dimmer Configuration Support
9b94eab
- Add: Support for configuring minimum dimming level.
- Add: Support for configuring dimmer ramp rate.
- Add: Support for configuring dimmer gentle fade time.
- Add: Support for configuring dimmper fade time.
@ryenitcher
Apply Suggested Changes
cdbac94
- Fix: Return time values as `timedelta` instead of `int`.
- Fix: Move constants to top of file.
- Fix: Correct feature types.
- Fix: Expose range of bounded features.
@ryenitcher
ryenitcher force-pushed the dev-dimcal branch from 77299dd to cdbac94 Compare January 26, 2025 20:46
@ryenitcher
Add IOT Dimmer Tests
535de3a
- Add: Tests for IOT Dimmer feature.
@ryenitcher

ryenitcher commented Jan 26, 2025

Copy link
Copy Markdown
Contributor Author

I'm not sure if it's worth writing a test for this line?

I doubt it will ever be triggered, and even then all it does its immediately return?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rytilahti
rytilahti approved these changes Jan 27, 2025
View reviewed changes

@rytilahti rytilahti left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Just some minor style-related nitpicks but this looks otherwise good to go, thanks @ryenitcher!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread kasa/iot/modules/dimmer.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread kasa/iot/modules/dimmer.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread kasa/iot/modules/dimmer.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread kasa/iot/modules/dimmer.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread kasa/iot/modules/dimmer.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread kasa/iot/modules/dimmer.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread kasa/iot/modules/dimmer.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread kasa/iot/modules/dimmer.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread kasa/iot/modules/dimmer.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread kasa/iot/modules/dimmer.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ryenitcher

ryenitcher commented Jan 28, 2025

Copy link
Copy Markdown
Contributor Author

Looks really great and it's nice to see also older devices getting some love, thanks @ryenitcher! 💯

It looks like the KS240 might be the only “new” dimmer so far (from searching the fixture files), but it looks like the config layout for the IOT version is roughly the same. I can copy over support to IOT in a follow up PR if that works. The new matter dimmer (KS225) might also be an IOT dimmer, but I don’t currently have one to test against.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ryenitcher
Formatting Corrections
f010a3b
- Fix: Correct inline comment formatting.
- Fix: Remove un-needed check for `get_dimmer_parameters` on dimmers.
- Fix: Remove extra newline from docstring summaries.
@ryenitcher

ryenitcher commented Feb 1, 2025

Copy link
Copy Markdown
Contributor Author

I think this PR should now be ready to go.

I've opened #1495 in draft status for calibration support on the SMART devices.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rytilahti
rytilahti approved these changes Feb 2, 2025
View reviewed changes

@rytilahti rytilahti left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM, thanks @ryenitcher! 🎉

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sdb9696 sdb9696 added this to the 0.10.1 milestone Feb 2, 2025
@sdb9696
sdb9696 merged commit bff5409 into python-kasa:master Feb 2, 2025
@sdb9696 sdb9696 mentioned this pull request Feb 2, 2025
Prepare 0.10.1 #1494
Merged
sdb9696 added a commit that referenced this pull request Feb 2, 2025
@sdb9696
Prepare 0.10.1 (#1494)
cbab40a
## [0.10.1](https://github.com/python-kasa/python-kasa/tree/0.10.1) (2025-02-02)

[Full Changelog](0.10.0...0.10.1)

**Release summary:**

Small patch release for bugfixes

**Implemented enhancements:**

- dustbin\_mode: add 'off' mode for cleaner downstream impl [\#1488](#1488) (@rytilahti)
- Add Dimmer Configuration Support [\#1484](#1484) (@ryenitcher)

**Fixed bugs:**

- Do not return empty string for custom light effect name [\#1491](#1491) (@sdb9696)
- Add FeatureAttributes to smartcam Alarm [\#1489](#1489) (@sdb9696)

**Project maintenance:**

- Add module.device to the public api [\#1478](#1478) (@sdb9696)
rytilahti pushed a commit to rytilahti/python-kasa that referenced this pull request Aug 31, 2025
@ryenitcher @rytilahti
Add Dimmer Configuration Support (python-kasa#1484)
b77aad8
rytilahti pushed a commit to rytilahti/python-kasa that referenced this pull request Aug 31, 2025
@sdb9696 @rytilahti
Prepare 0.10.1 (python-kasa#1494)
1c6ceb5
## [0.10.1](https://github.com/python-kasa/python-kasa/tree/0.10.1) (2025-02-02)

[Full Changelog](python-kasa/python-kasa@0.10.0...0.10.1)

**Release summary:**

Small patch release for bugfixes

**Implemented enhancements:**

- dustbin\_mode: add 'off' mode for cleaner downstream impl [\python-kasa#1488](python-kasa#1488) (@rytilahti)
- Add Dimmer Configuration Support [\python-kasa#1484](python-kasa#1484) (@ryenitcher)

**Fixed bugs:**

- Do not return empty string for custom light effect name [\python-kasa#1491](python-kasa#1491) (@sdb9696)
- Add FeatureAttributes to smartcam Alarm [\python-kasa#1489](python-kasa#1489) (@sdb9696)

**Project maintenance:**

- Add module.device to the public api [\python-kasa#1478](python-kasa#1478) (@sdb9696)
rytilahti pushed a commit to rytilahti/python-kasa that referenced this pull request Oct 26, 2025
@ryenitcher @rytilahti
Add Dimmer Configuration Support (python-kasa#1484)
cf25597
rytilahti pushed a commit to rytilahti/python-kasa that referenced this pull request Oct 26, 2025
@sdb9696 @rytilahti
Prepare 0.10.1 (python-kasa#1494)
9b22056
## [0.10.1](https://github.com/python-kasa/python-kasa/tree/0.10.1) (2025-02-02)

[Full Changelog](python-kasa/python-kasa@0.10.0...0.10.1)

**Release summary:**

Small patch release for bugfixes

**Implemented enhancements:**

- dustbin\_mode: add 'off' mode for cleaner downstream impl [\python-kasa#1488](python-kasa#1488) (@rytilahti)
- Add Dimmer Configuration Support [\python-kasa#1484](python-kasa#1484) (@ryenitcher)

**Fixed bugs:**

- Do not return empty string for custom light effect name [\python-kasa#1491](python-kasa#1491) (@sdb9696)
- Add FeatureAttributes to smartcam Alarm [\python-kasa#1489](python-kasa#1489) (@sdb9696)

**Project maintenance:**

- Add module.device to the public api [\python-kasa#1478](python-kasa#1478) (@sdb9696)
rytilahti pushed a commit to rytilahti/python-kasa that referenced this pull request Nov 10, 2025
@ryenitcher @rytilahti
Add Dimmer Configuration Support (python-kasa#1484)
aa627f7
rytilahti pushed a commit to rytilahti/python-kasa that referenced this pull request Nov 10, 2025
@sdb9696 @rytilahti
Prepare 0.10.1 (python-kasa#1494)
092771d
## [0.10.1](https://github.com/python-kasa/python-kasa/tree/0.10.1) (2025-02-02)

[Full Changelog](python-kasa/python-kasa@0.10.0...0.10.1)

**Release summary:**

Small patch release for bugfixes

**Implemented enhancements:**

- dustbin\_mode: add 'off' mode for cleaner downstream impl [\python-kasa#1488](python-kasa#1488) (@rytilahti)
- Add Dimmer Configuration Support [\python-kasa#1484](python-kasa#1484) (@ryenitcher)

**Fixed bugs:**

- Do not return empty string for custom light effect name [\python-kasa#1491](python-kasa#1491) (@sdb9696)
- Add FeatureAttributes to smartcam Alarm [\python-kasa#1489](python-kasa#1489) (@sdb9696)

**Project maintenance:**

- Add module.device to the public api [\python-kasa#1478](python-kasa#1478) (@sdb9696)
rytilahti pushed a commit to rytilahti/python-kasa that referenced this pull request Jul 5, 2026
@ryenitcher @rytilahti
Add Dimmer Configuration Support (python-kasa#1484)
dfdb363
rytilahti pushed a commit to rytilahti/python-kasa that referenced this pull request Jul 5, 2026
@sdb9696 @rytilahti
Prepare 0.10.1 (python-kasa#1494)
15a8bf8
## [0.10.1](https://github.com/python-kasa/python-kasa/tree/0.10.1) (2025-02-02)

[Full Changelog](python-kasa/python-kasa@0.10.0...0.10.1)

**Release summary:**

Small patch release for bugfixes

**Implemented enhancements:**

- dustbin\_mode: add 'off' mode for cleaner downstream impl [\python-kasa#1488](python-kasa#1488) (@rytilahti)
- Add Dimmer Configuration Support [\python-kasa#1484](python-kasa#1484) (@ryenitcher)

**Fixed bugs:**

- Do not return empty string for custom light effect name [\python-kasa#1491](python-kasa#1491) (@sdb9696)
- Add FeatureAttributes to smartcam Alarm [\python-kasa#1489](python-kasa#1489) (@sdb9696)

**Project maintenance:**

- Add module.device to the public api [\python-kasa#1478](python-kasa#1478) (@sdb9696)
pillarsdotnet pushed a commit to pillarsdotnet/python-kasa that referenced this pull request Oct 22, 2026
@ryenitcher
Add Dimmer Configuration Support (python-kasa#1484)
24482b9
pillarsdotnet pushed a commit to pillarsdotnet/python-kasa that referenced this pull request Oct 22, 2026
@sdb9696
Prepare 0.10.1 (python-kasa#1494)
179d5e9
## [0.10.1](https://github.com/python-kasa/python-kasa/tree/0.10.1) (2025-02-02)

[Full Changelog](python-kasa/python-kasa@0.10.0...0.10.1)

**Release summary:**

Small patch release for bugfixes

**Implemented enhancements:**

- dustbin\_mode: add 'off' mode for cleaner downstream impl [\python-kasa#1488](python-kasa#1488) (@rytilahti)
- Add Dimmer Configuration Support [\python-kasa#1484](python-kasa#1484) (@ryenitcher)

**Fixed bugs:**

- Do not return empty string for custom light effect name [\python-kasa#1491](python-kasa#1491) (@sdb9696)
- Add FeatureAttributes to smartcam Alarm [\python-kasa#1489](python-kasa#1489) (@sdb9696)

**Project maintenance:**

- Add module.device to the public api [\python-kasa#1478](python-kasa#1478) (@sdb9696)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sdb9696 sdb9696 sdb9696 left review comments
@rytilahti rytilahti rytilahti approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

enhancement New feature or request

Projects

None yet

Milestone

0.10.1

Development

Successfully merging this pull request may close these issues.

Dimmer Calibration? NOT Presets

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@ryenitcher @rytilahti @sdb9696
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.