Fix inverted tuya doorcontact_state (#59427)
This commit is contained in:
parent
b2f2c76e5a
commit
b5de99ebfc
2 changed files with 9 additions and 3 deletions
|
@ -190,7 +190,7 @@ class DPCode(str, Enum):
|
||||||
DEHUMIDITY_SET_VALUE = "dehumidify_set_value"
|
DEHUMIDITY_SET_VALUE = "dehumidify_set_value"
|
||||||
DO_NOT_DISTURB = "do_not_disturb"
|
DO_NOT_DISTURB = "do_not_disturb"
|
||||||
DOORCONTACT_STATE = "doorcontact_state" # Status of door window sensor
|
DOORCONTACT_STATE = "doorcontact_state" # Status of door window sensor
|
||||||
DOORCONTACT_STATE_2 = "doorcontact_state_3"
|
DOORCONTACT_STATE_2 = "doorcontact_state_2"
|
||||||
DOORCONTACT_STATE_3 = "doorcontact_state_3"
|
DOORCONTACT_STATE_3 = "doorcontact_state_3"
|
||||||
ELECTRICITY_LEFT = "electricity_left"
|
ELECTRICITY_LEFT = "electricity_left"
|
||||||
FAN_DIRECTION = "fan_direction" # Fan direction
|
FAN_DIRECTION = "fan_direction" # Fan direction
|
||||||
|
|
|
@ -36,6 +36,7 @@ class TuyaCoverEntityDescription(CoverEntityDescription):
|
||||||
"""Describe an Tuya cover entity."""
|
"""Describe an Tuya cover entity."""
|
||||||
|
|
||||||
current_state: DPCode | None = None
|
current_state: DPCode | None = None
|
||||||
|
current_state_inverse: bool = False
|
||||||
current_position: DPCode | None = None
|
current_position: DPCode | None = None
|
||||||
set_position: DPCode | None = None
|
set_position: DPCode | None = None
|
||||||
|
|
||||||
|
@ -75,18 +76,21 @@ COVERS: dict[str, tuple[TuyaCoverEntityDescription, ...]] = {
|
||||||
key=DPCode.SWITCH_1,
|
key=DPCode.SWITCH_1,
|
||||||
name="Door",
|
name="Door",
|
||||||
current_state=DPCode.DOORCONTACT_STATE,
|
current_state=DPCode.DOORCONTACT_STATE,
|
||||||
|
current_state_inverse=True,
|
||||||
device_class=DEVICE_CLASS_GARAGE,
|
device_class=DEVICE_CLASS_GARAGE,
|
||||||
),
|
),
|
||||||
TuyaCoverEntityDescription(
|
TuyaCoverEntityDescription(
|
||||||
key=DPCode.SWITCH_2,
|
key=DPCode.SWITCH_2,
|
||||||
name="Door 2",
|
name="Door 2",
|
||||||
current_state=DPCode.DOORCONTACT_STATE_2,
|
current_state=DPCode.DOORCONTACT_STATE_2,
|
||||||
|
current_state_inverse=True,
|
||||||
device_class=DEVICE_CLASS_GARAGE,
|
device_class=DEVICE_CLASS_GARAGE,
|
||||||
),
|
),
|
||||||
TuyaCoverEntityDescription(
|
TuyaCoverEntityDescription(
|
||||||
key=DPCode.SWITCH_3,
|
key=DPCode.SWITCH_3,
|
||||||
name="Door 3",
|
name="Door 3",
|
||||||
current_state=DPCode.DOORCONTACT_STATE_3,
|
current_state=DPCode.DOORCONTACT_STATE_3,
|
||||||
|
current_state_inverse=True,
|
||||||
device_class=DEVICE_CLASS_GARAGE,
|
device_class=DEVICE_CLASS_GARAGE,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -262,7 +266,7 @@ class TuyaCoverEntity(TuyaEntity, CoverEntity):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_closed(self) -> bool | None:
|
def is_closed(self) -> bool | None:
|
||||||
"""Return is cover is closed."""
|
"""Return true if cover is closed."""
|
||||||
if (
|
if (
|
||||||
self.entity_description.current_state is not None
|
self.entity_description.current_state is not None
|
||||||
and (
|
and (
|
||||||
|
@ -272,7 +276,9 @@ class TuyaCoverEntity(TuyaEntity, CoverEntity):
|
||||||
)
|
)
|
||||||
is not None
|
is not None
|
||||||
):
|
):
|
||||||
return current_state in (True, "fully_close")
|
return self.entity_description.current_state_inverse is not (
|
||||||
|
current_state in (False, "fully_close")
|
||||||
|
)
|
||||||
|
|
||||||
if (position := self.current_cover_position) is not None:
|
if (position := self.current_cover_position) is not None:
|
||||||
return position == 0
|
return position == 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue