mirror of
https://github.com/home-assistant/core.git
synced 2026-08-24 10:13:52 -05:00
Use state attribute enums in Dynalite (#175850)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
287b5743a6
commit
fe212883be
@@ -3,9 +3,9 @@
|
||||
from typing import Any, override
|
||||
|
||||
from homeassistant.components.cover import (
|
||||
ATTR_CURRENT_POSITION,
|
||||
CoverDeviceClass,
|
||||
CoverEntity,
|
||||
CoverEntityStateAttribute,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
@@ -89,7 +89,7 @@ class DynaliteCover(DynaliteBase, CoverEntity):
|
||||
@override
|
||||
def initialize_state(self, state):
|
||||
"""Initialize the state from cache."""
|
||||
target_level = state.attributes.get(ATTR_CURRENT_POSITION)
|
||||
target_level = state.attributes.get(CoverEntityStateAttribute.CURRENT_POSITION)
|
||||
if target_level is not None:
|
||||
self._device.init_level(target_level)
|
||||
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
|
||||
from typing import Any, override
|
||||
|
||||
from homeassistant.components.light import ATTR_BRIGHTNESS, ColorMode, LightEntity
|
||||
from homeassistant.components.light import (
|
||||
ColorMode,
|
||||
LightEntity,
|
||||
LightEntityStateAttribute,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
||||
@@ -52,6 +56,6 @@ class DynaliteLight(DynaliteBase, LightEntity):
|
||||
@override
|
||||
def initialize_state(self, state):
|
||||
"""Initialize the state from cache."""
|
||||
target_level = state.attributes.get(ATTR_BRIGHTNESS)
|
||||
target_level = state.attributes.get(LightEntityStateAttribute.BRIGHTNESS)
|
||||
if target_level is not None:
|
||||
self._device.init_level(target_level)
|
||||
|
||||
Reference in New Issue
Block a user