mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
Use the action field enums in unifiprotect (#194937)
This commit is contained in:
@@ -11,7 +11,7 @@ from uiprotect.data import (
|
||||
)
|
||||
from uiprotect.data.public_devices import PublicLight
|
||||
|
||||
from homeassistant.components.light import ATTR_BRIGHTNESS, ColorMode, LightEntity
|
||||
from homeassistant.components.light import ColorMode, LightEntity, LightServiceArgument
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
@@ -140,7 +140,7 @@ class ProtectLight(ProtectDeviceEntity, LightEntity):
|
||||
@override
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the light on."""
|
||||
brightness = kwargs.get(ATTR_BRIGHTNESS)
|
||||
brightness = kwargs.get(LightServiceArgument.BRIGHTNESS)
|
||||
led_level: int | None = None
|
||||
if brightness is not None:
|
||||
led_level = hass_to_unifi_brightness(brightness)
|
||||
|
||||
@@ -6,11 +6,10 @@ from typing import Any, cast, override
|
||||
from uiprotect.data import PublicDeviceModel, Siren, SirenDuration
|
||||
|
||||
from homeassistant.components.siren import (
|
||||
ATTR_DURATION,
|
||||
ATTR_VOLUME_LEVEL,
|
||||
SirenEntity,
|
||||
SirenEntityDescription,
|
||||
SirenEntityFeature,
|
||||
SirenServiceArgument,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
|
||||
@@ -101,8 +100,8 @@ class ProtectSiren(ProtectDeviceEntity, SirenEntity):
|
||||
translation_key="siren_not_available",
|
||||
)
|
||||
|
||||
duration: int | None = kwargs.get(ATTR_DURATION)
|
||||
volume_level: float | None = kwargs.get(ATTR_VOLUME_LEVEL)
|
||||
duration: int | None = kwargs.get(SirenServiceArgument.DURATION)
|
||||
volume_level: float | None = kwargs.get(SirenServiceArgument.VOLUME_LEVEL)
|
||||
|
||||
# Validate duration first (synchronous) before making any API calls.
|
||||
norm_duration: SirenDuration | None = None
|
||||
|
||||
Reference in New Issue
Block a user