Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try:
ontime = float(ontime)
except Exception as err:
LOG.debug("HMSwitchPowermeter.set_ontime: Exception %s" % (err,))
return False
if self._PARENT:
self._proxy.setValue(self._PARENT + ':1', 'ON_TIME', ontime)
else:
self.CHILDREN[1].setValue('ON_TIME', ontime)
class HMRemote(HMDevice):
pass
class HMWindowHandle(HMDevice):
@property
def sabotage(self):
""" Returns if the devicecase has been opened. """
if self._PARENT:
error = self._proxy.getValue(self._PARENT + ':1', 'ERROR')
else:
error = self.CHILDREN[1].getValue('ERROR')
if error == 1:
return True
else:
return False
@property
def low_batt(self):
""" Returns if the battery is low. """
return self.getValue('LOWBAT')
self.CHILDREN[1].setValue('STOP', True)
@property
def working(self):
"""Return True of False if working or not"""
if self._PARENT:
if self._working is None:
self._working = self._proxy.getValue(self._PARENT + ':1', 'WORKING')
return self._working
else:
if self.CHILDREN[1]._working is None:
self.CHILDREN[1]._working = self.CHILDREN[1].getValue('WORKING')
return self.CHILDREN[1]._working
class HMShutterContact(HMDevice):
"""
HM-Sec-SC, HM-Sec-SC-2, ZEL STG RM FFK
Door / Window contact that emits its open/closed state.
"""
@property
def sabotage(self):
""" Returns if the devicecase has been opened. """
if self._PARENT:
error = self._proxy.getValue(self._PARENT + ':1', 'ERROR')
else:
error = self.CHILDREN[1].getValue('ERROR')
if error == 7:
return True
else:
return False
""" Returns if the contact is closed. """
if self._PARENT:
return not self._proxy.getValue(self._PARENT + ':1', 'STATE')
else:
return not self.CHILDREN[1].getValue('STATE')
@property
def state(self):
""" Returns if the contact is 'open' or 'closed'. """
if self.is_closed:
return 'closed'
else:
return 'open'
class HMThermostat(HMDevice):
"""
HM-CC-RT-DN, HM-CC-RT-DN-BoM
ClimateControl-RadiatorThermostat that measures temperature and allows to set a target temperature or use some automatic mode.
"""
AUTO_MODE = 0
MANU_MODE = 1
PARTY_MODE = 2
BOOST_MODE = 3
@property
def actual_temperature(self):
""" Returns the current temperature. """
if self._PARENT:
return self._proxy.getValue(self._PARENT + ':4', 'ACTUAL_TEMPERATURE')
else:
return self.CHILDREN[4].getValue('ACTUAL_TEMPERATURE')
""" Returns the current battery state. """
if self._PARENT:
return self._proxy.getValue(self._PARENT + ':4', 'BATTERY_STATE')
else:
return self.CHILDREN[4].getValue('BATTERY_STATE')
@property
def valve_state(self):
""" Returns the current valve state. """
if self._PARENT:
return self._proxy.getValue(self._PARENT + ':4', 'VALVE_STATE')
else:
return self.CHILDREN[4].getValue('VALVE_STATE')
class HMMAXThermostat(HMDevice):
"""
BC-RT-TRX-CyG, BC-RT-TRX-CyG-2, BC-RT-TRX-CyG-3, BC-RT-TRX-CyG-4
ClimateControl-RadiatorThermostat that measures temperature and allows to set a target temperature or use some automatic mode.
"""
AUTO_MODE = 0
MANU_MODE = 1
PARTY_MODE = 2
BOOST_MODE = 3
@property
def actual_temperature(self):
""" Returns the current temperature. """
if self._PARENT:
return self._proxy.getValue(self._PARENT + ':1', 'ACTUAL_TEMPERATURE')
else:
return self.CHILDREN[1].getValue('ACTUAL_TEMPERATURE')
self.level = 0.0
@property
def working(self):
"""Return True of False if working or not"""
if self._PARENT:
if self._working is None:
self._working = self._proxy.getValue(self._PARENT + ':1', 'WORKING')
return self._working
else:
if self.CHILDREN[1]._working is None:
self.CHILDREN[1]._working = self.CHILDREN[1].getValue('WORKING')
return self.CHILDREN[1]._working
class HMSwitch(HMDevice):
"""
HM-LC-Sw1-Pl, HM-LC-Sw1-Pl-2, HM-LC-Sw1-SM, HM-LC-Sw2-SM, HM-LC-Sw4-SM, HM-LC-Sw4-PCB, HM-LC-Sw4-WM, HM-LC-Sw1-FM,
263 130, HM-LC-Sw2-FM, HM-LC-Sw1-PB-FM, HM-LC-Sw2-PB-FM, HM-LC-Sw4-DR, HM-LC-Sw2-DR, ZEL STG RM FZS,
ZEL STG RM FZS-2, HM-LC-SwX
Switch turning plugged in device on or off.
"""
def __init__(self, device_description, proxy, resolveparamsets=False):
super(HMSwitch, self).__init__(device_description, proxy, resolveparamsets)
self._working = None
def working_callback(device, caller, attribute, value):
attribute = str(attribute).upper()
if attribute == 'WORKING':
self._working = value
@boostmode.setter
def boostmode(self, setboost):
""" Turn on boost mode. """
self.mode = self.BOOST_MODE
@property
def battery_state(self):
""" Returns the current battery state. """
if self._PARENT:
return self._proxy.getValue(self._PARENT + ':0', 'LOWBAT')
else:
return self.CHILDREN[0].getValue('LOWBAT')
class HMDimmer(HMDevice):
"""
HM-LC-Dim1L-Pl, HM-LC-Dim1L-CV, HM-LC-Dim1L-Pl-3, HM-LC-Dim1L-CV-2
Dimmer switch that controls level of light brightness.
"""
def __init__(self, device_description, proxy, resolveparamsets=False):
super(HMDimmer, self).__init__(device_description, proxy, resolveparamsets)
self._working = None
def working_callback(device, caller, attribute, value):
attribute = str(attribute).upper()
if attribute == 'WORKING':
self._working = value
self.setEventCallback(working_callback, True)
callback(self._ADDRESS, interface_id, key, value)
def setEventCallback(self, callback, bequeath=True):
"""
Set additional event callbacks for the device.
Set the callback for specific channels or use the device itself and let it bequeath the callback to all of its children.
Signature for callback-functions: foo(address, interface_id, key, value).
"""
if hasattr(callback, '__call__'):
self._eventcallbacks.append(callback)
if bequeath and not self._PARENT:
for channel, device in self.CHILDREN.items():
device._eventcallbacks.append(callback)
class HMRollerShutter(HMDevice):
"""
HM-LC-Bl1-SM, HM-LC-Bl1-FM, HM-LC-Bl1-PB-FM, ZEL STG RM FEP 230V, 263 146, HM-LC-BlX
Rollershutter switch that raises and lowers roller shutters.
"""
def __init__(self, device_description, proxy, resolveparamsets=False):
super(HMRollerShutter, self).__init__(device_description, proxy, resolveparamsets)
self._working = None
def working_callback(device, caller, attribute, value):
attribute = str(attribute).upper()
if attribute == 'WORKING':
self._working = value
self.setEventCallback(working_callback, True)
self.state = False
@property
def working(self):
"""Return True of False if working or not"""
if self._PARENT:
if self._working is None:
self._working = self._proxy.getValue(self._PARENT + ':1', 'WORKING')
return self._working
else:
if self.CHILDREN[1]._working is None:
self.CHILDREN[1]._working = self.CHILDREN[1].getValue('WORKING')
return self.CHILDREN[1]._working
class HMSwitchPowermeter(HMDevice):
"""
HM-ES-PMSw1-Pl, HM-ES-PMSw1-Pl-DN-R1, HM-ES-PMSw1-Pl-DN-R2, HM-ES-PMSw1-Pl-DN-R3, HM-ES-PMSw1-Pl-DN-R4
HM-ES-PMSw1-Pl-DN-R5, HM-ES-PMSw1-DR, HM-ES-PMSw1-SM, HM-ES-PMSwX
Switch turning plugged in device on or off and measuring energy consumption.
"""
@property
def is_on(self):
""" Returns if switch is on. """
if self._PARENT:
return self._proxy.getValue(self._PARENT + ':1', 'STATE')
else:
return self.CHILDREN[1].getValue('STATE')
@property
def is_off(self):
return not self.CHILDREN[1].getValue('WORKING')
def set_ontime(self, ontime):
"""Set duration th switch stays on when toggled. """
try:
ontime = float(ontime)
except Exception as err:
LOG.debug("HMSwitchPowermeter.set_ontime: Exception %s" % (err,))
return False
if self._PARENT:
self._proxy.setValue(self._PARENT + ':1', 'ON_TIME', ontime)
else:
self.CHILDREN[1].setValue('ON_TIME', ontime)
class HMRemote(HMDevice):
pass
class HMWindowHandle(HMDevice):
@property
def sabotage(self):
""" Returns if the devicecase has been opened. """
if self._PARENT:
error = self._proxy.getValue(self._PARENT + ':1', 'ERROR')
else:
error = self.CHILDREN[1].getValue('ERROR')
if error == 1:
return True
else:
return False