diff --git a/homeassistant/components/lcn/__init__.py b/homeassistant/components/lcn/__init__.py index 9cf91695d56..faba23a52b9 100644 --- a/homeassistant/components/lcn/__init__.py +++ b/homeassistant/components/lcn/__init__.py @@ -233,7 +233,6 @@ async def async_setup(hass, config): } connection = pypck.connection.PchkConnectionManager( - hass.loop, conf_connection[CONF_HOST], conf_connection[CONF_PORT], conf_connection[CONF_USERNAME], diff --git a/homeassistant/components/lcn/climate.py b/homeassistant/components/lcn/climate.py index 9634dcf8fb3..f55734a052f 100644 --- a/homeassistant/components/lcn/climate.py +++ b/homeassistant/components/lcn/climate.py @@ -17,6 +17,8 @@ from .const import ( ) from .helpers import get_connection +PARALLEL_UPDATES = 0 + async def async_setup_platform( hass, hass_config, async_add_entities, discovery_info=None @@ -118,14 +120,20 @@ class LcnClimate(LcnDevice, ClimateEntity): async def async_set_hvac_mode(self, hvac_mode): """Set new target hvac mode.""" if hvac_mode == const.HVAC_MODE_HEAT: + if not await self.address_connection.lock_regulator( + self.regulator_id, False + ): + return self._is_on = True - self.address_connection.lock_regulator(self.regulator_id, False) + self.async_write_ha_state() elif hvac_mode == const.HVAC_MODE_OFF: + if not await self.address_connection.lock_regulator( + self.regulator_id, True + ): + return self._is_on = False - self.address_connection.lock_regulator(self.regulator_id, True) self._target_temperature = None - - self.async_write_ha_state() + self.async_write_ha_state() async def async_set_temperature(self, **kwargs): """Set new target temperature.""" @@ -133,10 +141,11 @@ class LcnClimate(LcnDevice, ClimateEntity): if temperature is None: return - self._target_temperature = temperature - self.address_connection.var_abs( + if not await self.address_connection.var_abs( self.setpoint, self._target_temperature, self.unit - ) + ): + return + self._target_temperature = temperature self.async_write_ha_state() def input_received(self, input_obj): diff --git a/homeassistant/components/lcn/cover.py b/homeassistant/components/lcn/cover.py index 512a7978c8c..ae88441f89e 100644 --- a/homeassistant/components/lcn/cover.py +++ b/homeassistant/components/lcn/cover.py @@ -8,6 +8,8 @@ from . import LcnDevice from .const import CONF_CONNECTIONS, CONF_MOTOR, CONF_REVERSE_TIME, DATA_LCN from .helpers import get_connection +PARALLEL_UPDATES = 0 + async def async_setup_platform( hass, hass_config, async_add_entities, discovery_info=None @@ -86,27 +88,34 @@ class LcnOutputsCover(LcnDevice, CoverEntity): async def async_close_cover(self, **kwargs): """Close the cover.""" + state = pypck.lcn_defs.MotorStateModifier.DOWN + if not await self.address_connection.control_motors_outputs( + state, self.reverse_time + ): + return self._is_opening = False self._is_closing = True - state = pypck.lcn_defs.MotorStateModifier.DOWN - self.address_connection.control_motors_outputs(state, self.reverse_time) self.async_write_ha_state() async def async_open_cover(self, **kwargs): """Open the cover.""" + state = pypck.lcn_defs.MotorStateModifier.UP + if not await self.address_connection.control_motors_outputs( + state, self.reverse_time + ): + return self._is_closed = False self._is_opening = True self._is_closing = False - state = pypck.lcn_defs.MotorStateModifier.UP - self.address_connection.control_motors_outputs(state, self.reverse_time) self.async_write_ha_state() async def async_stop_cover(self, **kwargs): """Stop the cover.""" + state = pypck.lcn_defs.MotorStateModifier.STOP + if not await self.address_connection.control_motors_outputs(state): + return self._is_closing = False self._is_opening = False - state = pypck.lcn_defs.MotorStateModifier.STOP - self.address_connection.control_motors_outputs(state) self.async_write_ha_state() def input_received(self, input_obj): @@ -176,30 +185,33 @@ class LcnRelayCover(LcnDevice, CoverEntity): async def async_close_cover(self, **kwargs): """Close the cover.""" - self._is_opening = False - self._is_closing = True states = [pypck.lcn_defs.MotorStateModifier.NOCHANGE] * 4 states[self.motor.value] = pypck.lcn_defs.MotorStateModifier.DOWN - self.address_connection.control_motors_relays(states) + if not await self.address_connection.control_motors_relays(states): + return + self._is_opening = False + self._is_closing = True self.async_write_ha_state() async def async_open_cover(self, **kwargs): """Open the cover.""" + states = [pypck.lcn_defs.MotorStateModifier.NOCHANGE] * 4 + states[self.motor.value] = pypck.lcn_defs.MotorStateModifier.UP + if not await self.address_connection.control_motors_relays(states): + return self._is_closed = False self._is_opening = True self._is_closing = False - states = [pypck.lcn_defs.MotorStateModifier.NOCHANGE] * 4 - states[self.motor.value] = pypck.lcn_defs.MotorStateModifier.UP - self.address_connection.control_motors_relays(states) self.async_write_ha_state() async def async_stop_cover(self, **kwargs): """Stop the cover.""" - self._is_closing = False - self._is_opening = False states = [pypck.lcn_defs.MotorStateModifier.NOCHANGE] * 4 states[self.motor.value] = pypck.lcn_defs.MotorStateModifier.STOP - self.address_connection.control_motors_relays(states) + if not await self.address_connection.control_motors_relays(states): + return + self._is_closing = False + self._is_opening = False self.async_write_ha_state() def input_received(self, input_obj): diff --git a/homeassistant/components/lcn/light.py b/homeassistant/components/lcn/light.py index 8fd24c43069..def025e0cf2 100644 --- a/homeassistant/components/lcn/light.py +++ b/homeassistant/components/lcn/light.py @@ -21,6 +21,8 @@ from .const import ( ) from .helpers import get_connection +PARALLEL_UPDATES = 0 + async def async_setup_platform( hass, hass_config, async_add_entities, discovery_info=None @@ -87,8 +89,6 @@ class LcnOutputLight(LcnDevice, LightEntity): async def async_turn_on(self, **kwargs): """Turn the entity on.""" - self._is_on = True - self._is_dimming_to_zero = False if ATTR_BRIGHTNESS in kwargs: percent = int(kwargs[ATTR_BRIGHTNESS] / 255.0 * 100) else: @@ -100,12 +100,16 @@ class LcnOutputLight(LcnDevice, LightEntity): else: transition = self._transition - self.address_connection.dim_output(self.output.value, percent, transition) + if not await self.address_connection.dim_output( + self.output.value, percent, transition + ): + return + self._is_on = True + self._is_dimming_to_zero = False self.async_write_ha_state() async def async_turn_off(self, **kwargs): """Turn the entity off.""" - self._is_on = False if ATTR_TRANSITION in kwargs: transition = pypck.lcn_defs.time_to_ramp_value( kwargs[ATTR_TRANSITION] * 1000 @@ -113,9 +117,12 @@ class LcnOutputLight(LcnDevice, LightEntity): else: transition = self._transition + if not await self.address_connection.dim_output( + self.output.value, 0, transition + ): + return self._is_dimming_to_zero = bool(transition) - - self.address_connection.dim_output(self.output.value, 0, transition) + self._is_on = False self.async_write_ha_state() def input_received(self, input_obj): @@ -157,22 +164,22 @@ class LcnRelayLight(LcnDevice, LightEntity): async def async_turn_on(self, **kwargs): """Turn the entity on.""" - self._is_on = True states = [pypck.lcn_defs.RelayStateModifier.NOCHANGE] * 8 states[self.output.value] = pypck.lcn_defs.RelayStateModifier.ON - self.address_connection.control_relays(states) - + if not await self.address_connection.control_relays(states): + return + self._is_on = True self.async_write_ha_state() async def async_turn_off(self, **kwargs): """Turn the entity off.""" - self._is_on = False states = [pypck.lcn_defs.RelayStateModifier.NOCHANGE] * 8 states[self.output.value] = pypck.lcn_defs.RelayStateModifier.OFF - self.address_connection.control_relays(states) - + if not await self.address_connection.control_relays(states): + return + self._is_on = False self.async_write_ha_state() def input_received(self, input_obj): diff --git a/homeassistant/components/lcn/manifest.json b/homeassistant/components/lcn/manifest.json index dca4436d5c2..6811e086ecc 100644 --- a/homeassistant/components/lcn/manifest.json +++ b/homeassistant/components/lcn/manifest.json @@ -2,6 +2,6 @@ "domain": "lcn", "name": "LCN", "documentation": "https://www.home-assistant.io/integrations/lcn", - "requirements": ["pypck==0.7.4"], + "requirements": ["pypck==0.7.6"], "codeowners": ["@alengwenus"] } diff --git a/homeassistant/components/lcn/scene.py b/homeassistant/components/lcn/scene.py index 0bad1b87efe..cac13ee1653 100644 --- a/homeassistant/components/lcn/scene.py +++ b/homeassistant/components/lcn/scene.py @@ -18,6 +18,8 @@ from .const import ( ) from .helpers import get_connection +PARALLEL_UPDATES = 0 + async def async_setup_platform( hass, hass_config, async_add_entities, discovery_info=None @@ -67,7 +69,7 @@ class LcnScene(LcnDevice, Scene): async def async_activate(self, **kwargs: Any) -> None: """Activate scene.""" - self.address_connection.activate_scene( + await self.address_connection.activate_scene( self.register_id, self.scene_id, self.output_ports, diff --git a/homeassistant/components/lcn/switch.py b/homeassistant/components/lcn/switch.py index e441ce40383..1d6f7cb6df4 100644 --- a/homeassistant/components/lcn/switch.py +++ b/homeassistant/components/lcn/switch.py @@ -8,6 +8,8 @@ from . import LcnDevice from .const import CONF_CONNECTIONS, CONF_OUTPUT, DATA_LCN, OUTPUT_PORTS from .helpers import get_connection +PARALLEL_UPDATES = 0 + async def async_setup_platform( hass, hass_config, async_add_entities, discovery_info=None @@ -57,14 +59,16 @@ class LcnOutputSwitch(LcnDevice, SwitchEntity): async def async_turn_on(self, **kwargs): """Turn the entity on.""" + if not await self.address_connection.dim_output(self.output.value, 100, 0): + return self._is_on = True - self.address_connection.dim_output(self.output.value, 100, 0) self.async_write_ha_state() async def async_turn_off(self, **kwargs): """Turn the entity off.""" + if not await self.address_connection.dim_output(self.output.value, 0, 0): + return self._is_on = False - self.address_connection.dim_output(self.output.value, 0, 0) self.async_write_ha_state() def input_received(self, input_obj): @@ -102,20 +106,21 @@ class LcnRelaySwitch(LcnDevice, SwitchEntity): async def async_turn_on(self, **kwargs): """Turn the entity on.""" - self._is_on = True - states = [pypck.lcn_defs.RelayStateModifier.NOCHANGE] * 8 states[self.output.value] = pypck.lcn_defs.RelayStateModifier.ON - self.address_connection.control_relays(states) + if not await self.address_connection.control_relays(states): + return + self._is_on = True self.async_write_ha_state() async def async_turn_off(self, **kwargs): """Turn the entity off.""" - self._is_on = False states = [pypck.lcn_defs.RelayStateModifier.NOCHANGE] * 8 states[self.output.value] = pypck.lcn_defs.RelayStateModifier.OFF - self.address_connection.control_relays(states) + if not await self.address_connection.control_relays(states): + return + self._is_on = False self.async_write_ha_state() def input_received(self, input_obj): diff --git a/requirements_all.txt b/requirements_all.txt index 4cbbc82748b..02a5fe91dc5 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1607,7 +1607,7 @@ pyownet==0.10.0.post1 pypca==0.0.7 # homeassistant.components.lcn -pypck==0.7.4 +pypck==0.7.6 # homeassistant.components.pjlink pypjlink2==1.2.1