Changed checking of cover state closed from 0 to closed_position variable. (#18407)

Change error message to avoid expression "get_position_topic".
This commit is contained in:
Pawel 2018-11-12 20:46:00 +01:00 committed by Diogo Gomes
parent 275b485b36
commit d0463942be

View file

@ -87,7 +87,7 @@ def validate_options(value):
if (CONF_SET_POSITION_TOPIC in value and
CONF_GET_POSITION_TOPIC not in value):
raise vol.Invalid(
"Set position topic must be set together with get position topic.")
"set_position_topic must be set together with position_topic.")
return value
@ -287,7 +287,7 @@ class MqttCover(MqttAvailability, MqttDiscoveryUpdate, MqttEntityDeviceInfo,
float(payload), COVER_PAYLOAD)
if 0 <= percentage_payload <= 100:
self._position = percentage_payload
self._state = self._position == 0
self._state = self._position == self._position_closed
else:
_LOGGER.warning(
"Payload is not integer within range: %s",
@ -451,7 +451,7 @@ class MqttCover(MqttAvailability, MqttDiscoveryUpdate, MqttEntityDeviceInfo,
mqtt.async_publish(self.hass, self._set_position_topic,
position, self._qos, self._retain)
if self._optimistic:
self._state = percentage_position == 0
self._state = percentage_position == self._position_closed
self._position = percentage_position
self.async_schedule_update_ha_state()