mirror of
https://github.com/home-assistant/core.git
synced 2025-12-20 02:48:57 +00:00
Drop supports_action in Tuya alarm_control_panel wrapper (#159118)
This commit is contained in:
@@ -96,18 +96,19 @@ class _AlarmActionWrapper(DPCodeEnumWrapper):
|
|||||||
"trigger": "sos",
|
"trigger": "sos",
|
||||||
}
|
}
|
||||||
|
|
||||||
def supports_action(self, action: str) -> bool:
|
def __init__(self, dpcode: str, type_information: EnumTypeInformation) -> None:
|
||||||
"""Return if action is supported."""
|
"""Init _AlarmActionWrapper."""
|
||||||
return (
|
super().__init__(dpcode, type_information)
|
||||||
mapped_value := self._ACTION_MAPPINGS.get(action)
|
self.options = [
|
||||||
) is not None and mapped_value in self.options
|
ha_action
|
||||||
|
for ha_action, tuya_action in self._ACTION_MAPPINGS.items()
|
||||||
|
if tuya_action in type_information.range
|
||||||
|
]
|
||||||
|
|
||||||
def _convert_value_to_raw_value(self, device: CustomerDevice, value: Any) -> Any:
|
def _convert_value_to_raw_value(self, device: CustomerDevice, value: Any) -> Any:
|
||||||
"""Convert value to raw value."""
|
"""Convert value to raw value."""
|
||||||
if (
|
if value in self.options:
|
||||||
mapped_value := self._ACTION_MAPPINGS.get(value)
|
return self._ACTION_MAPPINGS[value]
|
||||||
) is not None and mapped_value in self.options:
|
|
||||||
return mapped_value
|
|
||||||
raise ValueError(f"Unsupported value {value} for {self.dpcode}")
|
raise ValueError(f"Unsupported value {value} for {self.dpcode}")
|
||||||
|
|
||||||
|
|
||||||
@@ -182,12 +183,13 @@ class TuyaAlarmEntity(TuyaEntity, AlarmControlPanelEntity):
|
|||||||
self._state_wrapper = state_wrapper
|
self._state_wrapper = state_wrapper
|
||||||
|
|
||||||
# Determine supported modes
|
# Determine supported modes
|
||||||
if action_wrapper.supports_action("arm_home"):
|
if action_wrapper.options:
|
||||||
self._attr_supported_features |= AlarmControlPanelEntityFeature.ARM_HOME
|
if "arm_home" in action_wrapper.options:
|
||||||
if action_wrapper.supports_action("arm_away"):
|
self._attr_supported_features |= AlarmControlPanelEntityFeature.ARM_HOME
|
||||||
self._attr_supported_features |= AlarmControlPanelEntityFeature.ARM_AWAY
|
if "arm_away" in action_wrapper.options:
|
||||||
if action_wrapper.supports_action("trigger"):
|
self._attr_supported_features |= AlarmControlPanelEntityFeature.ARM_AWAY
|
||||||
self._attr_supported_features |= AlarmControlPanelEntityFeature.TRIGGER
|
if "trigger" in action_wrapper.options:
|
||||||
|
self._attr_supported_features |= AlarmControlPanelEntityFeature.TRIGGER
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def alarm_state(self) -> AlarmControlPanelState | None:
|
def alarm_state(self) -> AlarmControlPanelState | None:
|
||||||
|
|||||||
Reference in New Issue
Block a user