Enforce AlarmControlPanelEntityFeature (#82313)

This commit is contained in:
epenet 2022-11-21 22:58:36 +01:00 committed by GitHub
parent b3dd59f202
commit cec81e137c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View file

@ -133,7 +133,9 @@ class AlarmControlPanelEntity(Entity):
_attr_changed_by: str | None = None
_attr_code_arm_required: bool = True
_attr_code_format: CodeFormat | None = None
_attr_supported_features: AlarmControlPanelEntityFeature | int = 0
_attr_supported_features: AlarmControlPanelEntityFeature = (
AlarmControlPanelEntityFeature(0)
)
@property
def code_format(self) -> CodeFormat | None:
@ -207,7 +209,7 @@ class AlarmControlPanelEntity(Entity):
await self.hass.async_add_executor_job(self.alarm_arm_custom_bypass, code)
@property
def supported_features(self) -> AlarmControlPanelEntityFeature | int:
def supported_features(self) -> AlarmControlPanelEntityFeature:
"""Return the list of supported features."""
return self._attr_supported_features

View file

@ -189,9 +189,9 @@ class AlarmControlPanelTemplate(TemplateEntity, AlarmControlPanelEntity):
return self._state
@property
def supported_features(self) -> int:
def supported_features(self) -> AlarmControlPanelEntityFeature:
"""Return the list of supported features."""
supported_features = 0
supported_features = AlarmControlPanelEntityFeature(0)
if self._arm_night_script is not None:
supported_features = (
supported_features | AlarmControlPanelEntityFeature.ARM_NIGHT

View file

@ -661,7 +661,7 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
),
TypeHintMatch(
function_name="supported_features",
return_type=["AlarmControlPanelEntityFeature", "int"],
return_type="AlarmControlPanelEntityFeature",
),
TypeHintMatch(
function_name="alarm_disarm",