Add device and enable entity name for Lutron homeworks (#112268)

This commit is contained in:
Erik Montnemery 2024-03-04 19:50:49 +01:00 committed by GitHub
parent 68141873cd
commit 32964a2e90
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View File

@ -166,6 +166,7 @@ def calculate_unique_id(controller_id: str, addr: str, idx: int) -> str:
class HomeworksEntity(Entity): class HomeworksEntity(Entity):
"""Base class of a Homeworks device.""" """Base class of a Homeworks device."""
_attr_has_entity_name = True
_attr_should_poll = False _attr_should_poll = False
def __init__( def __init__(

View File

@ -10,6 +10,7 @@ from homeassistant.components.light import ATTR_BRIGHTNESS, ColorMode, LightEnti
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_NAME from homeassistant.const import CONF_NAME
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -54,7 +55,10 @@ class HomeworksLight(HomeworksEntity, LightEntity):
rate: float, rate: float,
) -> None: ) -> None:
"""Create device with Addr, name, and rate.""" """Create device with Addr, name, and rate."""
super().__init__(controller, controller_id, addr, 0, name) super().__init__(controller, controller_id, addr, 0, None)
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, f"{controller_id}.{addr}")}, name=name
)
self._rate = rate self._rate = rate
self._level = 0 self._level = 0
self._prev_level = 0 self._prev_level = 0