Use config entry title for Avea light (#170978)

This commit is contained in:
Sören
2026-05-18 12:26:09 +02:00
committed by GitHub
parent e9f9194b7b
commit aa8904b0cd
2 changed files with 7 additions and 6 deletions
+5 -3
View File
@@ -84,7 +84,9 @@ async def async_setup_entry(
async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
"""Set up the Avea light platform."""
async_add_entities([AveaLight(entry.runtime_data)], update_before_add=True)
async_add_entities(
[AveaLight(entry.runtime_data, entry.title)], update_before_add=True
)
def _discover_bulbs_for_import() -> list[dict[str, str]]:
@@ -169,10 +171,10 @@ class AveaLight(LightEntity):
_attr_color_mode = ColorMode.HS
_attr_supported_color_modes = {ColorMode.HS}
def __init__(self, light: avea.Bulb) -> None:
def __init__(self, light: avea.Bulb, entry_title: str) -> None:
"""Initialize an AveaLight."""
self._light = light
self._attr_name = light.name
self._attr_name = entry_title
self._attr_brightness = light.brightness
def turn_on(self, **kwargs: Any) -> None:
+2 -3
View File
@@ -15,7 +15,6 @@ from homeassistant.components.light import (
)
from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, STATE_ON
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import AVEA_DISCOVERY_INFO
@@ -26,7 +25,7 @@ from tests.common import MockConfigEntry, async_fire_time_changed
def mock_bulb() -> MagicMock:
"""Return a mocked Avea bulb."""
bulb = MagicMock()
bulb.name = "Bedroom"
bulb.name = "Unknown"
bulb.brightness = 0
bulb.get_brightness.return_value = 0
return bulb
@@ -54,13 +53,13 @@ async def setup_integration(
async def test_init_state(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
setup_integration: MagicMock,
) -> None:
"""Test the initial state."""
state = hass.states.get("light.bedroom")
assert state is not None
assert state.state == STATE_OFF
assert state.name == "Bedroom"
assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.HS]