Exemplo n.º 1
0
    def update_link_quality(self, device_data, message):
        config = domoticz.get_plugin_config()
        if config["trackLinkQuality"] == False:
            return None

        if 'linkquality' in message.raw:
            device = self.get_device_by_alias('signal')
            device.handle_message(device_data, message)
    def __init__(self):
        super().__init__()

        if domoticz.get_plugin_config('useBatteryDevices'):
            self.devices.append(
                VoltageSensor('cell', 'battery_voltage', ' (Battery Voltage)'))
            self.devices.append(
                PercentageSensor('btperc', 'battery', ' (Battery)'))
Exemplo n.º 3
0
    def update_battery_status(self, device_data, message):
        if domoticz.get_plugin_config('useBatteryDevices') == False:
            return

        if 'battery_voltage' in message.raw:
            device = self.get_device_by_alias('cell')
            device.handle_message(device_data, message)

        if 'battery' in message.raw:
            device = self.get_device_by_alias('btperc')
            device.handle_message(device_data, message)
Exemplo n.º 4
0
def has(device_id):
    blacklist_raw = domoticz.get_plugin_config('blackList')

    if blacklist_raw == '':
        return False

    blacklist = blacklist_raw.split(';')

    for pattern in blacklist:
        if re.match(pattern.strip(), device_id):
            return True

    return False
Exemplo n.º 5
0
    def _get_adapter(self, group_name):
        if (group_name.endswith('_dimmer')):
            adapter = DimmableBulbAdapter()
        elif (group_name.endswith('_ct')):
            adapter = DimmableCtBulbAdapter()
        elif (group_name.endswith('_rgb')):
            adapter = RGBAdapter()
        elif (group_name.endswith('_rgbw')):
            adapter = RGBWAdapter()
        else:
            adapter = OnOffSwitchAdapter()

        # Remove LinkQuality device from adapter
        if domoticz.get_plugin_config('trackLinkQuality'):
            adapter.devices.pop(0)

        return adapter
Exemplo n.º 6
0
    def add_numeric_device(self, feature):
        state_access = self._has_access(feature['access'], ACCESS_STATE)
        write_access = self._has_access(feature['access'], ACCESS_WRITE)

        # TODO: Use energy value for `power` feature
        if feature['name'] == 'energy':
            return

        if (feature['name'] == 'linkquality' and state_access):
            if domoticz.get_plugin_config('trackLinkQuality'):
                self._add_device('signal', feature, CustomSensor, ' (Link Quality)')
            return

        if (feature['name'] == 'battery' and state_access):
            if domoticz.get_plugin_config('useBatteryDevices'):
                self._add_device('btperc', feature, PercentageSensor, ' (Battery)')
            return

        if (feature['name'] == 'brightness' and state_access):
            alias = self._generate_alias(feature, 'light')
            self._add_device(alias, feature, DimmerSwitch)
            return

        if (feature['name'] == 'illuminance' and state_access):
            alias = self._generate_alias(feature, 'lux')
            self._add_device(alias, feature, LuxSensor, ' (Illuminance)')
            return

        if (feature['name'] == 'illuminance_lux' and state_access):
            alias = self._generate_alias(feature, 'lx')
            self._add_device(alias, feature, LuxSensor, ' (Illuminance Lux)')
            return

        if (feature['name'] == 'local_temperature' and state_access):
            alias = self._generate_alias(feature, 'ltemp')
            self._add_device(alias, feature, TemperatureSensor, ' (Local Temperature)')
            return

        if (feature['name'] == 'soil_moisture' and state_access):
            alias = self._generate_alias(feature, 'pres')
            self._add_device(alias, feature, PercentageSensor, ' (Soil Moisture)')
            return

        if (feature['name'] == 'voltage' and state_access):
            alias = self._generate_alias(feature, 'volt')
            self._add_device(alias, feature, VoltageSensor, ' (Voltage)')
            return

        if (feature['name'] == 'current' and state_access):
            alias = self._generate_alias(feature, 'ampere')
            self._add_device(alias, feature, CurrentSensor, ' (Current)')
            return

        if 'setpoint' in feature['name'] and feature['unit'] == '°C' and write_access:
            alias = self._generate_alias(feature, 'spoint')
            self._add_device(alias, feature, SetPoint, ' (Setpoint)')
            return

        if (feature['name'] == 'position' and state_access):
            alias = self._generate_alias(feature, 'level')
            self._add_device(alias, feature, LevelSwitch)
            return
        
        if (feature['name'] == 'color_temp_startup' and state_access):
            return

        if (feature['name'] == 'requested_brightness_level' and state_access):
            return

        if (feature['name'] == 'requested_brightness_percent' and state_access):
            return

        domoticz.error(self.name + ': can not process numeric item "' + feature['name'] + '"')
        domoticz.debug(json.dumps(feature))
Exemplo n.º 7
0
    def __init__(self, domoticz_devices):
        self.devices = []

        if domoticz.get_plugin_config('trackLinkQuality'):
            self.devices.append(CustomSensor(domoticz_devices, 'signal', 'linkquality', ' (Link Quality)'))
    def add_numeric_device(self, feature):
        state_access = self._has_access(feature['access'], ACCESS_STATE)
        write_access = self._has_access(feature['access'], ACCESS_WRITE)

        # TODO: Use energy value for `power` feature
        if feature['name'] == 'energy':
            return

        if (feature['name'] == 'linkquality' and state_access):
            if domoticz.get_plugin_config('trackLinkQuality'):
                self._add_device('signal', feature, CustomSensor,
                                 ' (Link Quality)')
            return

        if (feature['name'] == 'battery' and state_access):
            if domoticz.get_plugin_config('useBatteryDevices'):
                self._add_device('btperc', feature, PercentageSensor,
                                 ' (Battery)')
            return

        if (feature['name'] == 'brightness' and state_access):
            alias = feature['endpoint'] if 'endpoint' in feature else 'light'
            self._add_device(alias, feature, DimmerSwitch)
            return

        if (feature['name'] == 'humidity' and state_access):
            self._add_device('hum', feature, HumiditySensor, ' (Humidity)')
            return

        if (feature['name'] == 'temperature' and state_access):
            self._add_device('temp', feature, TemperatureSensor,
                             ' (Temperature)')
            return

        if (feature['name'] == 'local_temperature' and state_access):
            self._add_device('ltemp', feature, TemperatureSensor,
                             ' (Local Temperature)')
            return

        if (feature['name'] == 'pressure' and state_access):
            self._add_device('pres', feature, PressureSensor, ' (Pressure)')
            return

        if (feature['name'] == 'voltage' and state_access):
            self._add_device('volt', feature, VoltageSensor, ' (Voltage)')
            return

        if (feature['name'] == 'current' and state_access):
            self._add_device('ampere', feature, CurrentSensor, ' (Current)')
            return

        if (feature['name'] == 'power' and state_access
                and feature['unit'] == 'W'):
            device = KwhSensor(domoticz.get_devices(), 'power',
                               [feature['property']], ' (Power)')
            device.feature = feature
            self.devices.append(device)
            return

        if 'setpoint' in feature['name'] and feature[
                'unit'] == '°C' and write_access:
            alias = feature['endpoint'] if 'endpoint' in feature else 'spoint'
            self._add_device(alias, feature, SetPoint, ' (Setpoint)')
            return

        if (feature['name'] == 'position' and state_access):
            alias = feature['endpoint'] if 'endpoint' in feature else 'level'
            self._add_device(alias, feature, LevelSwitch)
            return

        domoticz.error(self.name + ': can not process numeric item "' +
                       feature['name'] + '"')
        domoticz.debug(json.dumps(feature))