Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Fix callbacks for channel 0 #159

Merged
merged 1 commit into from
Aug 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pyhomematic/devicetypes/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ def event(self, interface_id, key, value):
% (self._ADDRESS, interface_id, key, value))
if key == PARAM_UNREACH:
self._unreach = value
if not self._eventcallbacks:
LOG.debug("HMGeneric.event: No callbacks registered for event %s (%s)", key, str(self))

for callback in self._eventcallbacks:
LOG.debug("HMDevice.event: Using callback %s " % str(callback))
callback(self._ADDRESS, interface_id, key, value)
Expand Down Expand Up @@ -352,9 +355,14 @@ def setEventCallback(self, callback, bequeath=True, channel=0):
Signature for callback-functions: foo(address, interface_id, key, value)
"""
if hasattr(callback, '__call__'):
LOG.debug(
"Adding callback '%s' for %s:%s (%s)",
str(callback), self._name, channel, str(self)
)

if channel == 0:
self._eventcallbacks.append(callback)
elif not bequeath and channel > 0 and channel in self._hmchannels:
if not bequeath and channel in self._hmchannels:
self._hmchannels[channel]._eventcallbacks.append(callback)
if bequeath:
for channel, device in self._hmchannels.items():
Expand Down