Fix initial tilt value of MQTT cover (#73308)

This commit is contained in:
Erik Montnemery 2022-06-10 11:11:40 +02:00 committed by GitHub
parent 06ebc1fa14
commit 3d78240cee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 8 deletions

View File

@ -25,7 +25,6 @@ from homeassistant.const import (
STATE_CLOSING, STATE_CLOSING,
STATE_OPEN, STATE_OPEN,
STATE_OPENING, STATE_OPENING,
STATE_UNKNOWN,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -470,7 +469,6 @@ class MqttCover(MqttEntity, CoverEntity):
} }
if self._config.get(CONF_TILT_STATUS_TOPIC) is not None: if self._config.get(CONF_TILT_STATUS_TOPIC) is not None:
self._tilt_value = STATE_UNKNOWN
topics["tilt_status_topic"] = { topics["tilt_status_topic"] = {
"topic": self._config.get(CONF_TILT_STATUS_TOPIC), "topic": self._config.get(CONF_TILT_STATUS_TOPIC),
"msg_callback": tilt_message_received, "msg_callback": tilt_message_received,

View File

@ -1256,12 +1256,8 @@ async def test_tilt_defaults(hass, mqtt_mock_entry_with_yaml_config):
await mqtt_mock_entry_with_yaml_config() await mqtt_mock_entry_with_yaml_config()
state_attributes_dict = hass.states.get("cover.test").attributes state_attributes_dict = hass.states.get("cover.test").attributes
assert ATTR_CURRENT_TILT_POSITION in state_attributes_dict # Tilt position is not yet known
assert ATTR_CURRENT_TILT_POSITION not in state_attributes_dict
current_cover_position = hass.states.get("cover.test").attributes[
ATTR_CURRENT_TILT_POSITION
]
assert current_cover_position == STATE_UNKNOWN
async def test_tilt_via_invocation_defaults(hass, mqtt_mock_entry_with_yaml_config): async def test_tilt_via_invocation_defaults(hass, mqtt_mock_entry_with_yaml_config):