Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
This is a binary sensor."""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
# init metadata
self.BINARYNODE.update({"ALARMSTATE": self.ELEMENT,
"MOISTURE_DETECTED": self.ELEMENT,
"WATERLEVEL_DETECTED": self.ELEMENT})
@property
def ELEMENT(self):
return [1]
class IPContact(SensorHmIP, HelperBinaryState, HelperEventRemote):
"""Multi purpose contact that emits its open/closed state.
This is a binary sensor. Supports multiple modes"""
def is_open(self, channel=None):
""" Returns True if the contact is open. """
return self.get_state(channel)
def is_closed(self, channel=None):
""" Returns True if the contact is closed. """
return not self.get_state(channel)
def is_on(self, channel=None):
""" Returns True if switch is on. """
return self.get_state(channel)
def is_off(self, channel=None):
return int(self.getSensorData("HUMIDITY", channel))
def get_wind_speed(self, channel=None):
return float(self.getSensorData("WIND_SPEED", channel))
def get_sunshineduration(self, channel=None):
return int(self.getSensorData("SUNSHINEDURATION", channel))
def get_brightness(self, channel=None):
return int(self.getSensorData("ILLUMINATION", channel))
def is_temperature_out_of_range(self, channel=None):
return bool(self.getAttributeData("TEMPERATURE_OUT_OF_RANGE", channel))
class IPPassageSensor(SensorHmIP, HelperRssiPeer, HelperEventRemote):
"""HomeMatic IP Passage Sensor. #2 = right to left, #3 = left to right
This is a binary sensor."""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
# init metadata
self.SENSORNODE.update({"PASSAGE_COUNTER_VALUE": self.ELEMENT})
self.BINARYNODE.update({"PASSAGE_COUNTER_OVERFLOW": self.ELEMENT,
"LAST_PASSAGE_DIRECTION": [2],
"CURRENT_PASSAGE_DIRECTION": [2]})
@property
def ELEMENT(self):
return [2, 3]
pass
class HMCCU(HMDevice):
pass
class RemoteVirtual(HMCCU, HelperEventRemote, HelperActionPress):
"""For virtual remote from ccu/homegear or simple devices with just PRESS_SHORT and PRESS_LONG."""
@property
def ELEMENT(self):
return list(range(1, 51))
class Remote(HMEvent, HelperEventRemote, HelperActionPress, HelperRssiPeer):
"""Remote handle buttons."""
@property
def ELEMENT(self):
if "RC-2" in self.TYPE or "PB-2" in self.TYPE or "WRC2" in self.TYPE or "BRC2" in self.TYPE:
return [1, 2]
if "HM-Dis-WM55" in self.TYPE or "HM-Dis-EP-WM55" in self.TYPE:
return [1, 2]
if "HM-RC-Dis-H-x-EU" in self.TYPE:
return list(range(1, 21))
if "Sec3" in self.TYPE or "Key3" in self.TYPE:
return [1, 2, 3]
if "RC-4" in self.TYPE or "PB-4" in self.TYPE:
return [1, 2, 3, 4]
if "HM-PBI-4-FM" in self.TYPE or "ZEL STG RM FST UP4" in self.TYPE or "263 145" in self.TYPE or "HM-PBI-X" in self.TYPE:
return [1, 2, 3, 4]
from pyhomematic.devicetypes.helper import HelperActionPress, \
HelperEventRemote, HelperEventPress, HelperRssiPeer, HelperLowBatIP, \
HelperLowBat
LOG = logging.getLogger(__name__)
class HMEvent(HMDevice):
pass
class HMCCU(HMDevice):
pass
class RemoteVirtual(HMCCU, HelperEventRemote, HelperActionPress):
"""For virtual remote from ccu/homegear or simple devices with just PRESS_SHORT and PRESS_LONG."""
@property
def ELEMENT(self):
return list(range(1, 51))
class Remote(HMEvent, HelperEventRemote, HelperActionPress, HelperRssiPeer):
"""Remote handle buttons."""
@property
def ELEMENT(self):
if "RC-2" in self.TYPE or "PB-2" in self.TYPE or "WRC2" in self.TYPE or "BRC2" in self.TYPE:
return [1, 2]
if "HM-Dis-WM55" in self.TYPE or "HM-Dis-EP-WM55" in self.TYPE:
return [1, 2]
if "LC-Sw2" in self.TYPE or "Sec-SFA-SM" in self.TYPE:
return [1, 2]
elif "LC-Sw4" in self.TYPE:
return [1, 2, 3, 4]
elif "Re-8" in self.TYPE:
return [1, 2, 3, 4, 5, 6, 7, 8]
elif "HM-OU-CFM-Pl" in self.TYPE or "HM-OU-CFM-TW" in self.TYPE or "HM-OU-CF-Pl" in self.TYPE:
return [1, 2]
elif "HMW-IO-12-Sw14-DR" in self.TYPE:
return [1, 2, 3, 4, 5, 6]
elif "HMW-IO-12-Sw7-DR" in self.TYPE:
return [13, 14, 15, 16, 17, 18, 19]
return [1]
class IOSwitch(GenericSwitch, HelperWorking, HelperEventRemote, HelperWired):
"""
Switch turning attached device on or off.
"""
def __init__(self, device_description, proxy, resolveparamsets=False):
self._doc = []
super().__init__(device_description, proxy, resolveparamsets)
if "HMW-IO-12-FM" in self.TYPE:
for chan in range(1, 13):
if self._proxy.getParamset("%s:%i" % (self._ADDRESS, chan), "MASTER").get("BEHAVIOUR", None) == 1:
self._doc.append(chan)
@property
def ELEMENT(self):
if "HMW-IO-12-Sw7-DR" in self.TYPE:
return [13, 14, 15, 16, 17, 18, 19]