1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Deal with cover assumed state (#22673)

* Deal with cover assumed state

* Add docs
This commit is contained in:
Paulus Schoutsen
2019-04-03 04:53:44 -07:00
committed by Pascal Vizeli
parent 7066fb0d10
commit b1cca25299
2 changed files with 34 additions and 6 deletions

View File

@@ -27,6 +27,7 @@ from homeassistant.const import (
TEMP_FAHRENHEIT,
ATTR_SUPPORTED_FEATURES,
ATTR_TEMPERATURE,
ATTR_ASSUMED_STATE,
)
from homeassistant.core import DOMAIN as HA_DOMAIN
from homeassistant.util import color as color_util, temperature as temp_util
@@ -1055,11 +1056,19 @@ class OpenCloseTrait(_Trait):
response = {}
if domain == cover.DOMAIN:
position = self.state.attributes.get(cover.ATTR_CURRENT_POSITION)
if position is not None:
response['openPercent'] = position
# When it's an assumed state, we will always report it as 50%
# Google will not issue an open command if the assumed state is
# open, even if that is currently incorrect.
if self.state.attributes.get(ATTR_ASSUMED_STATE):
response['openPercent'] = 50
else:
if self.state.state != cover.STATE_CLOSED:
position = self.state.attributes.get(
cover.ATTR_CURRENT_POSITION
)
if position is not None:
response['openPercent'] = position
elif self.state.state != cover.STATE_CLOSED:
response['openPercent'] = 100
else:
response['openPercent'] = 0