mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Fix LCN cover behavior when using output ports (#37034)
* Fixed LCN cover behavior when connected to output ports * Cover is assumed to be in an open state unless it is fully closed.
This commit is contained in:
parent
02adcc532f
commit
4a65bed0eb
@ -49,9 +49,10 @@ class LcnOutputsCover(LcnDevice, CoverEntity):
|
|||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
self.reverse_time = None
|
self.reverse_time = None
|
||||||
self._closed = None
|
|
||||||
self.state_up = False
|
self._is_closed = False
|
||||||
self.state_down = False
|
self._is_closing = False
|
||||||
|
self._is_opening = False
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Run when entity about to be added to hass."""
|
"""Run when entity about to be added to hass."""
|
||||||
@ -66,26 +67,44 @@ class LcnOutputsCover(LcnDevice, CoverEntity):
|
|||||||
@property
|
@property
|
||||||
def is_closed(self):
|
def is_closed(self):
|
||||||
"""Return if the cover is closed."""
|
"""Return if the cover is closed."""
|
||||||
return self._closed
|
return self._is_closed
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_opening(self):
|
||||||
|
"""Return if the cover is opening or not."""
|
||||||
|
return self._is_opening
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_closing(self):
|
||||||
|
"""Return if the cover is closing or not."""
|
||||||
|
return self._is_closing
|
||||||
|
|
||||||
|
@property
|
||||||
|
def assumed_state(self):
|
||||||
|
"""Return True if unable to access real state of the entity."""
|
||||||
|
return True
|
||||||
|
|
||||||
async def async_close_cover(self, **kwargs):
|
async def async_close_cover(self, **kwargs):
|
||||||
"""Close the cover."""
|
"""Close the cover."""
|
||||||
self._closed = True
|
self._is_opening = False
|
||||||
|
self._is_closing = True
|
||||||
state = pypck.lcn_defs.MotorStateModifier.DOWN
|
state = pypck.lcn_defs.MotorStateModifier.DOWN
|
||||||
self.address_connection.control_motors_outputs(state)
|
self.address_connection.control_motors_outputs(state)
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
async def async_open_cover(self, **kwargs):
|
async def async_open_cover(self, **kwargs):
|
||||||
"""Open the cover."""
|
"""Open the cover."""
|
||||||
self._closed = False
|
self._is_closed = False
|
||||||
|
self._is_opening = True
|
||||||
|
self._is_closing = False
|
||||||
state = pypck.lcn_defs.MotorStateModifier.UP
|
state = pypck.lcn_defs.MotorStateModifier.UP
|
||||||
self.address_connection.control_motors_outputs(state, self.reverse_time)
|
self.address_connection.control_motors_outputs(state, self.reverse_time)
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
async def async_stop_cover(self, **kwargs):
|
async def async_stop_cover(self, **kwargs):
|
||||||
"""Stop the cover."""
|
"""Stop the cover."""
|
||||||
self._closed = None
|
self._is_closing = False
|
||||||
|
self._is_opening = False
|
||||||
state = pypck.lcn_defs.MotorStateModifier.STOP
|
state = pypck.lcn_defs.MotorStateModifier.STOP
|
||||||
self.address_connection.control_motors_outputs(state, self.reverse_time)
|
self.address_connection.control_motors_outputs(state, self.reverse_time)
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
@ -98,15 +117,19 @@ class LcnOutputsCover(LcnDevice, CoverEntity):
|
|||||||
):
|
):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if input_obj.get_percent() > 0: # motor is on
|
||||||
if input_obj.get_output_id() == self.output_ids[0]:
|
if input_obj.get_output_id() == self.output_ids[0]:
|
||||||
self.state_up = input_obj.get_percent() > 0
|
self._is_opening = True
|
||||||
|
self._is_closing = False
|
||||||
else: # self.output_ids[1]
|
else: # self.output_ids[1]
|
||||||
self.state_down = input_obj.get_percent() > 0
|
self._is_opening = False
|
||||||
|
self._is_closing = True
|
||||||
if self.state_up and not self.state_down:
|
self._is_closed = self._is_closing
|
||||||
self._closed = False # Cover open
|
else: # motor is off
|
||||||
elif self.state_down and not self.state_up:
|
# cover is assumed to be closed if we were in closing state before
|
||||||
self._closed = True # Cover closed
|
self._is_closed = self._is_closing
|
||||||
|
self._is_closing = False
|
||||||
|
self._is_opening = False
|
||||||
|
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
@ -153,7 +176,6 @@ class LcnRelayCover(LcnDevice, CoverEntity):
|
|||||||
|
|
||||||
async def async_close_cover(self, **kwargs):
|
async def async_close_cover(self, **kwargs):
|
||||||
"""Close the cover."""
|
"""Close the cover."""
|
||||||
self._is_closed = True
|
|
||||||
self._is_opening = False
|
self._is_opening = False
|
||||||
self._is_closing = True
|
self._is_closing = True
|
||||||
states = [pypck.lcn_defs.MotorStateModifier.NOCHANGE] * 4
|
states = [pypck.lcn_defs.MotorStateModifier.NOCHANGE] * 4
|
||||||
@ -173,8 +195,6 @@ class LcnRelayCover(LcnDevice, CoverEntity):
|
|||||||
|
|
||||||
async def async_stop_cover(self, **kwargs):
|
async def async_stop_cover(self, **kwargs):
|
||||||
"""Stop the cover."""
|
"""Stop the cover."""
|
||||||
if self._is_opening or self._is_closing:
|
|
||||||
self._is_closed = self._is_closing
|
|
||||||
self._is_closing = False
|
self._is_closing = False
|
||||||
self._is_opening = False
|
self._is_opening = False
|
||||||
states = [pypck.lcn_defs.MotorStateModifier.NOCHANGE] * 4
|
states = [pypck.lcn_defs.MotorStateModifier.NOCHANGE] * 4
|
||||||
@ -191,9 +211,9 @@ class LcnRelayCover(LcnDevice, CoverEntity):
|
|||||||
if states[self.motor_port_onoff]: # motor is on
|
if states[self.motor_port_onoff]: # motor is on
|
||||||
self._is_opening = not states[self.motor_port_updown] # set direction
|
self._is_opening = not states[self.motor_port_updown] # set direction
|
||||||
self._is_closing = states[self.motor_port_updown] # set direction
|
self._is_closing = states[self.motor_port_updown] # set direction
|
||||||
self._is_closed = self._is_closing
|
else: # motor is off
|
||||||
else:
|
|
||||||
self._is_opening = False
|
self._is_opening = False
|
||||||
self._is_closing = False
|
self._is_closing = False
|
||||||
|
self._is_closed = states[self.motor_port_updown]
|
||||||
|
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user