Skip to content

Commit

Permalink
Add set_dimming_delta method
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
olsen-sorensen committed Oct 6, 2024
1 parent 3821a01 commit aad9012
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions aiohue/v2/controllers/lights.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
ColorFeaturePut,
ColorPoint,
ColorTemperatureFeaturePut,
DeltaAction,
DimmingFeaturePut,
DimmingDeltaFeaturePut,
DynamicsFeaturePut,
EffectsFeaturePut,
EffectStatus,
Expand Down Expand Up @@ -100,3 +102,20 @@ async def set_state(
elif effect is not None:
update_obj.effects = EffectsFeaturePut(effect=effect)
await self.update(id, update_obj)

async def set_dimming_delta(
self, id: str, brightness_delta: float | None = None
) -> None:
"""
Set brightness_delta value and action via DimmingDeltaFeature.
The action to be send depends on brightness_delta value:
> 0: UP,
< 0: DOWN,
else: STOP (this immediately stops any dimming transition)
"""
if brightness_delta is not None:
update_obj = LightPut()
action = DeltaAction.DOWN if brightness_delta < 0 else DeltaAction.UP if brightness_delta > 0 else DeltaAction.STOP
update_obj.dimming_delta = DimmingDeltaFeaturePut(action=action, brightness_delta=brightness_delta)
await self.update(id, update_obj)

0 comments on commit aad9012

Please sign in to comment.