Exemplo n.º 1
0
    def handle_command(self, device_id, unit, command, level, color):
        alias = configuration.get_zigbee_feature_data(device_id, unit)
        device = domoticz.get_device(device_id, unit)
        adapter = self.get_group_by_id(alias['zigbee']['address'])

        if adapter == None:
            return None

        return adapter.handle_command(alias, device, command, level, color)
def get_zigbee_feature_device(device_address, feature_name, endpoint):
    item = get_alias_by_zigbee(device_address, feature_name, endpoint)

    if item != None:
        domoticz_data = item['domoticz']
        return domoticz.get_device(domoticz_data['device_id'],
                                   domoticz_data['unit'])

    return None
Exemplo n.º 3
0
    def _get_transport_device(self):
        device = domoticz.get_device('api_transport', 255)

        if device == None:
            device = domoticz.create_device(Unit=255,
                                            DeviceID='api_transport',
                                            Name='Zigbee2MQTT API Transport',
                                            TypeName="Text")

        return device
Exemplo n.º 4
0
    def handle_command(self, device_id, unit, command, level, color):
        try:
            domoticz_device = domoticz.get_device(device_id, unit)
            config = configuration.get_zigbee_feature_data(device_id, unit)

            alias = config['domoticz']['legacy_alias']
            device_address = config['zigbee']['address']
            adapter = self.devices[device_address]
        except:
            return

        return adapter.handle_command(alias, domoticz_device, command, level,
                                      color)
    def onCommand(self, device_id, unit, command, Level, Color):
        domoticz.debug("[Command] Device " + device_id + '(' + str(unit) +
                       '): ' + command + "(level = " + str(Level) +
                       ", color = " + Color + ')')

        message = None
        domoticz_device = domoticz.get_device(device_id, unit)
        zigbee_device_alias = configuration.get_zigbee_feature_data(
            device_id, unit)

        if zigbee_device_alias == None:
            domoticz.log('Can\'t process command from device "' +
                         domoticz_device.Name + '"')

        if self.groups_manager.get_group_by_id(
                zigbee_device_alias['zigbee']['address']) != None:
            message = self.groups_manager.handle_command(
                device_id, unit, command, Level, Color)
        else:
            message = self.devices_manager.handle_command(
                device_id, unit, command, Level, Color)

        if (message != None):
            self.publishToMqtt(message['topic'], message['payload'])
 def onDeviceModified(self, device_id, unit):
     if device_id == 'api_transport' and unit == 255:
         device = domoticz.get_device(device_id, unit)
         self.api.handle_request(device.sValue)
         return