class WeiserLock(Adapter): def __init__(self, devices): super().__init__(devices) self.switch = OnOffSwitch(devices, 'switch', 'state') self.devices.append(self.switch) def convert_message(self, message): message = super().convert_message(message) if 'state' in message.raw: state = message.raw['state'] message.raw['state'] = 'ON' if state == 'LOCK' else 'OFF' return message def handle_command(self, alias, device, command, level, color): device_data = self._get_legacy_device_data() self.switch.handle_command(device_data, command, level, color) return { 'topic': device_data['friendly_name'] + '/set', 'payload': json.dumps( {"state": 'LOCK' if command.upper() == 'ON' else 'UNLOCK'}) }
class BitronSirenAdapterWithBattery(AdapterWithBattery): def __init__(self, devices): super().__init__(devices) self.switch = OnOffSwitch(devices, 'switch', 'state') self.switch.set_icon(13) self.devices.append(self.switch) def handle_command(self, alias, device, command, level, color): device_data = self._get_legacy_device_data() self.switch.handle_command(device_data, command, level, color) mode = 'emergency' if command.upper() == 'ON' else 'stop' flash = False if command.upper() == 'ON' else True return { 'topic': device_data['friendly_name'] + '/set', 'payload': json.dumps({ 'warning': { 'mode': mode, 'level': 'high', 'strobe': flash, 'duration': 30 } }) }
def __init__(self, devices): super().__init__(devices) self.devices.append(OnOffSwitch(devices, 'l1', 'state_l1')) self.devices.append(OnOffSwitch(devices, 'l2', 'state_l2')) values = ['power', 'consumption'] self.devices.append(KwhSensor(devices, 'kwh', values)) self.devices.append(TemperatureSensor(devices, 'temp', 'temperature'))
def __init__(self, devices): super().__init__(devices) self.devices.append(OnOffSwitch(devices, 'l1', 'state_l1')) self.devices.append(OnOffSwitch(devices, 'l2', 'state_l2')) self.devices.append(OnOffSwitch(devices, 'l3', 'state_l3')) self.devices.append(OnOffSwitch(devices, 'l4', 'state_l4')) self.devices.append(OnOffSwitch(devices, 'l5', 'state_l5'))
def __init__(self, devices): super().__init__(devices) self.devices.append( OnOffSwitch(devices, 'wnd', 'window_detection', ' (Window Detection)')) self.devices.append( OnOffSwitch(devices, 'valve', 'valve_detection', ' (Valve Detection)')) self.devices.append( OnOffSwitch(devices, 'child', 'child_lock', ' (Child Lock)'))
class OnOffSwitchAdapter(Adapter): def __init__(self, devices): super().__init__(devices) self.switch = OnOffSwitch(devices, 'switch', 'state') self.devices.append(self.switch) def handleCommand(self, alias, device, device_data, command, level, 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) selector = SelectorSwitch(devices, 'click', 'click') selector.add_level('Off', None) selector.add_level('Left', 'left') selector.add_level('Right', 'right') selector.add_level('Both', 'both') selector.disable_value_check_on_update() self.devices.append(OnOffSwitch(devices, 'left', 'state_left')) self.devices.append(OnOffSwitch(devices, 'right', 'state_right')) self.devices.append(selector)
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('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(devices, '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(devices, '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(devices, 'spoint', 'current_heating_setpoint', ' (Setpoint)')) self.devices.append( SetPoint(devices, 'sp_eco', 'eco_temperature', ' (Eco Setpoint)')) self.devices.append( SetPoint(devices, 'sp_cmf', 'comfort_temperature', ' (Comfort Setpoint)')) self.devices.append( TemperatureSensor(devices, 'temp', 'local_temperature', ' (Temperature)')) self.devices.append( LevelSwitch(devices, 'level', 'position', ' (Valve position)')) self.devices.append( OnOffSwitch(devices, 'wnd', 'window_detection', ' (Window Detection)')) self.devices.append( OnOffSwitch(devices, 'child', 'child_lock', ' (Child Lock)'))
def __init__(self): super().__init__() self.devices.append(TextSensor('click', 'click', ' (input)')) self.switch={} for ptvo in PTVOID: self.switch[ptvo] = OnOffSwitch(ptvo, 'state_' + PTVOID[ptvo], ' (' + ptvo + ')') self.devices.append(self.switch[ptvo])
def __init__(self, devices): super().__init__(devices) self.devices.append(OnOffSwitch(devices, 'switch', 'state', ' (State)')) self.devices.append(TemperatureSensor(devices, 'temp', 'cpu_temperature', ' (CPU Temperature)')) self.devices.append(TemperatureSensor(devices, 'temp_e', 'external_temperature', ' (External Temperature)')) self.devices.append(VoltageSensor(devices, 'adc', 'adc_volt', ' (ADC Voltage)'))
class SirenAdapter(Adapter): def __init__(self, devices): super().__init__(devices) self.switch = OnOffSwitch(devices, 'switch', 'state') self.switch.set_icon(13) self.devices.append(self.switch) def handleCommand(self, alias, device, device_data, command, level, color): self.switch.handle_command(device_data, command, level, color) mode = 'emergency' if command.upper() == 'ON' else 'stop' return { 'topic': device_data['friendly_name'] + '/set', 'payload': json.dumps({'warning': { 'mode': mode, 'duration': 10 }}) }
def register_groups(self, domoticz_devices, groups): self.groups = {} for item in groups: group_id = self._get_group_address_by_name(item['friendly_name']) device_data = { 'type': 'Group', 'model': 'Group', 'ieee_addr': group_id, 'friendly_name': item['friendly_name'] } Domoticz.Log('Group ' + item['friendly_name'] + ' (' + group_id + '_grp)') device = OnOffSwitch(domoticz_devices, 'grp', 'state') device.register(device_data) self.groups[group_id] = { 'friendly_name': item['friendly_name'], 'device': device }
def __init__(self): super().__init__() sensitivity_switch = SelectorSwitch('sens', 'sensitivity', ' (Sensivity)') sensitivity_switch.add_level('Low', 'low') sensitivity_switch.add_level('Medium', 'medium') sensitivity_switch.add_level('High', 'high') self.devices.append(SmokeSensor('smoke', 'smoke')) self.devices.append(OnOffSwitch('test', 'test_state', ' (Test)')) self.devices.append(sensitivity_switch) self.devices.append( CustomSensor('dnsty', 'smoke_density', ' (Smoke Density)'))
def __init__(self, devices): super().__init__(devices) self.devices.append( TemperatureSensor(devices, 'temp', 'temperature', 'temperature')) self.devices.append( HumiditySensor(devices, 'hum', 'humidity', ' (Humidity)')) self.devices.append(OnOffSwitch(devices, 'alarm', 'alarm', ' (Alarm)')) volume_switch = SelectorSwitch(devices, 'vol', 'volume', ' (Volume)') volume_switch.add_level('Low', 'low') volume_switch.add_level('Medium', 'medium') volume_switch.add_level('High', 'high') self.devices.append(volume_switch)
def __init__(self): super().__init__() self.devices.append(OnOffSwitch('left', 'state_left')) self.devices.append(OnOffSwitch('right', 'state_right'))
def __init__(self, devices): super().__init__(devices) self.devices.append(OnOffSwitch(devices, 'center', 'state_left'))
def __init__(self): super().__init__() self.devices.append(OnOffSwitch('center', 'state_center'))
def __init__(self): super().__init__() self.devices.append(OnOffSwitch('l1', 'state_l1')) self.devices.append(OnOffSwitch('l2', 'state_l2'))
def __init__(self): super().__init__() self.switch = OnOffSwitch('switch', 'state') self.devices.append(self.switch)
def __init__(self, devices): super().__init__(devices) self.devices.append(OnOffSwitch(devices, 'left', 'state_left')) self.devices.append(OnOffSwitch(devices, 'right', 'state_right'))
def __init__(self, devices): super().__init__(devices) self.switch = OnOffSwitch(devices, 'switch', 'state') self.switch.set_icon(13) self.devices.append(self.switch)
def create_switch(self, devices, name): device = OnOffSwitch(devices, 'sw_' + name[0], 'state_' + name, ' (' + name.capitalize() + ' Switch)') return device