Use SirenEntityFeature enum in demo (#69649)

This commit is contained in:
epenet 2022-04-08 09:30:15 +02:00 committed by GitHub
parent af57f9c6a4
commit 9eba1425e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,20 +3,13 @@ from __future__ import annotations
from typing import Any
from homeassistant.components.siren import SirenEntity
from homeassistant.components.siren.const import (
SUPPORT_DURATION,
SUPPORT_TONES,
SUPPORT_TURN_OFF,
SUPPORT_TURN_ON,
SUPPORT_VOLUME_SET,
)
from homeassistant.components.siren import SirenEntity, SirenEntityFeature
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
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(
@ -65,11 +58,11 @@ class DemoSiren(SirenEntity):
self._attr_supported_features = SUPPORT_FLAGS
self._attr_is_on = is_on
if available_tones is not None:
self._attr_supported_features |= SUPPORT_TONES
self._attr_supported_features |= SirenEntityFeature.TONES
if support_volume_set:
self._attr_supported_features |= SUPPORT_VOLUME_SET
self._attr_supported_features |= SirenEntityFeature.VOLUME_SET
if support_duration:
self._attr_supported_features |= SUPPORT_DURATION
self._attr_supported_features |= SirenEntityFeature.DURATION
self._attr_available_tones = available_tones
async def async_turn_on(self, **kwargs: Any) -> None: