Skip to content

Commit

Permalink
Add support for Flashing
Browse files Browse the repository at this point in the history
Add the flash method for outputs.  This takes an optional fade_time_seconds.

Factor out the helper to take the optional fade time seconds and turn it into something that lutron is happy to parse.
  • Loading branch information
cdheiser authored Jan 31, 2024
1 parent 40f7f42 commit 6ef9dc5
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions pylutron/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ class Output(LutronEntity):
switched/dimmed load, e.g. light fixture, outlet, etc."""
_CMD_TYPE = 'OUTPUT'
_ACTION_ZONE_LEVEL = 1
_ACTION_ZONE_FLASH = 5

class Event(LutronEvent):
"""Output events that can be generated.
Expand Down Expand Up @@ -728,18 +729,26 @@ def level(self, new_level):
"""Sets the new output level."""
self.set_level(new_level)

@staticmethod
def _fade_time(seconds):
if seconds is None:
return None
return str(timedelta(seconds=seconds))

def set_level(self, new_level, fade_time_seconds=None):
"""Sets the new output level."""
if self._level == new_level:
return
if fade_time_seconds is not None:
fade_time = str(timedelta(seconds=fade_time_seconds))
else:
fade_time = None
self._lutron.send(Lutron.OP_EXECUTE, Output._CMD_TYPE, self._integration_id,
Output._ACTION_ZONE_LEVEL, "%.2f" % new_level, fade_time)
Output._ACTION_ZONE_LEVEL, "%.2f" % new_level, self._fade_time(fade_time_seconds))
self._level = new_level

def flash(self, fade_time_seconds=None):
"""Flashes the zone until a new level is set."""
self._lutron.send(Lutron.OP_EXECUTE, Output._CMD_TYPE, self._integration_id,
Output._ACTION_ZONE_FLASH, self._fade_time(fade_time_seconds))


## At some later date, we may want to also specify delay times
# def set_level(self, new_level, fade_time_seconds, delay):
# self._lutron.send(Lutron.OP_EXECUTE, Output._CMD_TYPE,
Expand Down

0 comments on commit 6ef9dc5

Please sign in to comment.