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:
Andre Lengwenus 2019-05-25 11:40:44 +02:00 committed by Martin Hjelmare
parent 9d7aa8f05d
commit c928f82cbf
12 changed files with 144 additions and 129 deletions

View File

@ -131,6 +131,7 @@ homeassistant/components/kodi/* @armills
homeassistant/components/konnected/* @heythisisnate
homeassistant/components/lametric/* @robbiet480
homeassistant/components/launch_library/* @ludeeus
homeassistant/components/lcn/* @alengwenus
homeassistant/components/lifx/* @amelchio
homeassistant/components/lifx_cloud/* @amelchio
homeassistant/components/lifx_legacy/* @amelchio

View File

@ -2,7 +2,6 @@
import logging
import pypck
from pypck.connection import PchkConnectionManager
import voluptuous as vol
from homeassistant.components.climate import DEFAULT_MAX_TEMP, DEFAULT_MIN_TEMP
@ -18,55 +17,13 @@ from .const import (
BINSENSOR_PORTS, CONF_CLIMATES, CONF_CONNECTIONS, CONF_DIM_MODE,
CONF_DIMMABLE, CONF_LOCKABLE, CONF_MAX_TEMP, CONF_MIN_TEMP, CONF_MOTOR,
CONF_OUTPUT, CONF_SETPOINT, CONF_SK_NUM_TRIES, CONF_SOURCE,
CONF_TRANSITION, DATA_LCN, DEFAULT_NAME, DIM_MODES, DOMAIN, KEYS,
LED_PORTS, LOGICOP_PORTS, MOTOR_PORTS, OUTPUT_PORTS, PATTERN_ADDRESS,
RELAY_PORTS, S0_INPUTS, SETPOINTS, THRESHOLDS, VAR_UNITS, VARIABLES)
CONF_TRANSITION, DATA_LCN, DIM_MODES, DOMAIN, KEYS, LED_PORTS,
LOGICOP_PORTS, MOTOR_PORTS, OUTPUT_PORTS, RELAY_PORTS, S0_INPUTS,
SETPOINTS, THRESHOLDS, VAR_UNITS, VARIABLES)
from .helpers import has_unique_connection_names, is_address
_LOGGER = logging.getLogger(__name__)
def has_unique_connection_names(connections):
"""Validate that all connection names are unique.
Use 'pchk' as default connection_name (or add a numeric suffix if
pchk' is already in use.
"""
for suffix, connection in enumerate(connections):
connection_name = connection.get(CONF_NAME)
if connection_name is None:
if suffix == 0:
connection[CONF_NAME] = DEFAULT_NAME
else:
connection[CONF_NAME] = '{}{:d}'.format(DEFAULT_NAME, suffix)
schema = vol.Schema(vol.Unique())
schema([connection.get(CONF_NAME) for connection in connections])
return connections
def is_address(value):
"""Validate the given address string.
Examples for S000M005 at myhome:
myhome.s000.m005
myhome.s0.m5
myhome.0.5 ("m" is implicit if missing)
Examples for s000g011
myhome.0.g11
myhome.s0.g11
"""
matcher = PATTERN_ADDRESS.match(value)
if matcher:
is_group = (matcher.group('type') == 'g')
addr = (int(matcher.group('seg_id')),
int(matcher.group('id')),
is_group)
conn_id = matcher.group('conn_id')
return addr, conn_id
raise vol.error.Invalid('Not a valid address string.')
BINARY_SENSORS_SCHEMA = vol.Schema({
vol.Required(CONF_NAME): cv.string,
vol.Required(CONF_ADDRESS): is_address,
@ -153,19 +110,6 @@ CONFIG_SCHEMA = vol.Schema({
}, extra=vol.ALLOW_EXTRA)
def get_connection(connections, connection_id=None):
"""Return the connection object from list."""
if connection_id is None:
connection = connections[0]
else:
for connection in connections:
if connection.connection_id == connection_id:
break
else:
raise ValueError('Unknown connection_id.')
return connection
async def async_setup(hass, config):
"""Set up the LCN component."""
hass.data[DATA_LCN] = {}
@ -179,13 +123,14 @@ async def async_setup(hass, config):
'DIM_MODE': pypck.lcn_defs.OutputPortDimMode[
conf_connection[CONF_DIM_MODE]]}
connection = PchkConnectionManager(hass.loop,
conf_connection[CONF_HOST],
conf_connection[CONF_PORT],
conf_connection[CONF_USERNAME],
conf_connection[CONF_PASSWORD],
settings=settings,
connection_id=connection_name)
connection = pypck.connection.PchkConnectionManager(
hass.loop,
conf_connection[CONF_HOST],
conf_connection[CONF_PORT],
conf_connection[CONF_USERNAME],
conf_connection[CONF_PASSWORD],
settings=settings,
connection_id=connection_name)
try:
# establish connection to PCHK server
@ -218,7 +163,6 @@ class LcnDevice(Entity):
def __init__(self, config, address_connection):
"""Initialize the LCN device."""
self.pypck = pypck
self.config = config
self.address_connection = address_connection
self._name = config[CONF_NAME]

View File

@ -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

View File

@ -5,10 +5,11 @@ from homeassistant.components.climate import ClimateDevice, const
from homeassistant.const import (
ATTR_TEMPERATURE, CONF_ADDRESS, CONF_UNIT_OF_MEASUREMENT)
from . import LcnDevice, get_connection
from . import LcnDevice
from .const import (
CONF_CONNECTIONS, CONF_LOCKABLE, CONF_MAX_TEMP, CONF_MIN_TEMP,
CONF_SETPOINT, CONF_SOURCE, DATA_LCN)
from .helpers import get_connection
async def async_setup_platform(hass, hass_config, async_add_entities,
@ -37,13 +38,13 @@ class LcnClimate(LcnDevice, ClimateDevice):
"""Initialize of a LCN climate device."""
super().__init__(config, address_connection)
self.variable = self.pypck.lcn_defs.Var[config[CONF_SOURCE]]
self.setpoint = self.pypck.lcn_defs.Var[config[CONF_SETPOINT]]
self.unit = self.pypck.lcn_defs.VarUnit.parse(
self.variable = pypck.lcn_defs.Var[config[CONF_SOURCE]]
self.setpoint = pypck.lcn_defs.Var[config[CONF_SETPOINT]]
self.unit = pypck.lcn_defs.VarUnit.parse(
config[CONF_UNIT_OF_MEASUREMENT])
self.regulator_id = \
self.pypck.lcn_defs.Var.to_set_point_id(self.setpoint)
pypck.lcn_defs.Var.to_set_point_id(self.setpoint)
self.is_lockable = config[CONF_LOCKABLE]
self._max_temp = config[CONF_MAX_TEMP]
self._min_temp = config[CONF_MIN_TEMP]
@ -125,7 +126,7 @@ class LcnClimate(LcnDevice, ClimateDevice):
def input_received(self, input_obj):
"""Set temperature value when LCN input object is received."""
if not isinstance(input_obj, self.pypck.inputs.ModStatusVar):
if not isinstance(input_obj, pypck.inputs.ModStatusVar):
return
if input_obj.get_var() == self.variable:

View File

@ -1,7 +1,6 @@
# coding: utf-8
"""Constants for the LCN component."""
from itertools import product
import re
from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT
@ -9,10 +8,6 @@ DOMAIN = 'lcn'
DATA_LCN = 'lcn'
DEFAULT_NAME = 'pchk'
# Regex for address validation
PATTERN_ADDRESS = re.compile('^((?P<conn_id>\\w+)\\.)?s?(?P<seg_id>\\d+)'
'\\.(?P<type>m|g)?(?P<id>\\d+)$')
CONF_CONNECTIONS = 'connections'
CONF_SK_NUM_TRIES = 'sk_num_tries'
CONF_OUTPUT = 'output'

View File

@ -4,8 +4,9 @@ import pypck
from homeassistant.components.cover import CoverDevice
from homeassistant.const import CONF_ADDRESS
from . import LcnDevice, get_connection
from . import LcnDevice
from .const import CONF_CONNECTIONS, CONF_MOTOR, DATA_LCN
from .helpers import get_connection
async def async_setup_platform(hass, hass_config, async_add_entities,
@ -34,7 +35,7 @@ class LcnCover(LcnDevice, CoverDevice):
"""Initialize the LCN cover."""
super().__init__(config, address_connection)
self.motor = self.pypck.lcn_defs.MotorPort[config[CONF_MOTOR]]
self.motor = pypck.lcn_defs.MotorPort[config[CONF_MOTOR]]
self.motor_port_onoff = self.motor.value * 2
self.motor_port_updown = self.motor_port_onoff + 1
@ -54,30 +55,30 @@ class LcnCover(LcnDevice, CoverDevice):
async def async_close_cover(self, **kwargs):
"""Close the cover."""
self._closed = True
states = [self.pypck.lcn_defs.MotorStateModifier.NOCHANGE] * 4
states[self.motor.value] = self.pypck.lcn_defs.MotorStateModifier.DOWN
states = [pypck.lcn_defs.MotorStateModifier.NOCHANGE] * 4
states[self.motor.value] = pypck.lcn_defs.MotorStateModifier.DOWN
self.address_connection.control_motors(states)
await self.async_update_ha_state()
async def async_open_cover(self, **kwargs):
"""Open the cover."""
self._closed = False
states = [self.pypck.lcn_defs.MotorStateModifier.NOCHANGE] * 4
states[self.motor.value] = self.pypck.lcn_defs.MotorStateModifier.UP
states = [pypck.lcn_defs.MotorStateModifier.NOCHANGE] * 4
states[self.motor.value] = pypck.lcn_defs.MotorStateModifier.UP
self.address_connection.control_motors(states)
await self.async_update_ha_state()
async def async_stop_cover(self, **kwargs):
"""Stop the cover."""
self._closed = None
states = [self.pypck.lcn_defs.MotorStateModifier.NOCHANGE] * 4
states[self.motor.value] = self.pypck.lcn_defs.MotorStateModifier.STOP
states = [pypck.lcn_defs.MotorStateModifier.NOCHANGE] * 4
states[self.motor.value] = pypck.lcn_defs.MotorStateModifier.STOP
self.address_connection.control_motors(states)
await self.async_update_ha_state()
def input_received(self, input_obj):
"""Set cover states when LCN input object (command) is received."""
if not isinstance(input_obj, self.pypck.inputs.ModStatusRelays):
if not isinstance(input_obj, pypck.inputs.ModStatusRelays):
return
states = input_obj.states # list of boolean values (relay on/off)

View File

@ -0,0 +1,67 @@
"""Helpers for LCN component."""
import re
import voluptuous as vol
from homeassistant.const import CONF_NAME
from .const import DEFAULT_NAME
# Regex for address validation
PATTERN_ADDRESS = re.compile('^((?P<conn_id>\\w+)\\.)?s?(?P<seg_id>\\d+)'
'\\.(?P<type>m|g)?(?P<id>\\d+)$')
def get_connection(connections, connection_id=None):
"""Return the connection object from list."""
if connection_id is None:
connection = connections[0]
else:
for connection in connections:
if connection.connection_id == connection_id:
break
else:
raise ValueError('Unknown connection_id.')
return connection
def has_unique_connection_names(connections):
"""Validate that all connection names are unique.
Use 'pchk' as default connection_name (or add a numeric suffix if
pchk' is already in use.
"""
for suffix, connection in enumerate(connections):
connection_name = connection.get(CONF_NAME)
if connection_name is None:
if suffix == 0:
connection[CONF_NAME] = DEFAULT_NAME
else:
connection[CONF_NAME] = '{}{:d}'.format(DEFAULT_NAME, suffix)
schema = vol.Schema(vol.Unique())
schema([connection.get(CONF_NAME) for connection in connections])
return connections
def is_address(value):
"""Validate the given address string.
Examples for S000M005 at myhome:
myhome.s000.m005
myhome.s0.m5
myhome.0.5 ("m" is implicit if missing)
Examples for s000g011
myhome.0.g11
myhome.s0.g11
"""
matcher = PATTERN_ADDRESS.match(value)
if matcher:
is_group = (matcher.group('type') == 'g')
addr = (int(matcher.group('seg_id')),
int(matcher.group('id')),
is_group)
conn_id = matcher.group('conn_id')
return addr, conn_id
raise vol.error.Invalid('Not a valid address string.')

View File

@ -6,10 +6,11 @@ from homeassistant.components.light import (
Light)
from homeassistant.const import CONF_ADDRESS
from . import LcnDevice, get_connection
from . import LcnDevice
from .const import (
CONF_CONNECTIONS, CONF_DIMMABLE, CONF_OUTPUT, CONF_TRANSITION, DATA_LCN,
OUTPUT_PORTS)
from .helpers import get_connection
async def async_setup_platform(
@ -43,9 +44,9 @@ class LcnOutputLight(LcnDevice, Light):
"""Initialize the LCN light."""
super().__init__(config, address_connection)
self.output = self.pypck.lcn_defs.OutputPort[config[CONF_OUTPUT]]
self.output = pypck.lcn_defs.OutputPort[config[CONF_OUTPUT]]
self._transition = self.pypck.lcn_defs.time_to_ramp_value(
self._transition = pypck.lcn_defs.time_to_ramp_value(
config[CONF_TRANSITION])
self.dimmable = config[CONF_DIMMABLE]
@ -86,7 +87,7 @@ class LcnOutputLight(LcnDevice, Light):
else:
percent = 100
if ATTR_TRANSITION in kwargs:
transition = self.pypck.lcn_defs.time_to_ramp_value(
transition = pypck.lcn_defs.time_to_ramp_value(
kwargs[ATTR_TRANSITION] * 1000)
else:
transition = self._transition
@ -99,7 +100,7 @@ class LcnOutputLight(LcnDevice, Light):
"""Turn the entity off."""
self._is_on = False
if ATTR_TRANSITION in kwargs:
transition = self.pypck.lcn_defs.time_to_ramp_value(
transition = pypck.lcn_defs.time_to_ramp_value(
kwargs[ATTR_TRANSITION] * 1000)
else:
transition = self._transition
@ -111,7 +112,7 @@ class LcnOutputLight(LcnDevice, Light):
def input_received(self, input_obj):
"""Set light state when LCN input object (command) is received."""
if not isinstance(input_obj, self.pypck.inputs.ModStatusOutput) or \
if not isinstance(input_obj, pypck.inputs.ModStatusOutput) or \
input_obj.get_output_id() != self.output.value:
return
@ -130,7 +131,7 @@ class LcnRelayLight(LcnDevice, Light):
"""Initialize the LCN light."""
super().__init__(config, address_connection)
self.output = self.pypck.lcn_defs.RelayPort[config[CONF_OUTPUT]]
self.output = pypck.lcn_defs.RelayPort[config[CONF_OUTPUT]]
self._is_on = None
@ -149,8 +150,8 @@ class LcnRelayLight(LcnDevice, Light):
"""Turn the entity on."""
self._is_on = True
states = [self.pypck.lcn_defs.RelayStateModifier.NOCHANGE] * 8
states[self.output.value] = self.pypck.lcn_defs.RelayStateModifier.ON
states = [pypck.lcn_defs.RelayStateModifier.NOCHANGE] * 8
states[self.output.value] = pypck.lcn_defs.RelayStateModifier.ON
self.address_connection.control_relays(states)
await self.async_update_ha_state()
@ -159,15 +160,15 @@ class LcnRelayLight(LcnDevice, Light):
"""Turn the entity off."""
self._is_on = False
states = [self.pypck.lcn_defs.RelayStateModifier.NOCHANGE] * 8
states[self.output.value] = self.pypck.lcn_defs.RelayStateModifier.OFF
states = [pypck.lcn_defs.RelayStateModifier.NOCHANGE] * 8
states[self.output.value] = pypck.lcn_defs.RelayStateModifier.OFF
self.address_connection.control_relays(states)
await self.async_update_ha_state()
def input_received(self, input_obj):
"""Set light state when LCN input object (command) is received."""
if not isinstance(input_obj, self.pypck.inputs.ModStatusRelays):
if not isinstance(input_obj, pypck.inputs.ModStatusRelays):
return
self._is_on = input_obj.get_state(self.output.value)

View File

@ -3,8 +3,10 @@
"name": "Lcn",
"documentation": "https://www.home-assistant.io/components/lcn",
"requirements": [
"pypck==0.5.9"
"pypck==0.6.0"
],
"dependencies": [],
"codeowners": []
"codeowners": [
"@alengwenus"
]
}

View File

@ -3,10 +3,11 @@ import pypck
from homeassistant.const import CONF_ADDRESS, CONF_UNIT_OF_MEASUREMENT
from . import LcnDevice, get_connection
from . import LcnDevice
from .const import (
CONF_CONNECTIONS, CONF_SOURCE, DATA_LCN, LED_PORTS, S0_INPUTS, SETPOINTS,
THRESHOLDS, VARIABLES)
from .helpers import get_connection
async def async_setup_platform(hass, hass_config, async_add_entities,
@ -41,8 +42,8 @@ class LcnVariableSensor(LcnDevice):
"""Initialize the LCN sensor."""
super().__init__(config, address_connection)
self.variable = self.pypck.lcn_defs.Var[config[CONF_SOURCE]]
self.unit = self.pypck.lcn_defs.VarUnit.parse(
self.variable = pypck.lcn_defs.Var[config[CONF_SOURCE]]
self.unit = pypck.lcn_defs.VarUnit.parse(
config[CONF_UNIT_OF_MEASUREMENT])
self._value = None
@ -65,7 +66,7 @@ class LcnVariableSensor(LcnDevice):
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.variable:
return
@ -81,9 +82,9 @@ class LcnLedLogicSensor(LcnDevice):
super().__init__(config, address_connection)
if config[CONF_SOURCE] in LED_PORTS:
self.source = self.pypck.lcn_defs.LedPort[config[CONF_SOURCE]]
self.source = pypck.lcn_defs.LedPort[config[CONF_SOURCE]]
else:
self.source = self.pypck.lcn_defs.LogicOpPort[config[CONF_SOURCE]]
self.source = pypck.lcn_defs.LogicOpPort[config[CONF_SOURCE]]
self._value = None
@ -101,13 +102,13 @@ class LcnLedLogicSensor(LcnDevice):
def input_received(self, input_obj):
"""Set sensor value when LCN input object (command) is received."""
if not isinstance(input_obj,
self.pypck.inputs.ModStatusLedsAndLogicOps):
pypck.inputs.ModStatusLedsAndLogicOps):
return
if self.source in self.pypck.lcn_defs.LedPort:
if self.source in pypck.lcn_defs.LedPort:
self._value = input_obj.get_led_state(
self.source.value).name.lower()
elif self.source in self.pypck.lcn_defs.LogicOpPort:
elif self.source in pypck.lcn_defs.LogicOpPort:
self._value = input_obj.get_logic_op_state(
self.source.value).name.lower()

View File

@ -4,8 +4,9 @@ import pypck
from homeassistant.components.switch import SwitchDevice
from homeassistant.const import CONF_ADDRESS
from . import LcnDevice, get_connection
from . import LcnDevice
from .const import CONF_CONNECTIONS, CONF_OUTPUT, DATA_LCN, OUTPUT_PORTS
from .helpers import get_connection
async def async_setup_platform(hass, hass_config, async_add_entities,
@ -39,7 +40,7 @@ class LcnOutputSwitch(LcnDevice, SwitchDevice):
"""Initialize the LCN switch."""
super().__init__(config, address_connection)
self.output = self.pypck.lcn_defs.OutputPort[config[CONF_OUTPUT]]
self.output = pypck.lcn_defs.OutputPort[config[CONF_OUTPUT]]
self._is_on = None
@ -68,7 +69,7 @@ class LcnOutputSwitch(LcnDevice, SwitchDevice):
def input_received(self, input_obj):
"""Set switch state when LCN input object (command) is received."""
if not isinstance(input_obj, self.pypck.inputs.ModStatusOutput) or \
if not isinstance(input_obj, pypck.inputs.ModStatusOutput) or \
input_obj.get_output_id() != self.output.value:
return
@ -83,7 +84,7 @@ class LcnRelaySwitch(LcnDevice, SwitchDevice):
"""Initialize the LCN switch."""
super().__init__(config, address_connection)
self.output = self.pypck.lcn_defs.RelayPort[config[CONF_OUTPUT]]
self.output = pypck.lcn_defs.RelayPort[config[CONF_OUTPUT]]
self._is_on = None
@ -102,8 +103,8 @@ class LcnRelaySwitch(LcnDevice, SwitchDevice):
"""Turn the entity on."""
self._is_on = True
states = [self.pypck.lcn_defs.RelayStateModifier.NOCHANGE] * 8
states[self.output.value] = self.pypck.lcn_defs.RelayStateModifier.ON
states = [pypck.lcn_defs.RelayStateModifier.NOCHANGE] * 8
states[self.output.value] = pypck.lcn_defs.RelayStateModifier.ON
self.address_connection.control_relays(states)
await self.async_update_ha_state()
@ -111,14 +112,14 @@ class LcnRelaySwitch(LcnDevice, SwitchDevice):
"""Turn the entity off."""
self._is_on = False
states = [self.pypck.lcn_defs.RelayStateModifier.NOCHANGE] * 8
states[self.output.value] = self.pypck.lcn_defs.RelayStateModifier.OFF
states = [pypck.lcn_defs.RelayStateModifier.NOCHANGE] * 8
states[self.output.value] = pypck.lcn_defs.RelayStateModifier.OFF
self.address_connection.control_relays(states)
await self.async_update_ha_state()
def input_received(self, input_obj):
"""Set switch state when LCN input object (command) is received."""
if not isinstance(input_obj, self.pypck.inputs.ModStatusRelays):
if not isinstance(input_obj, pypck.inputs.ModStatusRelays):
return
self._is_on = input_obj.get_state(self.output.value)

View File

@ -1259,7 +1259,7 @@ pyowlet==1.0.2
pyowm==2.10.0
# homeassistant.components.lcn
pypck==0.5.9
pypck==0.6.0
# homeassistant.components.pjlink
pypjlink2==1.2.0