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 — Fix changing brightness when effect is active by rytilahti · Pull Request #1019 · python-kasa/python-kasa

Conversation

@rytilahti

@rytilahti rytilahti commented Jun 27, 2024 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

This PR changes the behavior of brightness module if an effect is active.
Currently, changing the brightness disables the effect when the brightness is changed, this fixes that.
This will also improve the set_effect interface to use the current brightness when an effect is activated.

  • light_strip_effect: passing bAdjusted with the changed properties changes the brightness.
  • light_effect: the brightness is stored only in the rule, so we modify it when adjusting the brightness. This is also done during the initial effect activation.

Sorry, something went wrong.

Uh oh!

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

All reactions
rytilahti added 2 commits June 27, 2024 14:32
@rytilahti
Implement effect brightness for lightstripeffect
0310299
@rytilahti
Implement effect brightness for light_effect
e52e1ef
Note, this edits the active effect
@rytilahti rytilahti added the enhancement New feature or request label Jun 27, 2024
@rytilahti rytilahti changed the title Implement effect brightness Fix changing brightness when effect is active Jun 27, 2024
@rytilahti rytilahti added this to the 0.7.0.2 milestone Jun 27, 2024
@codecov

codecov Bot commented Jun 27, 2024 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 95.89041% with 3 lines in your changes missing coverage. Please review.

Project coverage is 91.42%. Comparing base (2a62849) to head (88e3310).
Report is 89 commits behind head on master.

Files with missing lines Patch % Lines
kasa/smart/modules/lightstripeffect.py 88.00% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1019      +/-   ##
==========================================
+ Coverage   91.33%   91.42%   +0.08%     
==========================================
  Files          84       84              
  Lines        5657     5724      +67     
  Branches     1371     1392      +21     
==========================================
+ Hits         5167     5233      +66     
  Misses        382      382              
- Partials      108      109       +1     

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

All reactions

Sorry, something went wrong.

Uh oh!

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

rytilahti added 4 commits June 28, 2024 15:29
@rytilahti
Fix tests
c49fe87
@rytilahti
Update tutorial.py
d00d34b
@rytilahti
Add tests to light effect brightness
177e9c6
@rytilahti
Remove is_active, brightness, and set_brightness from the common inte…
9526ca2
…rface
@rytilahti
rytilahti force-pushed the fix/effect_brightness branch from 801744a to 9526ca2 Compare June 28, 2024 13:33
rytilahti added 2 commits June 28, 2024 17:24
@rytilahti
Extract brightness interface into smartlighteffect interface
0b8954e
@rytilahti
add a comment about bAdjusted
7c66677
rytilahti
rytilahti commented Jun 28, 2024
View reviewed changes
Comment thread kasa/smart/effects.py Resolved

Uh oh!

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

sdb9696
sdb9696 approved these changes Jun 28, 2024
View reviewed changes

@sdb9696 sdb9696 left a comment

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.

Looks really good. Happy for you to merge if you want to defer the comment about the custom effect test to later.

Will update the branch with master.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread kasa/smart/effects.py Resolved

Uh oh!

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

Comment thread kasa/tests/fakeprotocol_smart.py Resolved

Uh oh!

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

Comment thread docs/tutorial.py Outdated
>>> for feat in dev.features.values():
>>> print(f"{feat.name}: {feat.value}")
Device ID: 0000000000000000000000000000000000000000\nState: True\nSignal Level: 2\nRSSI: -52\nSSID: #MASKED_SSID#\nOverheated: False\nBrightness: 50\nCloud connection: True\nHSV: HSV(hue=0, saturation=100, value=50)\nColor temperature: 2700\nAuto update enabled: True\nUpdate available: False\nCurrent firmware version: 1.1.6 Build 240130 Rel.173828\nAvailable firmware version: 1.1.6 Build 240130 Rel.173828\nLight effect: Party\nLight preset: Light preset 1\nSmooth transition on: 2\nSmooth transition off: 2\nDevice time: 2024-02-23 02:40:15+01:00
Device ID: 0000000000000000000000000000000000000000\nState: True\nSignal Level: 2\nRSSI: -52\nSSID: #MASKED_SSID#\nOverheated: False\nBrightness: 100\nCloud connection: True\nHSV: HSV(hue=0, saturation=100, value=50)\nColor temperature: 2700\nAuto update enabled: True\nUpdate available: False\nCurrent firmware version: 1.1.6 Build 240130 Rel.173828\nAvailable firmware version: 1.1.6 Build 240130 Rel.173828\nLight effect: Party\nLight preset: Not set\nSmooth transition on: 2\nSmooth transition off: 2\nDevice time: 2024-02-23 02:40:15+01:00

@sdb9696 sdb9696 Jun 28, 2024

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.

I'm guessing the test_readme_examples.py picked this up. Great to see it working 😄

Sorry, something went wrong.

Uh oh!

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

All reactions

@rytilahti rytilahti Jun 29, 2024

Copy link
Copy Markdown
Member 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, it was picked up by tests indeed 🎉 Bad news is, that this is actually wrong output as setting the effect is supposed to keep the brightness in the previously set 50...

Sorry, something went wrong.

Uh oh!

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

All reactions

@rytilahti rytilahti Jun 30, 2024

Copy link
Copy Markdown
Member 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.

So, the issue here was that the code was not changing the brightness when activating the effect. This should be now fixed, but the test bulb still thinks that it has an active preset.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread kasa/smart/modules/lightstripeffect.py Resolved

Uh oh!

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

@sdb9696
Merge branch 'master' into fix/effect_brightness
82e6e13
@sdb9696 sdb9696 closed this Jun 28, 2024
@sdb9696 sdb9696 reopened this Jun 28, 2024
rytilahti added 3 commits June 30, 2024 16:01
@rytilahti
Add explicit tests for light_strip_effect
af42812
@rytilahti
Fix test_deprecated_light_effects not passing brightness
23584ad
@rytilahti
Fix brightness setting when activating an effect on already turned on…
ead8f73
… bulb
rytilahti
rytilahti commented Jun 30, 2024
View reviewed changes
Comment thread kasa/tests/test_common_modules.py Resolved

Uh oh!

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

@rytilahti
cleanup
8af23c8
@rytilahti
rytilahti requested a review from sdb9696 June 30, 2024 15:31
@sdb9696
Fix switching off light strip effects (#1024)
88e3310
sdb9696
sdb9696 approved these changes Jul 1, 2024
View reviewed changes

@sdb9696 sdb9696 left a comment

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.

LGTM, let's merge!

Sorry, something went wrong.

Uh oh!

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

All reactions
@rytilahti
rytilahti merged commit b31a2ed into master Jul 1, 2024
@rytilahti
rytilahti deleted the fix/effect_brightness branch July 1, 2024 11:59
@sdb9696 sdb9696 added bug Something isn't working and removed enhancement New feature or request labels Jul 1, 2024
@sdb9696 sdb9696 mentioned this pull request Jul 1, 2024
Prepare 0.7.0.2 #1028
Merged
sdb9696 added a commit that referenced this pull request Jul 1, 2024
@sdb9696
Prepare 0.7.0.2 (#1028)
38a8c96
## [0.7.0.2](https://github.com/python-kasa/python-kasa/tree/0.7.0.2) (2024-07-01)

[Full Changelog](0.7.0.1...0.7.0.2)

This patch release fixes some minor issues found out during testing against all new homeassistant platforms.

**Fixed bugs:**

- Disable multi-request on unknown errors [\#1027](#1027) (@sdb9696)
- Disable multi requests on json decode error during multi-request [\#1025](#1025) (@sdb9696)
- Fix changing brightness when effect is active [\#1019](#1019) (@rytilahti)
- Update light transition module to work with child devices [\#1017](#1017) (@sdb9696)
- Handle unknown error codes gracefully [\#1016](#1016) (@rytilahti)

**Project maintenance:**

- Make parent attribute on device consistent across iot and smart [\#1023](#1023) (@sdb9696)
- Cache SmartErrorCode creation [\#1022](#1022) (@bdraco)
pillarsdotnet pushed a commit to pillarsdotnet/python-kasa that referenced this pull request Oct 22, 2026
@rytilahti @sdb9696
Fix changing brightness when effect is active (python-kasa#1019)
4e37191
This PR changes the behavior of `brightness` module if an effect is
active.
Currently, changing the brightness disables the effect when the
brightness is changed, this fixes that.
This will also improve the `set_effect` interface to use the current
brightness when an effect is activated.

* light_strip_effect: passing `bAdjusted` with the changed properties
changes the brightness.
* light_effect: the brightness is stored only in the rule, so we modify
it when adjusting the brightness. This is also done during the initial
effect activation.

---------

Co-authored-by: Steven B <[email protected]>
pillarsdotnet pushed a commit to pillarsdotnet/python-kasa that referenced this pull request Oct 22, 2026
@sdb9696
Prepare 0.7.0.2 (python-kasa#1028)
c89adc3
## [0.7.0.2](https://github.com/python-kasa/python-kasa/tree/0.7.0.2) (2024-07-01)

[Full Changelog](python-kasa/python-kasa@0.7.0.1...0.7.0.2)

This patch release fixes some minor issues found out during testing against all new homeassistant platforms.

**Fixed bugs:**

- Disable multi-request on unknown errors [\python-kasa#1027](python-kasa#1027) (@sdb9696)
- Disable multi requests on json decode error during multi-request [\python-kasa#1025](python-kasa#1025) (@sdb9696)
- Fix changing brightness when effect is active [\python-kasa#1019](python-kasa#1019) (@rytilahti)
- Update light transition module to work with child devices [\python-kasa#1017](python-kasa#1017) (@sdb9696)
- Handle unknown error codes gracefully [\python-kasa#1016](python-kasa#1016) (@rytilahti)

**Project maintenance:**

- Make parent attribute on device consistent across iot and smart [\python-kasa#1023](python-kasa#1023) (@sdb9696)
- Cache SmartErrorCode creation [\python-kasa#1022](python-kasa#1022) (@bdraco)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sdb9696 sdb9696 sdb9696 approved these changes

Uh oh!

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

Assignees

No one assigned

Labels

bug Something isn't working

Projects

None yet

Milestone

0.7.0.2

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

2 participants

@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.