Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_rssi(self, channel=0):
return self.getAttributeData("RSSI_DEVICE", channel)
class HelperRssiPeer(HMDevice):
"""Used for devices which report their RSSI value through RSSI_PEER"""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
self.ATTRIBUTENODE["RSSI_PEER"] = [0]
def get_rssi(self, channel=0):
return self.getAttributeData("RSSI_PEER", channel)
class HelperDeviceTemperature(HMDevice):
"""Used for devices that report their actual device temperature values (such as the HmIP Wired devices)"""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
self.ATTRIBUTENODE["ACTUAL_TEMPERATURE"] = [0]
def get_device_temperature(self, channel=0):
return self.getAttributeData("ACTUAL_TEMPERATURE", channel)
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
self.ACTIONNODE.update({"PRESS_SHORT": self.ELEMENT,
"PRESS_LONG": self.ELEMENT})
def press_long(self, channel=None):
"""Simulat a button press long."""
self.actionNodeData("PRESS_LONG", 1, channel)
def press_short(self, channel=None):
"""Simulat a button press short."""
self.actionNodeData("PRESS_SHORT", 1, channel)
class HelperEventPress(HMDevice):
"""Remote handle buttons."""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
self.EVENTNODE.update({"PRESS": self.ELEMENT})
class HelperEventRemote(HMDevice):
"""Remote handle buttons."""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
self.EVENTNODE.update({"PRESS_SHORT": self.ELEMENT,
"PRESS_LONG": self.ELEMENT,
"PRESS_CONT": self.ELEMENT,
"PRESS_LONG_RELEASE": self.ELEMENT})
# init metadata
self.ACTIONNODE.update({"ON_TIME": self.ELEMENT})
def set_ontime(self, ontime):
"""Set duration th switch stays on when toggled. """
try:
ontime = float(ontime)
except Exception as err:
LOG.debug("SwitchPowermeter.set_ontime: Exception %s" % (err,))
return False
self.actionNodeData("ON_TIME", ontime)
class HelperActionPress(HMDevice):
"""Helper for simulate press button."""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
self.ACTIONNODE.update({"PRESS_SHORT": self.ELEMENT,
"PRESS_LONG": self.ELEMENT})
def press_long(self, channel=None):
"""Simulat a button press long."""
self.actionNodeData("PRESS_LONG", 1, channel)
def press_short(self, channel=None):
"""Simulat a button press short."""
self.actionNodeData("PRESS_SHORT", 1, channel)
import logging
from pyhomematic.devicetypes import generic, misc, sensors, actors, thermostats
LOG = logging.getLogger(__name__)
try:
UNSUPPORTED = generic.HMDevice
SUPPORTED = {}
SUPPORTED.update(actors.DEVICETYPES)
SUPPORTED.update(sensors.DEVICETYPES)
SUPPORTED.update(thermostats.DEVICETYPES)
SUPPORTED.update(misc.DEVICETYPES)
except Exception as err:
LOG.critical("devicetypes Exception: %s" % (err,))
UNSUPPORTED = False
SUPPORTED = {}
"""Returns True if the devicecase has been opened."""
return bool(self.getAttributeData("SABOTAGE", 0))
class HelperLowBat(HMDevice):
"""This Helper adds easy access to read the LOWBAT state"""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
# init metadata
self.ATTRIBUTENODE.update({"LOWBAT": [0]})
def low_batt(self, channel=None):
""" Returns if the battery is low. """
return self.getAttributeData("LOWBAT", channel)
class HelperLowBatIP(HMDevice):
"""This Helper adds easy access to read the LOWBAT state"""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
# init metadata
self.ATTRIBUTENODE.update({"LOW_BAT": [0]})
# pylint: disable=unused-argument
def low_batt(self, channel=None):
""" Returns if the battery is low. """
return self.getAttributeData("LOW_BAT", 0)
class HelperOperatingVoltageIP(HMDevice):
"""This Helper adds easy access to read the OPERATING_VOLTAGE state"""
def __init__(self, device_description, proxy, resolveparamsets=False):
import logging
from pyhomematic.devicetypes.generic import HMDevice
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):
super().__init__(device_description, proxy, resolveparamsets)
self.ATTRIBUTENODE.pop("RSSI_PEER", None)
self.ATTRIBUTENODE.pop("RSSI_DEVICE", None)
class HelperRssiDevice(HMDevice):
"""Used for devices which report their RSSI value through RSSI_DEVICE"""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
self.ATTRIBUTENODE["RSSI_DEVICE"] = [0]
def get_rssi(self, channel=0):
return self.getAttributeData("RSSI_DEVICE", channel)
class HelperRssiPeer(HMDevice):
"""Used for devices which report their RSSI value through RSSI_PEER"""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
self.ATTRIBUTENODE["RSSI_PEER"] = [0]
def get_rssi(self, channel=0):
return self.getAttributeData("RSSI_PEER", channel)
class HelperDeviceTemperature(HMDevice):
"""Used for devices that report their actual device temperature values (such as the HmIP Wired devices)"""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
self.ATTRIBUTENODE["ACTUAL_TEMPERATURE"] = [0]
"""Seek a specific value by specifying a float() from 0.0 to 1.0."""
try:
position = float(position)
except Exception as err:
LOG.debug("HelperActorBlindTilt.set_level_2: Exception %s" % (err,))
return False
level = self.getWriteData("LEVEL", channel)
self.writeNodeData("LEVEL_2", position, channel)
# set level after level_2 to have level_2 updated
self.writeNodeData("LEVEL", level, channel)
class HelperActionOnTime(HMDevice):
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
# init metadata
self.ACTIONNODE.update({"ON_TIME": self.ELEMENT})
def set_ontime(self, ontime):
"""Set duration th switch stays on when toggled. """
try:
ontime = float(ontime)
except Exception as err:
LOG.debug("SwitchPowermeter.set_ontime: Exception %s" % (err,))
return False
self.actionNodeData("ON_TIME", ontime)
self.actionNodeData("PRESS_LONG", 1, channel)
def press_short(self, channel=None):
"""Simulat a button press short."""
self.actionNodeData("PRESS_SHORT", 1, channel)
class HelperEventPress(HMDevice):
"""Remote handle buttons."""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
self.EVENTNODE.update({"PRESS": self.ELEMENT})
class HelperEventRemote(HMDevice):
"""Remote handle buttons."""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
self.EVENTNODE.update({"PRESS_SHORT": self.ELEMENT,
"PRESS_LONG": self.ELEMENT,
"PRESS_CONT": self.ELEMENT,
"PRESS_LONG_RELEASE": self.ELEMENT})
class HelperWired(HMDevice):
"""Remove the RSSI-related attributes"""
def __init__(self, device_description, proxy, resolveparamsets=False):
super().__init__(device_description, proxy, resolveparamsets)
self.ATTRIBUTENODE.pop("RSSI_PEER", None)
self.ATTRIBUTENODE.pop("RSSI_DEVICE", None)
import logging
from pyhomematic.devicetypes.generic import HMDevice
from pyhomematic.devicetypes.misc import HMEvent, Remote
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."""