Refactor LCN integration (#40665)
* Moved configuration schemes to schemes.py * Renamed LcnDevice to LcnEntity. Renamed address_connection to device_connection. * Rename schemes.py to schemas.py
This commit is contained in:
parent
bc83e30761
commit
378424b2c4
10 changed files with 286 additions and 266 deletions
|
@ -4,7 +4,7 @@ import pypck
|
|||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
||||
from homeassistant.const import CONF_ADDRESS
|
||||
|
||||
from . import LcnDevice
|
||||
from . import LcnEntity
|
||||
from .const import BINSENSOR_PORTS, CONF_CONNECTIONS, CONF_SOURCE, DATA_LCN, SETPOINTS
|
||||
from .helpers import get_connection
|
||||
|
||||
|
@ -36,12 +36,12 @@ async def async_setup_platform(
|
|||
async_add_entities(devices)
|
||||
|
||||
|
||||
class LcnRegulatorLockSensor(LcnDevice, BinarySensorEntity):
|
||||
class LcnRegulatorLockSensor(LcnEntity, BinarySensorEntity):
|
||||
"""Representation of a LCN binary sensor for regulator locks."""
|
||||
|
||||
def __init__(self, config, address_connection):
|
||||
def __init__(self, config, device_connection):
|
||||
"""Initialize the LCN binary sensor."""
|
||||
super().__init__(config, address_connection)
|
||||
super().__init__(config, device_connection)
|
||||
|
||||
self.setpoint_variable = pypck.lcn_defs.Var[config[CONF_SOURCE]]
|
||||
|
||||
|
@ -50,7 +50,7 @@ class LcnRegulatorLockSensor(LcnDevice, BinarySensorEntity):
|
|||
async def async_added_to_hass(self):
|
||||
"""Run when entity about to be added to hass."""
|
||||
await super().async_added_to_hass()
|
||||
await self.address_connection.activate_status_request_handler(
|
||||
await self.device_connection.activate_status_request_handler(
|
||||
self.setpoint_variable
|
||||
)
|
||||
|
||||
|
@ -71,12 +71,12 @@ class LcnRegulatorLockSensor(LcnDevice, BinarySensorEntity):
|
|||
self.async_write_ha_state()
|
||||
|
||||
|
||||
class LcnBinarySensor(LcnDevice, BinarySensorEntity):
|
||||
class LcnBinarySensor(LcnEntity, BinarySensorEntity):
|
||||
"""Representation of a LCN binary sensor for binary sensor ports."""
|
||||
|
||||
def __init__(self, config, address_connection):
|
||||
def __init__(self, config, device_connection):
|
||||
"""Initialize the LCN binary sensor."""
|
||||
super().__init__(config, address_connection)
|
||||
super().__init__(config, device_connection)
|
||||
|
||||
self.bin_sensor_port = pypck.lcn_defs.BinSensorPort[config[CONF_SOURCE]]
|
||||
|
||||
|
@ -85,7 +85,7 @@ class LcnBinarySensor(LcnDevice, BinarySensorEntity):
|
|||
async def async_added_to_hass(self):
|
||||
"""Run when entity about to be added to hass."""
|
||||
await super().async_added_to_hass()
|
||||
await self.address_connection.activate_status_request_handler(
|
||||
await self.device_connection.activate_status_request_handler(
|
||||
self.bin_sensor_port
|
||||
)
|
||||
|
||||
|
@ -103,12 +103,12 @@ class LcnBinarySensor(LcnDevice, BinarySensorEntity):
|
|||
self.async_write_ha_state()
|
||||
|
||||
|
||||
class LcnLockKeysSensor(LcnDevice, BinarySensorEntity):
|
||||
class LcnLockKeysSensor(LcnEntity, BinarySensorEntity):
|
||||
"""Representation of a LCN sensor for key locks."""
|
||||
|
||||
def __init__(self, config, address_connection):
|
||||
def __init__(self, config, device_connection):
|
||||
"""Initialize the LCN sensor."""
|
||||
super().__init__(config, address_connection)
|
||||
super().__init__(config, device_connection)
|
||||
|
||||
self.source = pypck.lcn_defs.Key[config[CONF_SOURCE]]
|
||||
self._value = None
|
||||
|
@ -116,7 +116,7 @@ class LcnLockKeysSensor(LcnDevice, BinarySensorEntity):
|
|||
async def async_added_to_hass(self):
|
||||
"""Run when entity about to be added to hass."""
|
||||
await super().async_added_to_hass()
|
||||
await self.address_connection.activate_status_request_handler(self.source)
|
||||
await self.device_connection.activate_status_request_handler(self.source)
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue