Bump pypck to v0.7.6 (#43710)

* Bump pypck to v0.7.6

* Await commands to ensure that they are received.
This commit is contained in:
Andre Lengwenus 2020-11-29 16:30:17 +01:00 committed by GitHub
parent 5462d6e798
commit 493eaef616
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 79 additions and 45 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -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"]
}

View File

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

View File

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

View File

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