mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
Use SirenEntityFeature enum in demo (#69649)
This commit is contained in:
parent
af57f9c6a4
commit
9eba1425e0
@ -3,20 +3,13 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.components.siren import SirenEntity
|
from homeassistant.components.siren import SirenEntity, SirenEntityFeature
|
||||||
from homeassistant.components.siren.const import (
|
|
||||||
SUPPORT_DURATION,
|
|
||||||
SUPPORT_TONES,
|
|
||||||
SUPPORT_TURN_OFF,
|
|
||||||
SUPPORT_TURN_ON,
|
|
||||||
SUPPORT_VOLUME_SET,
|
|
||||||
)
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
SUPPORT_FLAGS = SUPPORT_TURN_OFF | SUPPORT_TURN_ON
|
SUPPORT_FLAGS = SirenEntityFeature.TURN_OFF | SirenEntityFeature.TURN_ON
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
async def async_setup_platform(
|
||||||
@ -65,11 +58,11 @@ class DemoSiren(SirenEntity):
|
|||||||
self._attr_supported_features = SUPPORT_FLAGS
|
self._attr_supported_features = SUPPORT_FLAGS
|
||||||
self._attr_is_on = is_on
|
self._attr_is_on = is_on
|
||||||
if available_tones is not None:
|
if available_tones is not None:
|
||||||
self._attr_supported_features |= SUPPORT_TONES
|
self._attr_supported_features |= SirenEntityFeature.TONES
|
||||||
if support_volume_set:
|
if support_volume_set:
|
||||||
self._attr_supported_features |= SUPPORT_VOLUME_SET
|
self._attr_supported_features |= SirenEntityFeature.VOLUME_SET
|
||||||
if support_duration:
|
if support_duration:
|
||||||
self._attr_supported_features |= SUPPORT_DURATION
|
self._attr_supported_features |= SirenEntityFeature.DURATION
|
||||||
self._attr_available_tones = available_tones
|
self._attr_available_tones = available_tones
|
||||||
|
|
||||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user