'Subscribe all required events to handle job.'

def _subscribe_homematic_events(self):

    channels_to_sub = set()
    channels_to_sub.add(0)
    for metadata in (self._hmdevice.SENSORNODE, self._hmdevice.BINARYNODE, self._hmdevice.ATTRIBUTENODE, self._hmdevice.WRITENODE, self._hmdevice.EVENTNODE, self._hmdevice.ACTIONNODE):
        for (node, channels) in metadata.items():
            if (node in self._data):
                if (len(channels) == 1):
                    channel = channels[0]
                else:
                    channel = self._channel
                try:
                    channels_to_sub.add(int(channel))
                except (ValueError, TypeError):
                    _LOGGER.error('Invalid    channel    in    metadata    from    %s', self._name)
    for channel in channels_to_sub:
        _LOGGER.debug('Subscribe    channel    %d    from    %s', channel, self._name)
        self._hmdevice.setEventCallback(callback=self._hm_event_callback, bequeath=False, channel=channel)
