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:
parent
f77c4485b6
commit
e0cb7dad31
1 changed files with 19 additions and 5 deletions
|
@ -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
|
||||
),
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue