Use entity name naming for Nanoleaf (#95741)

* Use device class naming for Nanoleaf

* Remove device class icon
This commit is contained in:
Joost Lekkerkerker 2023-07-23 04:59:56 +02:00 committed by GitHub
parent b90137f4c6
commit bf66dc7a91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View File

@ -2,7 +2,7 @@
from aionanoleaf import Nanoleaf
from homeassistant.components.button import ButtonEntity
from homeassistant.components.button import ButtonDeviceClass, ButtonEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import EntityCategory
from homeassistant.core import HomeAssistant
@ -27,15 +27,15 @@ async def async_setup_entry(
class NanoleafIdentifyButton(NanoleafEntity, ButtonEntity):
"""Representation of a Nanoleaf identify button."""
_attr_entity_category = EntityCategory.CONFIG
_attr_device_class = ButtonDeviceClass.IDENTIFY
def __init__(
self, nanoleaf: Nanoleaf, coordinator: DataUpdateCoordinator[None]
) -> None:
"""Initialize the Nanoleaf button."""
super().__init__(nanoleaf, coordinator)
self._attr_unique_id = f"{nanoleaf.serial_no}_identify"
self._attr_name = f"Identify {nanoleaf.name}"
self._attr_icon = "mdi:magnify"
self._attr_entity_category = EntityCategory.CONFIG
async def async_press(self) -> None:
"""Identify the Nanoleaf."""

View File

@ -14,10 +14,12 @@ from .const import DOMAIN
class NanoleafEntity(CoordinatorEntity[DataUpdateCoordinator[None]]):
"""Representation of a Nanoleaf entity."""
_attr_has_entity_name = True
def __init__(
self, nanoleaf: Nanoleaf, coordinator: DataUpdateCoordinator[None]
) -> None:
"""Initialize an Nanoleaf entity."""
"""Initialize a Nanoleaf entity."""
super().__init__(coordinator)
self._nanoleaf = nanoleaf
self._attr_device_info = DeviceInfo(

View File

@ -46,6 +46,7 @@ class NanoleafLight(NanoleafEntity, LightEntity):
_attr_supported_color_modes = {ColorMode.COLOR_TEMP, ColorMode.HS}
_attr_supported_features = LightEntityFeature.EFFECT | LightEntityFeature.TRANSITION
_attr_name = None
def __init__(
self, nanoleaf: Nanoleaf, coordinator: DataUpdateCoordinator[None]
@ -53,7 +54,6 @@ class NanoleafLight(NanoleafEntity, LightEntity):
"""Initialize the Nanoleaf light."""
super().__init__(nanoleaf, coordinator)
self._attr_unique_id = nanoleaf.serial_no
self._attr_name = nanoleaf.name
self._attr_min_mireds = math.ceil(1000000 / nanoleaf.color_temperature_max)
self._attr_max_mireds = kelvin_to_mired(nanoleaf.color_temperature_min)