mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 04:50:05 +00:00
Refactoring of LCN component (#23824)
* Moved helper functions to const.py * Removed pypck attribute from LcnDevice * Bump to pypck==0.6.0 * Added myself as a codeowner * Moved helper functions to helpers.py
This commit is contained in:
committed by
Martin Hjelmare
parent
9d7aa8f05d
commit
c928f82cbf
@@ -4,9 +4,10 @@ import pypck
|
||||
from homeassistant.components.binary_sensor import BinarySensorDevice
|
||||
from homeassistant.const import CONF_ADDRESS
|
||||
|
||||
from . import LcnDevice, get_connection
|
||||
from . import LcnDevice
|
||||
from .const import (
|
||||
BINSENSOR_PORTS, CONF_CONNECTIONS, CONF_SOURCE, DATA_LCN, SETPOINTS)
|
||||
from .helpers import get_connection
|
||||
|
||||
|
||||
async def async_setup_platform(hass, hass_config, async_add_entities,
|
||||
@@ -43,7 +44,7 @@ class LcnRegulatorLockSensor(LcnDevice, BinarySensorDevice):
|
||||
super().__init__(config, address_connection)
|
||||
|
||||
self.setpoint_variable = \
|
||||
self.pypck.lcn_defs.Var[config[CONF_SOURCE]]
|
||||
pypck.lcn_defs.Var[config[CONF_SOURCE]]
|
||||
|
||||
self._value = None
|
||||
|
||||
@@ -60,7 +61,7 @@ class LcnRegulatorLockSensor(LcnDevice, BinarySensorDevice):
|
||||
|
||||
def input_received(self, input_obj):
|
||||
"""Set sensor value when LCN input object (command) is received."""
|
||||
if not isinstance(input_obj, self.pypck.inputs.ModStatusVar) or \
|
||||
if not isinstance(input_obj, pypck.inputs.ModStatusVar) or \
|
||||
input_obj.get_var() != self.setpoint_variable:
|
||||
return
|
||||
|
||||
@@ -76,7 +77,7 @@ class LcnBinarySensor(LcnDevice, BinarySensorDevice):
|
||||
super().__init__(config, address_connection)
|
||||
|
||||
self.bin_sensor_port = \
|
||||
self.pypck.lcn_defs.BinSensorPort[config[CONF_SOURCE]]
|
||||
pypck.lcn_defs.BinSensorPort[config[CONF_SOURCE]]
|
||||
|
||||
self._value = None
|
||||
|
||||
@@ -93,7 +94,7 @@ class LcnBinarySensor(LcnDevice, BinarySensorDevice):
|
||||
|
||||
def input_received(self, input_obj):
|
||||
"""Set sensor value when LCN input object (command) is received."""
|
||||
if not isinstance(input_obj, self.pypck.inputs.ModStatusBinSensors):
|
||||
if not isinstance(input_obj, pypck.inputs.ModStatusBinSensors):
|
||||
return
|
||||
|
||||
self._value = input_obj.get_state(self.bin_sensor_port.value)
|
||||
@@ -107,7 +108,7 @@ class LcnLockKeysSensor(LcnDevice, BinarySensorDevice):
|
||||
"""Initialize the LCN sensor."""
|
||||
super().__init__(config, address_connection)
|
||||
|
||||
self.source = self.pypck.lcn_defs.Key[config[CONF_SOURCE]]
|
||||
self.source = pypck.lcn_defs.Key[config[CONF_SOURCE]]
|
||||
self._value = None
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
@@ -123,8 +124,8 @@ class LcnLockKeysSensor(LcnDevice, BinarySensorDevice):
|
||||
|
||||
def input_received(self, input_obj):
|
||||
"""Set sensor value when LCN input object (command) is received."""
|
||||
if not isinstance(input_obj, self.pypck.inputs.ModStatusKeyLocks) or \
|
||||
self.source not in self.pypck.lcn_defs.Key:
|
||||
if not isinstance(input_obj, pypck.inputs.ModStatusKeyLocks) or \
|
||||
self.source not in pypck.lcn_defs.Key:
|
||||
return
|
||||
|
||||
table_id = ord(self.source.name[0]) - 65
|
||||
|
||||
Reference in New Issue
Block a user