Fix mqtt cover state is open after receiving stopped payload (#104726)

This commit is contained in:
Jan Bouwhuis 2023-11-29 16:29:42 +01:00 committed by GitHub
parent 4628b03677
commit 82264a0d6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -380,7 +380,11 @@ class MqttCover(MqttEntity, CoverEntity):
else STATE_OPEN
)
else:
state = STATE_CLOSED if self.state == STATE_CLOSING else STATE_OPEN
state = (
STATE_CLOSED
if self.state in [STATE_CLOSED, STATE_CLOSING]
else STATE_OPEN
)
elif payload == self._config[CONF_STATE_OPENING]:
state = STATE_OPENING
elif payload == self._config[CONF_STATE_CLOSING]:

View File

@ -3347,6 +3347,11 @@ async def test_set_state_via_stopped_state_no_position_topic(
state = hass.states.get("cover.test")
assert state.state == STATE_CLOSED
async_fire_mqtt_message(hass, "state-topic", "STOPPED")
state = hass.states.get("cover.test")
assert state.state == STATE_CLOSED
@pytest.mark.parametrize(
"hass_config",