Add "power on state" config entity for Tuya plugs to ZHA (#80486)
* Add "power on state" config entity for Tuya plugs to ZHA * Remove TS004F from models, as it doesn't support power-on-state
This commit is contained in:
parent
e38d93ee93
commit
f4f7122c66
2 changed files with 33 additions and 0 deletions
|
@ -331,6 +331,19 @@ class OnOffChannel(ZigbeeChannel):
|
||||||
super().__init__(cluster, ch_pool)
|
super().__init__(cluster, ch_pool)
|
||||||
self._off_listener = None
|
self._off_listener = None
|
||||||
|
|
||||||
|
if self.cluster.endpoint.model in (
|
||||||
|
"TS011F",
|
||||||
|
"TS0121",
|
||||||
|
"TS0001",
|
||||||
|
"TS0002",
|
||||||
|
"TS0003",
|
||||||
|
"TS0004",
|
||||||
|
):
|
||||||
|
self.ZCL_INIT_ATTRS = ( # pylint: disable=invalid-name
|
||||||
|
self.ZCL_INIT_ATTRS.copy()
|
||||||
|
)
|
||||||
|
self.ZCL_INIT_ATTRS["power_on_state"] = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def on_off(self) -> bool | None:
|
def on_off(self) -> bool | None:
|
||||||
"""Return cached value of on/off attribute."""
|
"""Return cached value of on/off attribute."""
|
||||||
|
|
|
@ -227,6 +227,26 @@ class ZHAStartupOnOffSelectEntity(
|
||||||
_attr_name = "Start-up behavior"
|
_attr_name = "Start-up behavior"
|
||||||
|
|
||||||
|
|
||||||
|
class TuyaPowerOnState(types.enum8):
|
||||||
|
"""Tuya power on state enum."""
|
||||||
|
|
||||||
|
Off = 0x00
|
||||||
|
On = 0x01
|
||||||
|
LastState = 0x02
|
||||||
|
|
||||||
|
|
||||||
|
@CONFIG_DIAGNOSTIC_MATCH(
|
||||||
|
channel_names=CHANNEL_ON_OFF,
|
||||||
|
models={"TS011F", "TS0121", "TS0001", "TS0002", "TS0003", "TS0004"},
|
||||||
|
)
|
||||||
|
class TuyaPowerOnStateSelectEntity(ZCLEnumSelectEntity, id_suffix="power_on_state"):
|
||||||
|
"""Representation of a ZHA power on state select entity."""
|
||||||
|
|
||||||
|
_select_attr = "power_on_state"
|
||||||
|
_enum = TuyaPowerOnState
|
||||||
|
_attr_name = "Power on state"
|
||||||
|
|
||||||
|
|
||||||
class AqaraMotionSensitivities(types.enum8):
|
class AqaraMotionSensitivities(types.enum8):
|
||||||
"""Aqara motion sensitivities."""
|
"""Aqara motion sensitivities."""
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue