class KonkeButton(AdapterWithBattery): def __init__(self, devices): super().__init__(devices) self.switch = SelectorSwitch(devices, 'switch', 'click') self.switch.add_level('Off', None) self.switch.add_level('Click', 'single') self.switch.add_level('Double Click', 'double') self.switch.add_level('Long Click', 'long') self.switch.set_selector_style(SelectorSwitch.SELECTOR_TYPE_MENU) self.switch.disable_value_check_on_update() self.devices.append(self.switch) def handleCommand(self, alias, device, device_data, command, level, color): self.switch.handle_command(device_data, command, level, color)
class HueDimmerSwitch(AdapterWithBattery): def __init__(self): super().__init__() self.switch = SelectorSwitch('dimmer', 'action') self.switch.add_level('off-press', 'off-press') self.switch.add_level('off-press-double', 'off-press-double') self.switch.add_level('off-press-triple', 'off-press-triple') self.switch.add_level('off-hold', 'off-hold') self.switch.add_level('off-hold-release', 'off-hold-release') self.switch.add_level('down-press', 'down-press') self.switch.add_level('down-press-double', 'down-press-double') self.switch.add_level('down-press-triple', 'down-press-triple') self.switch.add_level('down-hold', 'down-hold') self.switch.add_level('down-hold-release', 'down-hold-release') self.switch.add_level('up-press', 'up-press') self.switch.add_level('up-press-double', 'up-press-double') self.switch.add_level('up-press-triple', 'up-press-triple') self.switch.add_level('up-hold', 'up-hold') self.switch.add_level('up-hold-release', 'up-hold-release') self.switch.add_level('on-press', 'on-press') self.switch.add_level('on-press-double', 'on-press-double') self.switch.add_level('on-press-triple', 'on-press-triple') self.switch.add_level('on-hold', 'on-hold') self.switch.add_level('on-hold-release', 'on-hold-release') self.switch.set_selector_style(SelectorSwitch.SELECTOR_TYPE_MENU) self.switch.disable_value_check_on_update() self.devices.append(self.switch) # Add dimmer self.dimmer = DimmerSwitch('bright', 'brightness') self.devices.append(self.dimmer) def convert_message(self, message): message = super().convert_message(message) if 'action' in message.raw and 'counter' in message.raw: simpleaction = str(message.raw['action']) if simpleaction.endswith('press'): if message.raw['counter'] == 2: addstring = '-double' elif message.raw['counter'] == 3: addstring = '-triple' else: addstring = '' message.raw['action'] = message.raw['action'] + addstring return message
def __init__(self, devices): super().__init__(devices) mode_switch = SelectorSwitch(devices, 'mode', 'system_mode', ' (Mode)') mode_switch.add_level('Off', 'off') mode_switch.add_level('Auto', 'auto') mode_switch.add_level('Heat', 'heat') mode_switch.set_selector_style(SelectorSwitch.SELECTOR_TYPE_BUTTONS) mode_switch.set_icon(15) self.devices.append( TemperatureSensor(devices, 'temp', 'local_temperature', ' (Temperature)')) self.devices.append( SetPoint(devices, 'spoint', 'current_heating_setpoint', ' (Setpoint)')) self.devices.append(mode_switch)
def __init__(self): super().__init__() self.devices.append(ContactSensor('sensor', 'contact')) temperature_sensor = TemperatureSensor('temp', 'local_temperature', ' (Temperature)') self.devices.append(temperature_sensor) setpoint = SetPoint('sp1', 'occupied_heating_setpoint', ' (Occupied Setpoint)') self.devices.append(setpoint) mode_switch = SelectorSwitch('mode', 'system_mode', ' (Mode)') mode_switch.add_level('Off', 'idle') mode_switch.add_level('Heat', 'heat') mode_switch.set_selector_style(SelectorSwitch.SELECTOR_TYPE_MENU) mode_switch.set_icon(15) self.devices.append(mode_switch)
class GiraLightLink(Adapter): def __init__(self, devices): super().__init__(devices) self.switch = SelectorSwitch(devices, 'switch', 'action') self.switch.add_level('Off', 'off') self.switch.add_level('On', 'on') self.switch.add_level('1', 'select_0') self.switch.add_level('2', 'select_1') self.switch.add_level('3', 'select_2') self.switch.add_level('4', 'select_3') self.switch.set_selector_style(SelectorSwitch.SELECTOR_TYPE_MENU) self.switch.disable_value_check_on_update() self.devices.append(self.switch) def handleCommand(self, alias, device, device_data, command, level, color): self.switch.handle_command(device_data, command, level, color)
class HeimanAlarmRemoteAdapter(AdapterWithBattery): def __init__(self, devices): super().__init__(devices) self.switch = SelectorSwitch(devices, 'Remote', 'action') self.switch.add_level('Off', None) self.switch.add_level('Arm all zones', 'arm_all_zones') self.switch.add_level('Arm partial zones', 'arm_partial_zones') self.switch.add_level('Disarm', 'disarm') self.switch.add_level('Emergency', 'emergency') self.switch.set_selector_style(SelectorSwitch.SELECTOR_TYPE_MENU) self.devices.append(self.switch) def convert_message(self, message): message = super().convert_message(message) return message def handleCommand(self, alias, device, device_data, command, level, color): self.switch.handle_command(device_data, command, level, color)
class WXKG01LM(AdapterWithBattery): def __init__(self, devices): super().__init__(devices) self.switch = SelectorSwitch(devices, 'switch', 'click') self.switch.add_level('Off', None) self.switch.add_level('Click', 'single') self.switch.add_level('Double Click', 'double') self.switch.add_level('Triple Click', 'triple') self.switch.add_level('Quadruple Click', 'quadruple') self.switch.add_level('Many clicks', 'many') self.switch.add_level('Long Click', 'long') self.switch.add_level('Long Click Release', 'long_release') self.switch.set_selector_style(SelectorSwitch.SELECTOR_TYPE_MENU) self.devices.append(self.switch) def handleCommand(self, alias, device, device_data, command, level, color): self.switch.handle_command(device_data, command, level, color)
class WXKG02LM(AdapterWithBattery): def __init__(self, devices): super().__init__(devices) self.switch = SelectorSwitch(devices, 'switch', 'click') self.switch.add_level('Off', None) self.switch.add_level('Switch 1', 'left') self.switch.add_level('Switch 2', 'right') self.switch.add_level('Both_Click', 'both') self.switch.add_level('Switch 1 Double', 'left_double') self.switch.add_level('Switch 2 Double', 'right_double') self.switch.add_level('Both_Click Double', 'both_double') self.switch.set_selector_style(SelectorSwitch.SELECTOR_TYPE_BUTTONS) self.switch.disable_value_check_on_update() self.devices.append(self.switch) def handleCommand(self, alias, device, device_data, command, level, color): self.switch.handle_command(device_data, command, level, color)
class WXKG07LM(AdapterWithBattery): def __init__(self, devices): super().__init__(devices) self.switch = SelectorSwitch(devices, 'switch', 'action') self.switch.add_level('Off', None) self.switch.add_level('Left Click', 'left') self.switch.add_level('Left Double Click', 'left_double') self.switch.add_level('Left Long Click', 'left_long') self.switch.add_level('Right Click', 'right') self.switch.add_level('Right Double Click', 'right_double') self.switch.add_level('Right Long Click', 'right_long') self.switch.add_level('Both Click', 'both') self.switch.add_level('Both Double Click', 'both_double') self.switch.add_level('Both Long Click', 'both_long') self.switch.set_selector_style(SelectorSwitch.SELECTOR_TYPE_MENU) self.switch.disable_value_check_on_update() self.devices.append(self.switch)
def __init__(self): super().__init__() mode_switch = SelectorSwitch('mode', 'system_mode', ' (Mode)') mode_switch.add_level('Off', 'off') mode_switch.add_level('Auto', 'auto') mode_switch.add_level('Cool', 'cool') mode_switch.add_level('Heat', 'heat') mode_switch.add_level('Emergency Heating', 'emergency heating') mode_switch.add_level('Precooling', 'precooling') mode_switch.add_level('Fan only', 'fan only') mode_switch.add_level('Dry', 'dry') mode_switch.add_level('Sleep', 'sleep') mode_switch.set_selector_style(SelectorSwitch.SELECTOR_TYPE_MENU) mode_switch.set_icon(15) self.devices.append(TemperatureSensor('temp', 'local_temperature',' (Temperature)')) self.devices.append(SetPoint('sp1', 'occupied_heating_setpoint',' (Occupied Setpoint)')) self.devices.append(SetPoint('sp2', 'unoccupied_heating_setpoint',' (Unoccupied Setpoint)')) self.devices.append(mode_switch)
class TradfriRemoteCloseOpen(AdapterWithBattery): def __init__(self, devices): super().__init__(devices) self.switch = SelectorSwitch(devices, 'switch', 'click') self.switch.add_level('Up', 'open') self.switch.add_level('Down', 'close') self.switch.add_level('Release', 'release') self.switch.set_selector_style(SelectorSwitch.SELECTOR_TYPE_BUTTONS) self.switch.disable_value_check_on_update() self.devices.append(self.switch) def handleCommand(self, alias, device, device_data, command, level, color): Domoticz.Debug(str(command) + str(level) + str(color)) self.switch.handle_command(device_data, command, level, color) return { 'topic': device_data['friendly_name'] + '/set', 'payload': json.dumps({"state": command.upper()}) }
def __init__(self, devices): super().__init__(devices) self.click_actions = ['play_pause','skip_forward','skip_backward'] rotation_switch = SelectorSwitch(devices, 'rotate', 'rotation', ' (Rotation)') rotation_switch.add_level('Left', 'rotate_left') rotation_switch.add_level('Off', 'rotate_stop') rotation_switch.add_level('Right', 'rotate_right') rotation_switch.disable_value_check_on_update() rotation_switch.set_selector_style(SelectorSwitch.SELECTOR_TYPE_BUTTONS) control_switch = SelectorSwitch(devices, 'switch', 'click', ' (Switch)') control_switch.add_level('Backward', 'skip_forward') control_switch.add_level('PlayPause', 'play_pause') control_switch.add_level('Forward', 'skip_backward') control_switch.disable_value_check_on_update() control_switch.set_selector_style(SelectorSwitch.SELECTOR_TYPE_BUTTONS) self.devices.append(DimmerSwitch(devices, 'dimmer', 'brightness', ' (Level)')) self.devices.append(rotation_switch) self.devices.append(control_switch)
def __init__(self): super().__init__() mode_switch = SelectorSwitch('mode', 'system_mode', ' (Mode)') mode_switch.add_level('Off', 'off') mode_switch.add_level('Auto', 'auto') mode_switch.add_level('Manual', 'manual') mode_switch.add_level('Comfort', 'comfort') mode_switch.add_level('Eco', 'eco') mode_switch.add_level('Boost', 'boost') mode_switch.add_level('Complex', 'complex') mode_switch.set_selector_style(SelectorSwitch.SELECTOR_TYPE_MENU) mode_switch.set_icon(15) preset = SelectorSwitch('preset', 'preset', ' (Preset)') preset.add_level('Away', 'away') preset.add_level('Schedule', 'schedule') preset.add_level('Manual', 'manual') preset.add_level('Comfort', 'comfort') preset.add_level('Eco', 'eco') preset.add_level('Boost', 'boost') preset.add_level('Complex', 'complex') preset.set_selector_style(SelectorSwitch.SELECTOR_TYPE_MENU) preset.set_icon(15) week_format = SelectorSwitch('week', 'week', ' (Week Format)') week_format.add_level('5+2', '5+2') week_format.add_level('6+1', '6+1') week_format.add_level('7', '7') self.devices.append(mode_switch) self.devices.append(preset) self.devices.append(week_format) self.devices.append(SetPoint('spoint', 'current_heating_setpoint',' (Setpoint)')) self.devices.append(SetPoint('sp_eco', 'eco_temperature',' (Eco Setpoint)')) self.devices.append(SetPoint('sp_cmf', 'comfort_temperature',' (Comfort Setpoint)')) self.devices.append(TemperatureSensor('temp', 'local_temperature',' (Temperature)')) self.devices.append(LevelSwitch('level', 'position', ' (Valve position)')) self.devices.append(OnOffSwitch('wnd', 'window_detection', ' (Window Detection)')) self.devices.append(OnOffSwitch('child', 'child_lock', ' (Child Lock)'))
class SmartMiniSwitch(AdapterWithBattery): def __init__(self, devices): super().__init__(devices) self.switch = SelectorSwitch(devices, 'switch', 'action') self.switch.add_level('Off', None) self.switch.add_level('Up', 'up') self.switch.add_level('Up: hold', 'up_hold') self.switch.add_level('Up: release', 'up_release') self.switch.add_level('Circle: click', 'circle_click') self.switch.add_level('Circle: hold', 'circle_hold') self.switch.add_level('Circle: release', 'circle_release') self.switch.add_level('Down', 'down') self.switch.add_level('Down: hold', 'down_hold') self.switch.add_level('Down: release', 'down_release') self.switch.set_selector_style(SelectorSwitch.SELECTOR_TYPE_MENU) self.switch.disable_value_check_on_update() self.devices.append(self.switch) def handleCommand(self, alias, device, device_data, command, level, color): self.switch.handle_command(device_data, command, level, color)
class TradfriRemoteControl(AdapterWithBattery): def __init__(self): super().__init__() self.switch = ToggleSwitch('switch', 'action') self.arrow_left = SelectorSwitch('arrowL', 'action', ' (Left Arrow)') self.arrow_left.add_level('Off', None) self.arrow_left.add_level('Click', 'arrow_left_click') self.arrow_left.add_level('Hold', 'arrow_left_hold') self.arrow_left.add_level('Release', 'arrow_left_release') self.arrow_left.set_selector_style( SelectorSwitch.SELECTOR_TYPE_BUTTONS) self.arrow_left.disable_value_check_on_update() self.arrow_right = SelectorSwitch('arrowR', 'action', ' (Right Arrow)') self.arrow_right.add_level('Off', None) self.arrow_right.add_level('Click', 'arrow_right_click') self.arrow_right.add_level('Hold', 'arrow_right_hold') self.arrow_right.add_level('Release', 'arrow_right_release') self.arrow_right.set_selector_style( SelectorSwitch.SELECTOR_TYPE_BUTTONS) self.arrow_right.disable_value_check_on_update() self.brightness_up = SelectorSwitch('brUp', 'action', ' (Brightness Up)') self.brightness_up.add_level('Off', None) self.brightness_up.add_level('Click', 'brightness_up_click') self.brightness_up.add_level('Hold', 'brightness_up_hold') self.brightness_up.add_level('Release', 'brightness_up_release') self.brightness_up.set_selector_style( SelectorSwitch.SELECTOR_TYPE_BUTTONS) self.brightness_up.disable_value_check_on_update() self.brightness_down = SelectorSwitch('brDown', 'action', ' (Brightness Down)') self.brightness_down.add_level('Off', None) self.brightness_down.add_level('Click', 'brightness_down_click') self.brightness_down.add_level('Hold', 'brightness_down_hold') self.brightness_down.add_level('Release', 'brightness_down_release') self.brightness_down.set_selector_style( SelectorSwitch.SELECTOR_TYPE_BUTTONS) self.brightness_down.disable_value_check_on_update() self.devices.append(self.switch) self.devices.append(self.arrow_left) self.devices.append(self.arrow_right) self.devices.append(self.brightness_up) self.devices.append(self.brightness_down) def handle_command(self, alias, device, command, level, color): device_data = self._get_legacy_device_data() device = self.get_device_by_alias(alias) if device != None: device.handle_command(device_data, command, level, color) def handle_mqtt_message(self, message): if 'action' not in message.raw: return device_data = self._get_legacy_device_data() converted_message = self.convert_message(message) action = message.raw['action'] if action == None: return if action == 'toggle': self.switch.handle_message(device_data, converted_message) if action.startswith('brightness_up'): self.brightness_up.handle_message(device_data, converted_message) if action.startswith('brightness_down'): self.brightness_down.handle_message(device_data, converted_message) if action.startswith('arrow_right'): self.arrow_right.handle_message(device_data, converted_message) if action.startswith('arrow_left'): self.arrow_left.handle_message(device_data, converted_message) self.update_battery_status(device_data, converted_message) self.update_link_quality(device_data, converted_message)
class TradfriRemoteControl(AdapterWithBattery): def __init__(self, devices): super().__init__(devices) self.switch = ToggleSwitch(devices, 'switch', 'action') self.arrow_left = SelectorSwitch(devices, 'arrowL', 'action', ' (Left Arrow)') self.arrow_left.add_level('Off', None) self.arrow_left.add_level('Click', 'arrow_left_click') self.arrow_left.add_level('Hold', 'arrow_left_hold') self.arrow_left.add_level('Release', 'arrow_left_release') self.arrow_left.set_selector_style( SelectorSwitch.SELECTOR_TYPE_BUTTONS) self.arrow_right = SelectorSwitch(devices, 'arrowR', 'action', ' (Right Arrow)') self.arrow_right.add_level('Off', None) self.arrow_right.add_level('Click', 'arrow_right_click') self.arrow_right.add_level('Hold', 'arrow_right_hold') self.arrow_right.add_level('Release', 'arrow_right_release') self.arrow_right.set_selector_style( SelectorSwitch.SELECTOR_TYPE_BUTTONS) self.brightness_up = SelectorSwitch(devices, 'brUp', 'action', ' (Brightness Up)') self.brightness_up.add_level('Off', None) self.brightness_up.add_level('Click', 'brightness_up_click') self.brightness_up.add_level('Hold', 'brightness_up_hold') self.brightness_up.add_level('Release', 'brightness_up_release') self.brightness_up.set_selector_style( SelectorSwitch.SELECTOR_TYPE_BUTTONS) self.brightness_down = SelectorSwitch(devices, 'brDown', 'action', ' (Brightness Down)') self.brightness_down.add_level('Off', None) self.brightness_down.add_level('Click', 'brightness_down_click') self.brightness_down.add_level('Hold', 'brightness_down_hold') self.brightness_down.add_level('Release', 'brightness_down_release') self.brightness_down.set_selector_style( SelectorSwitch.SELECTOR_TYPE_BUTTONS) self.devices.append(self.switch) self.devices.append(self.arrow_left) self.devices.append(self.arrow_right) self.devices.append(self.brightness_up) self.devices.append(self.brightness_down) def handleCommand(self, alias, device, device_data, command, level, color): if alias == self.switch.alias: self.switch.handle_command(device_data, command, level, color) if alias == self.arrow_left.alias: self.arrow_left.handle_command(device_data, command, level, color) if alias == self.arrow_right.alias: self.arrow_right.handle_command(device_data, command, level, color) if alias == self.brightness_up.alias: self.brightness_up.handle_command(device_data, command, level, color) if alias == self.brightness_down.alias: self.brightness_down.handle_command(device_data, command, level, color) def handleMqttMessage(self, device_data, message): if 'action' not in message.raw: return converted_message = self.convert_message(message) action = message.raw['action'] if action == 'toggle': self.switch.handle_message(device_data, converted_message) if action.startswith('brightness_up'): self.brightness_up.handle_message(device_data, converted_message) if action.startswith('brightness_down'): self.brightness_down.handle_message(device_data, converted_message) if action.startswith('arrow_right'): self.arrow_right.handle_message(device_data, converted_message) if action.startswith('arrow_left'): self.arrow_left.handle_message(device_data, converted_message)
class HueDimmerSwitch(AdapterWithBattery): def __init__(self, devices): super().__init__(devices) self.switch = SelectorSwitch(devices, 'dimmer', 'action') self.switch.add_level('off-press', 'off-press') self.switch.add_level('off-press-double', 'off-press-double') self.switch.add_level('off-press-triple', 'off-press-triple') self.switch.add_level('off-hold', 'off-hold') self.switch.add_level('off-hold-release', 'off-hold-release') self.switch.add_level('down-press', 'down-press') self.switch.add_level('down-press-double', 'down-press-double') self.switch.add_level('down-press-triple', 'down-press-triple') self.switch.add_level('down-hold', 'down-hold') self.switch.add_level('down-hold-release', 'down-hold-release') self.switch.add_level('up-press', 'up-press') self.switch.add_level('up-press-double', 'up-press-double') self.switch.add_level('up-press-triple', 'up-press-triple') self.switch.add_level('up-hold', 'up-hold') self.switch.add_level('up-hold-release', 'up-hold-release') self.switch.add_level('on-press', 'on-press') self.switch.add_level('on-press-double', 'on-press-double') self.switch.add_level('on-press-triple', 'on-press-triple') self.switch.add_level('on-hold', 'on-hold') self.switch.add_level('on-hold-release', 'on-hold-release') self.switch.set_selector_style(SelectorSwitch.SELECTOR_TYPE_MENU) self.switch.disable_value_check_on_update() self.devices.append(self.switch) # Add dimmer self.dimmer = DimmerSwitch(devices, 'bright', 'brightness') self.devices.append(self.dimmer) def convert_message(self, message): message = super().convert_message(message) if 'action' in message.raw and 'counter' in message.raw: simpleaction = str(message.raw['action']) if simpleaction.endswith('press'): if message.raw['counter'] == 2: addstring = '-double' elif message.raw['counter'] == 3: addstring = '-triple' else: addstring = '' message.raw['action'] = message.raw['action'] + addstring return message def handle_mqtt_message(self, message): converted_message = self.convert_message(message) device_data = self._get_legacy_device_data() if ('action' not in converted_message.raw) or (len( converted_message.raw['action']) == 0): domoticz.debug("Received Hue heartbeat message") return if (device_data == None): domoticz.debug( self.name + ': not enough details to handle MQTT message from device') return for device in self.devices: device.handle_message(device_data, converted_message) self.update_battery_status(device_data, converted_message) self.update_link_quality(device_data, converted_message)
class TradfriRemoteControl(AdapterWithBattery): def __init__(self, devices): super().__init__(devices) self.switch = ToggleSwitch(devices, 'switch', 'action') self.selector_switch = SelectorSwitch(devices, 'sel', 'action', ' (Selector)') self.selector_switch.add_level('Off', None) self.selector_switch.add_level('brightness-up-click', 'brightness_up_click') self.selector_switch.add_level('brightness-up-hold', 'brightness_up_hold') self.selector_switch.add_level('brightness-up-release', 'brightness_up_release') self.selector_switch.add_level('brightness-down-click', 'brightness_down_click') self.selector_switch.add_level('brightness-down-hold', 'brightness_down_hold') self.selector_switch.add_level('brightness-down-release', 'brightness_down_release') self.selector_switch.add_level('arrow-left-click', 'arrow_left_click') self.selector_switch.add_level('arrow-left-hold', 'arrow_left_hold') self.selector_switch.add_level('arrow-left-release', 'arrow_left_release') self.selector_switch.add_level('arrow-right-click', 'arrow_right_click') self.selector_switch.add_level('arrow-right-hold', 'arrow_right_hold') self.selector_switch.add_level('arrow-right-release', 'arrow_right_release') self.selector_switch.disable_value_check_on_update() self.selector_switch.set_selector_style( SelectorSwitch.SELECTOR_TYPE_MENU) self.devices.append(self.switch) self.devices.append(self.selector_switch) def handle_command(self, alias, device, command, level, color): device_data = self._get_legacy_device_data() device = self.get_device_by_alias(alias) if device != None: device.handle_command(device_data, command, level, color) def handle_mqtt_message(self, message): if 'action' not in message.raw: return device_data = self._get_legacy_device_data() converted_message = self.convert_message(message) action = message.raw['action'] if action == 'toggle': self.switch.handle_message(device_data, converted_message) if action.startswith('brightness_up'): self.selector_switch.handle_message(device_data, converted_message) if action.startswith('brightness_down'): self.selector_switch.handle_message(device_data, converted_message) if action.startswith('arrow_right'): self.selector_switch.handle_message(device_data, converted_message) if action.startswith('arrow_left'): self.selector_switch.handle_message(device_data, converted_message) self.update_battery_status(device_data, converted_message) self.update_link_quality(device_data, converted_message)