Skip to content
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

Add dimming_delta support #417

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

olsen-sorensen
Copy link

@olsen-sorensen olsen-sorensen commented Oct 4, 2024

This method sets the brightness_delta value and its action based on the
value to up/down/stop. This can be useful if someone wants to dim a light to
the max/min value within a dedicated transition time but stop the
transition when for instance a btn was released.

resolves #420

@olsen-sorensen
Copy link
Author

olsen-sorensen commented Oct 4, 2024

I think it makes sense to open the libraries api a bit more to support dimming_delta functionality. So I'll change the code in a more generic way like

set_brightness_delta(brightness_delta: float | None = None)

if brightness is None we do not send any update, however this should not happen :)

@olsen-sorensen olsen-sorensen marked this pull request as draft October 4, 2024 06:12
@olsen-sorensen olsen-sorensen changed the title Add stop_dimming method Add dimming_delta support Oct 4, 2024
@olsen-sorensen olsen-sorensen marked this pull request as ready for review October 6, 2024 08:41
@olsen-sorensen olsen-sorensen force-pushed the feature/add_stop_dimming branch 2 times, most recently from 6bab2fe to aa4d88b Compare October 6, 2024 14:46
This method sets the brightness_delta value and its action based on the
value to up/down/stop. This can be useful if someone wants to dim a light to
the max/min value within a dedicated transition time but stop the
transition  when for instance a btn was released.
"""
if brightness_delta is not None:
update_obj = GroupedLightPut()
action = DeltaAction.DOWN if brightness_delta < 0 else DeltaAction.UP if brightness_delta > 0 else DeltaAction.STOP
Copy link
Collaborator

Choose a reason for hiding this comment

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

please split this one up into a specific definition for the None case

if brightness_delta is None or brightness_delta == 0:
    action = DeltaAction.STOP
elif brightness_delta < 0:
  ...
else:
    ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature dimming_delta not supported
2 participants