Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class IPKeySwitch(IPSwitch, HMEvent, HelperActionPress):
"""
Switch turning plugged in device on or off and measuring energy consumption.
"""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
self.EVENTNODE.update({"PRESS_SHORT": [1, 2],
"PRESS_LONG": [1, 2]})
@property
def ELEMENT(self):
return [4]
class IPKeySwitchLevel(GenericDimmer, GenericSwitch, HMEvent, HelperActionPress, HelperActorLevel):
"""
Switch with two independent controllable LEDs, turning plugged in device on or off.
"""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
self.WRITENODE.update({"STATE": [4],
"COLOR": [8, 12],
"LEVEL": [8, 12]})
self.EVENTNODE.update({"PRESS_SHORT": [1, 2],
"PRESS_LONG": [1, 2]})
def on(self, channel=None):
"""Turn light/switch on."""
if channel in self.WRITENODE["LEVEL"]:
self.set_level(1.0, channel)
"""Turn light off."""
self.set_level(0.0, channel)
class Dimmer(GenericDimmer, HelperWorking):
"""
Dimmer switch that controls level of light brightness.
"""
@property
def ELEMENT(self):
if "Dim2L" in self._TYPE or "Dim2T" in self._TYPE or self._TYPE == "HM-DW-WM":
return [1, 2]
return [1]
class KeyDimmer(GenericDimmer, HelperWorking, HelperActionPress):
"""
Dimmer switch that controls level of light brightness.
"""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
# init metadata
self.EVENTNODE.update({"PRESS_SHORT": [1, 2],
"PRESS_LONG_RELEASE": [1, 2]})
@property
def ELEMENT(self):
return [3]
class IPDimmer(GenericDimmer):
class GenericDimmer(HMActor, HelperActorLevel):
"""
Dimmer switch that controls level of light brightness.
"""
def on(self, channel=None):
"""Turn light to maximum brightness."""
self.set_level(1.0, channel)
def off(self, channel=None):
"""Turn light off."""
self.set_level(0.0, channel)
class Dimmer(GenericDimmer, HelperWorking):
"""
Dimmer switch that controls level of light brightness.
"""
@property
def ELEMENT(self):
if "Dim2L" in self._TYPE or "Dim2T" in self._TYPE or self._TYPE == "HM-DW-WM":
return [1, 2]
return [1]
class KeyDimmer(GenericDimmer, HelperWorking, HelperActionPress):
"""
Dimmer switch that controls level of light brightness.
"""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
def ELEMENT(self):
return [3]
class IPDimmer(GenericDimmer):
"""
IP Dimmer switch that controls level of light brightness.
"""
@property
def ELEMENT(self):
if "PDT" in self._TYPE:
return [3]
return [2]
class IPKeyDimmer(GenericDimmer, HelperActionPress):
"""
IP Dimmer with buttons switch that controls level of light brightness.
"""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
# init metadata
self.EVENTNODE.update({"PRESS_SHORT": [1, 2],
"PRESS_LONG_RELEASE": [1, 2]})
@property
def ELEMENT(self):
return [4]
class GenericSwitch(HMActor, HelperActorState):
"""
Dimmer switch that controls level of light brightness.
"""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
# init metadata
self.EVENTNODE.update({"PRESS_SHORT": [1, 2],
"PRESS_LONG_RELEASE": [1, 2]})
@property
def ELEMENT(self):
return [3]
class IPDimmer(GenericDimmer):
"""
IP Dimmer switch that controls level of light brightness.
"""
@property
def ELEMENT(self):
if "PDT" in self._TYPE:
return [3]
return [2]
class IPKeyDimmer(GenericDimmer, HelperActionPress):
"""
IP Dimmer with buttons switch that controls level of light brightness.
"""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)