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

Commit

Permalink
Merge pull request #161 from klada/fix_unreach_callbacks
Browse files Browse the repository at this point in the history
Fix callbacks for channel 0
  • Loading branch information
danielperna84 authored Aug 26, 2018
2 parents 96c0960 + 368d051 commit 66c1c30
Showing 1 changed file with 9 additions and 1 deletion.
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

0 comments on commit 66c1c30

Please sign in to comment.