Use state attribute enums in Dynalite (#175850)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
epenet
2026-07-07 14:50:40 +02:00
committed by GitHub
co-authored by Claude Opus 4.8
parent 287b5743a6
commit fe212883be
2 changed files with 8 additions and 4 deletions
+2 -2
View File
@@ -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)
+6 -2
View File
@@ -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)