Fix Tuya cover open/close commands (#61369)

Co-authored-by: Franck Nijhof <frenck@frenck.nl>
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Yehuda Davis 2021-12-10 12:19:33 -05:00 committed by GitHub
parent f77c4485b6
commit e0cb7dad31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -315,11 +315,18 @@ class TuyaCoverEntity(TuyaEntity, CoverEntity):
{"code": self.entity_description.key, "value": value}
]
if (self.entity_description.set_position) is not None:
if (
self.entity_description.set_position is not None
and self._set_position_type is not None
):
commands.append(
{
"code": self.entity_description.set_position,
"value": 0,
"value": round(
self._set_position_type.remap_value_from(
100, 0, 100, reverse=True
),
),
}
)
@ -327,7 +334,7 @@ class TuyaCoverEntity(TuyaEntity, CoverEntity):
def close_cover(self, **kwargs: Any) -> None:
"""Close cover."""
value: bool | str = True
value: bool | str = False
if self.device.function[self.entity_description.key].type == "Enum":
value = "close"
@ -335,11 +342,18 @@ class TuyaCoverEntity(TuyaEntity, CoverEntity):
{"code": self.entity_description.key, "value": value}
]
if (self.entity_description.set_position) is not None:
if (
self.entity_description.set_position is not None
and self._set_position_type is not None
):
commands.append(
{
"code": self.entity_description.set_position,
"value": 100,
"value": round(
self._set_position_type.remap_value_from(
0, 0, 100, reverse=True
),
),
}
)