Black
This commit is contained in:
parent
da05dfe708
commit
4de97abc3a
2676 changed files with 163166 additions and 140084 deletions
|
@ -5,13 +5,13 @@ from homeassistant.components.binary_sensor import BinarySensorDevice
|
|||
from homeassistant.const import CONF_ADDRESS
|
||||
|
||||
from . import LcnDevice
|
||||
from .const import (
|
||||
BINSENSOR_PORTS, CONF_CONNECTIONS, CONF_SOURCE, DATA_LCN, SETPOINTS)
|
||||
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,
|
||||
discovery_info=None):
|
||||
async def async_setup_platform(
|
||||
hass, hass_config, async_add_entities, discovery_info=None
|
||||
):
|
||||
"""Set up the LCN binary sensor platform."""
|
||||
if discovery_info is None:
|
||||
return
|
||||
|
@ -43,8 +43,7 @@ class LcnRegulatorLockSensor(LcnDevice, BinarySensorDevice):
|
|||
"""Initialize the LCN binary sensor."""
|
||||
super().__init__(config, address_connection)
|
||||
|
||||
self.setpoint_variable = \
|
||||
pypck.lcn_defs.Var[config[CONF_SOURCE]]
|
||||
self.setpoint_variable = pypck.lcn_defs.Var[config[CONF_SOURCE]]
|
||||
|
||||
self._value = None
|
||||
|
||||
|
@ -52,7 +51,8 @@ class LcnRegulatorLockSensor(LcnDevice, BinarySensorDevice):
|
|||
"""Run when entity about to be added to hass."""
|
||||
await super().async_added_to_hass()
|
||||
await self.address_connection.activate_status_request_handler(
|
||||
self.setpoint_variable)
|
||||
self.setpoint_variable
|
||||
)
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
|
@ -61,8 +61,10 @@ 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, pypck.inputs.ModStatusVar) or \
|
||||
input_obj.get_var() != self.setpoint_variable:
|
||||
if (
|
||||
not isinstance(input_obj, pypck.inputs.ModStatusVar)
|
||||
or input_obj.get_var() != self.setpoint_variable
|
||||
):
|
||||
return
|
||||
|
||||
self._value = input_obj.get_value().is_locked_regulator()
|
||||
|
@ -76,8 +78,7 @@ class LcnBinarySensor(LcnDevice, BinarySensorDevice):
|
|||
"""Initialize the LCN binary sensor."""
|
||||
super().__init__(config, address_connection)
|
||||
|
||||
self.bin_sensor_port = \
|
||||
pypck.lcn_defs.BinSensorPort[config[CONF_SOURCE]]
|
||||
self.bin_sensor_port = pypck.lcn_defs.BinSensorPort[config[CONF_SOURCE]]
|
||||
|
||||
self._value = None
|
||||
|
||||
|
@ -85,7 +86,8 @@ class LcnBinarySensor(LcnDevice, BinarySensorDevice):
|
|||
"""Run when entity about to be added to hass."""
|
||||
await super().async_added_to_hass()
|
||||
await self.address_connection.activate_status_request_handler(
|
||||
self.bin_sensor_port)
|
||||
self.bin_sensor_port
|
||||
)
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
|
@ -114,8 +116,7 @@ class LcnLockKeysSensor(LcnDevice, BinarySensorDevice):
|
|||
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.address_connection.activate_status_request_handler(self.source)
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
|
@ -124,8 +125,10 @@ 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, pypck.inputs.ModStatusKeyLocks) or \
|
||||
self.source not in 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue