Prioritize channels for homematic event subscriptions (#56619)
* Prioritize SENSORNODE for event callbacks * Ran black * Use lazy % formatting for logging Co-authored-by: Franck Nijhof <git@frenck.dev>pull/68905/head
parent
ca1337d9c2
commit
94fde3bf23
|
@ -50,7 +50,7 @@ class HMDevice(Entity):
|
|||
self._data: dict[str, str] = {}
|
||||
self._connected = False
|
||||
self._available = False
|
||||
self._channel_map: set[str] = set()
|
||||
self._channel_map: dict[str, str] = {}
|
||||
|
||||
if entity_description is not None:
|
||||
self.entity_description = entity_description
|
||||
|
@ -127,7 +127,7 @@ class HMDevice(Entity):
|
|||
has_changed = False
|
||||
|
||||
# Is data needed for this instance?
|
||||
if f"{attribute}:{device.partition(':')[2]}" in self._channel_map:
|
||||
if device.partition(":")[2] == self._channel_map.get(attribute):
|
||||
self._data[attribute] = value
|
||||
has_changed = True
|
||||
|
||||
|
@ -143,12 +143,12 @@ class HMDevice(Entity):
|
|||
def _subscribe_homematic_events(self):
|
||||
"""Subscribe all required events to handle job."""
|
||||
for metadata in (
|
||||
self._hmdevice.SENSORNODE,
|
||||
self._hmdevice.BINARYNODE,
|
||||
self._hmdevice.ATTRIBUTENODE,
|
||||
self._hmdevice.WRITENODE,
|
||||
self._hmdevice.EVENTNODE,
|
||||
self._hmdevice.ACTIONNODE,
|
||||
self._hmdevice.EVENTNODE,
|
||||
self._hmdevice.WRITENODE,
|
||||
self._hmdevice.ATTRIBUTENODE,
|
||||
self._hmdevice.BINARYNODE,
|
||||
self._hmdevice.SENSORNODE,
|
||||
):
|
||||
for node, channels in metadata.items():
|
||||
# Data is needed for this instance
|
||||
|
@ -159,7 +159,9 @@ class HMDevice(Entity):
|
|||
else:
|
||||
channel = self._channel
|
||||
# Remember the channel for this attribute to ignore invalid events later
|
||||
self._channel_map.add(f"{node}:{channel!s}")
|
||||
self._channel_map[node] = str(channel)
|
||||
|
||||
_LOGGER.debug("Channel map for %s: %s", self._address, str(self._channel_map))
|
||||
|
||||
# Set callbacks
|
||||
self._hmdevice.setEventCallback(callback=self._hm_event_callback, bequeath=True)
|
||||
|
|
Loading…
Reference in New Issue