Skip to content

Commit

Permalink
Generate Legacy UUIDs using IntegrationIDs and other information. (#90)
Browse files Browse the repository at this point in the history
* Add support for generating UUIDs with older firmware.

Much older Lutron firmware doesn't have UUIDs.  We generate legacy UUIDs using the integration IDs and component numbers.  These are accessible via the legacy_uuid property and should work for all versions of firmware.

Note: Integration ids can/do change when significant changes are made to the programming of a system which is why UUIDs exist in the first place.
  • Loading branch information
cdheiser authored Feb 12, 2024
1 parent 6ef9dc5 commit 8b63996
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pylutron/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,11 @@ def name(self):
def uuid(self):
return self._uuid

@property
def legacy_uuid(self):
"""Return a synthesized uuid."""
return None

def _dispatch_event(self, event: LutronEvent, params: Dict):
"""Dispatches the specified event to all the subscribers."""
for handler, context in self._subscribers:
Expand Down Expand Up @@ -693,6 +698,10 @@ def id(self):
"""The integration id"""
return self._integration_id

@property
def legacy_uuid(self):
return '%d-0' % self.id

def handle_update(self, args):
"""Handles an event update for this object, e.g. dimmer level change."""
_LOGGER.debug("handle_update %d -- %s" % (self._integration_id, args))
Expand Down Expand Up @@ -816,6 +825,10 @@ def component_number(self):
is only used for interfacing with the controller."""
return self._component_num

@property
def legacy_uuid(self):
return '%d-%d' % (self._keypad.id, self._component_num)

def handle_update(self, action, params):
"""Handle the specified action on this component."""
_LOGGER.debug('Keypad: "%s" Handling "%s" Action: %s Params: %s"' % (
Expand Down Expand Up @@ -1018,6 +1031,10 @@ def id(self):
"""The integration id"""
return self._integration_id

@property
def legacy_uuid(self):
return '%d-0' % self.id

@property
def name(self):
"""Returns the name of this keypad"""
Expand Down Expand Up @@ -1114,6 +1131,10 @@ def id(self):
"""The integration id"""
return self._integration_id

@property
def legacy_uuid(self):
return str(self.id)

def __str__(self):
"""Returns a pretty-printed string for this object."""
return 'MotionSensor {} Id: {} Battery: {} Power: {}'.format(
Expand Down Expand Up @@ -1211,6 +1232,10 @@ def id(self):
"""The integration id"""
return self._integration_id

@property
def legacy_uuid(self):
return '%s-%s' % (self._area.id, self._group_number)

@property
def group_number(self):
"""The OccupancyGroupNumber"""
Expand Down

0 comments on commit 8b63996

Please sign in to comment.