Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
# init metadata
self.SENSORNODE.update({"POWER": [2],
"CURRENT": [2],
"VOLTAGE": [2],
"FREQUENCY": [2],
"ENERGY_COUNTER": [2]})
@property
def ELEMENT(self):
return [1]
class EcoLogic(Switch, HelperActionOnTime, HelperActionPress, HMSensor):
"""
Switching device and humidity sensor for automatic watering
"""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
# init metadata
self.SENSORNODE.update({"SENSOR": [3, 4]})
self.EVENTNODE.update({"PRESS_SHORT": [5, 6, 7, 8, 9]})
@property
def ELEMENT(self):
return [1, 2]
class IPSwitchPowermeter(IPSwitch, HMSensor, HelperRssiDevice):
super().__init__(device_description, proxy, resolveparamsets)
# init metadata
self.BINARYNODE.update({"MOTION": self.ELEMENT})
self.SENSORNODE.update({"BRIGHTNESS": self.ELEMENT})
def is_motion(self, channel=None):
""" Return True if motion is detected """
return bool(self.getBinaryData("MOTION", channel))
def get_brightness(self, channel=None):
""" Return brightness from 0 (dark ) to 255 (bright) """
return int(self.getSensorData("BRIGHTNESS", channel))
class SmartwareMotion(HMSensor, HelperRssiDevice):
"""Motion detection.
This is a binary sensor."""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
# init metadata
self.BINARYNODE.update({"STATE": self.ELEMENT})
def is_motion(self, channel=None):
""" Return True if motion is detected """
return bool(self.getBinaryData("STATE", channel))
@property
def ELEMENT(self):
return [1]
- voltage of the batteries (HelperOperatingVoltageIP)"""
class SensorHmIPNoVoltage(HMSensor, HelperRssiDevice, HelperLowBatIP):
"""Some Homematic IP sensors have
- strength of the signal received by the CCU (HelperRssiDevice).
Be aware that HMIP devices have a reversed understanding of PEER
and DEVICE compared to standard HM devices.
- strength of the signal received by the device (HelperRssiPeer).
Be aware that standard HMIP devices have a reversed understanding of PEER
and DEVICE compared to standard HM devices.
- low battery status (HelperLowBatIP)
- but no voltage of batteries"""
class SensorHmIPNoBattery(HMSensor, HelperRssiDevice):
"""Some Homematic IP sensors have
- strength of the signal received by the CCU (HelperRssiDevice).
Be aware that HMIP devices have a reversed understanding of PEER
and DEVICE compared to standard HM devices.
- strength of the signal received by the device (HelperRssiPeer).
Be aware that standard HMIP devices have a reversed understanding of PEER
and DEVICE compared to standard HM devices.
- low battery status (HelperLowBatIP)
- but no voltage of batteries"""
class ShutterContact(SensorHm, HelperBinaryState, HelperSabotage):
"""Door / Window contact that emits its open/closed state.
This is a binary sensor."""
def is_open(self, channel=None):
"""
Switching device and humidity sensor for automatic watering
"""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
# init metadata
self.SENSORNODE.update({"SENSOR": [3, 4]})
self.EVENTNODE.update({"PRESS_SHORT": [5, 6, 7, 8, 9]})
@property
def ELEMENT(self):
return [1, 2]
class IPSwitchPowermeter(IPSwitch, HMSensor, HelperRssiDevice):
"""
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]})
# init metadata
sensorIndex = None
if "HmIP-FSM" in self.TYPE or "HmIP-FSM16" in self.TYPE:
sensorIndex = 5
elif "HMIP-PSM" in self.TYPE or "HmIP-PSM" in self.TYPE or "HmIP-PSM-CH" in self.TYPE:
sensorIndex = 6
elif "HmIP-BSM" in self.TYPE:
elif hue in range(210, 269):
hm_color = 'BLUE'
elif hue in range(270, 329):
hm_color = 'PURPLE' # actually magenta
else:
hm_color = 'RED'
self.setValue(key="COLOR", value=hm_color, channel=channel)
@property
def ELEMENT(self):
return [4, 8, 12]
class SwitchPowermeter(Switch, HelperActionOnTime, HMSensor):
"""
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)
# init metadata
self.SENSORNODE.update({"POWER": [2],
"CURRENT": [2],
"VOLTAGE": [2],
"FREQUENCY": [2],
"ENERGY_COUNTER": [2]})
@property
def ELEMENT(self):
return [1]
from pyhomematic.devicetypes.helper import (HelperLowBat, HelperSabotage,
HelperLowBatIP, HelperSabotageIP,
HelperOperatingVoltageIP,
HelperBinaryState,
HelperSensorState,
HelperWired, HelperEventRemote, HelperRssiPeer, HelperRssiDevice,
HelperValveState)
LOG = logging.getLogger(__name__)
class HMSensor(HMDevice):
"""This class helps to resolve class inheritance order problems."""
class SensorHmW(HMSensor):
"""Homematic Wired sensors"""
class SensorHmNLB(HMSensor, HelperRssiDevice, HelperRssiPeer):
"""Homematic sensors always have
- strength of the signal received by the device (HelperRssiDevice).
Be aware that standard HM devices have a reversed understanding of PEER
and DEVICE compared to HMIP devices.
- strength of the signal received by the CCU (HelperRssiPeer).
Be aware that standard HM devices have a reversed understanding of PEER
and DEVICE compared to HMIP devices."""
class SensorHm(HMSensor, HelperRssiDevice, HelperRssiPeer, HelperLowBat):
"""Homematic sensors always have
- strength of the signal received by the device (HelperRssiDevice).