From f15d3fc5dba45e4e503d7cd17e30f6f29a5329b0 Mon Sep 17 00:00:00 2001
From: Franck Nijhof <git@frenck.dev>
Date: Sun, 10 Jul 2022 23:56:48 +0200
Subject: [PATCH] Migrate WLED to new entity naming style (#74860)

---
 homeassistant/components/wled/binary_sensor.py |  2 +-
 homeassistant/components/wled/button.py        |  2 +-
 homeassistant/components/wled/light.py         |  7 +++----
 homeassistant/components/wled/models.py        |  2 ++
 homeassistant/components/wled/number.py        |  7 ++-----
 homeassistant/components/wled/select.py        | 14 ++++++--------
 homeassistant/components/wled/sensor.py        | 13 ++++++-------
 homeassistant/components/wled/switch.py        | 12 ++++++------
 homeassistant/components/wled/update.py        |  2 +-
 9 files changed, 28 insertions(+), 33 deletions(-)

diff --git a/homeassistant/components/wled/binary_sensor.py b/homeassistant/components/wled/binary_sensor.py
index d2262798d50..61f8dc45f7b 100644
--- a/homeassistant/components/wled/binary_sensor.py
+++ b/homeassistant/components/wled/binary_sensor.py
@@ -34,6 +34,7 @@ class WLEDUpdateBinarySensor(WLEDEntity, BinarySensorEntity):
 
     _attr_entity_category = EntityCategory.DIAGNOSTIC
     _attr_device_class = BinarySensorDeviceClass.UPDATE
+    _attr_name = "Firmware"
 
     # Disabled by default, as this entity is deprecated.
     _attr_entity_registry_enabled_default = False
@@ -41,7 +42,6 @@ class WLEDUpdateBinarySensor(WLEDEntity, BinarySensorEntity):
     def __init__(self, coordinator: WLEDDataUpdateCoordinator) -> None:
         """Initialize the button entity."""
         super().__init__(coordinator=coordinator)
-        self._attr_name = f"{coordinator.data.info.name} Firmware"
         self._attr_unique_id = f"{coordinator.data.info.mac_address}_update"
 
     @property
diff --git a/homeassistant/components/wled/button.py b/homeassistant/components/wled/button.py
index 97877053163..b08ee396c70 100644
--- a/homeassistant/components/wled/button.py
+++ b/homeassistant/components/wled/button.py
@@ -28,11 +28,11 @@ class WLEDRestartButton(WLEDEntity, ButtonEntity):
 
     _attr_device_class = ButtonDeviceClass.RESTART
     _attr_entity_category = EntityCategory.CONFIG
+    _attr_name = "Restart"
 
     def __init__(self, coordinator: WLEDDataUpdateCoordinator) -> None:
         """Initialize the button entity."""
         super().__init__(coordinator=coordinator)
-        self._attr_name = f"{coordinator.data.info.name} Restart"
         self._attr_unique_id = f"{coordinator.data.info.mac_address}_restart"
 
     @wled_exception_handler
diff --git a/homeassistant/components/wled/light.py b/homeassistant/components/wled/light.py
index 4f5c758dfff..98be359628e 100644
--- a/homeassistant/components/wled/light.py
+++ b/homeassistant/components/wled/light.py
@@ -52,13 +52,13 @@ class WLEDMasterLight(WLEDEntity, LightEntity):
 
     _attr_color_mode = ColorMode.BRIGHTNESS
     _attr_icon = "mdi:led-strip-variant"
+    _attr_name = "Master"
     _attr_supported_features = LightEntityFeature.TRANSITION
     _attr_supported_color_modes = {ColorMode.BRIGHTNESS}
 
     def __init__(self, coordinator: WLEDDataUpdateCoordinator) -> None:
         """Initialize WLED master light."""
         super().__init__(coordinator=coordinator)
-        self._attr_name = f"{coordinator.data.info.name} Master"
         self._attr_unique_id = coordinator.data.info.mac_address
 
     @property
@@ -118,9 +118,8 @@ class WLEDSegmentLight(WLEDEntity, LightEntity):
 
         # Segment 0 uses a simpler name, which is more natural for when using
         # a single segment / using WLED with one big LED strip.
-        self._attr_name = f"{coordinator.data.info.name} Segment {segment}"
-        if segment == 0:
-            self._attr_name = coordinator.data.info.name
+        if segment != 0:
+            self._attr_name = f"Segment {segment}"
 
         self._attr_unique_id = (
             f"{self.coordinator.data.info.mac_address}_{self._segment}"
diff --git a/homeassistant/components/wled/models.py b/homeassistant/components/wled/models.py
index b5fc0855e04..2bdd2e46e2c 100644
--- a/homeassistant/components/wled/models.py
+++ b/homeassistant/components/wled/models.py
@@ -10,6 +10,8 @@ from .coordinator import WLEDDataUpdateCoordinator
 class WLEDEntity(CoordinatorEntity[WLEDDataUpdateCoordinator]):
     """Defines a base WLED entity."""
 
+    _attr_has_entity_name = True
+
     @property
     def device_info(self) -> DeviceInfo:
         """Return device information about this WLED device."""
diff --git a/homeassistant/components/wled/number.py b/homeassistant/components/wled/number.py
index 6c426cc44c5..d6032791e5b 100644
--- a/homeassistant/components/wled/number.py
+++ b/homeassistant/components/wled/number.py
@@ -71,11 +71,8 @@ class WLEDNumber(WLEDEntity, NumberEntity):
 
         # Segment 0 uses a simpler name, which is more natural for when using
         # a single segment / using WLED with one big LED strip.
-        self._attr_name = (
-            f"{coordinator.data.info.name} Segment {segment} {description.name}"
-        )
-        if segment == 0:
-            self._attr_name = f"{coordinator.data.info.name} {description.name}"
+        if segment != 0:
+            self._attr_name = f"Segment {segment} {description.name}"
 
         self._attr_unique_id = (
             f"{coordinator.data.info.mac_address}_{description.key}_{segment}"
diff --git a/homeassistant/components/wled/select.py b/homeassistant/components/wled/select.py
index e555b3422ce..c3980f9f9c7 100644
--- a/homeassistant/components/wled/select.py
+++ b/homeassistant/components/wled/select.py
@@ -51,12 +51,12 @@ class WLEDLiveOverrideSelect(WLEDEntity, SelectEntity):
     _attr_device_class = DEVICE_CLASS_WLED_LIVE_OVERRIDE
     _attr_entity_category = EntityCategory.CONFIG
     _attr_icon = "mdi:theater"
+    _attr_name = "Live override"
 
     def __init__(self, coordinator: WLEDDataUpdateCoordinator) -> None:
         """Initialize WLED ."""
         super().__init__(coordinator=coordinator)
 
-        self._attr_name = f"{coordinator.data.info.name} Live Override"
         self._attr_unique_id = f"{coordinator.data.info.mac_address}_live_override"
         self._attr_options = [str(live.value) for live in Live]
 
@@ -75,12 +75,12 @@ class WLEDPresetSelect(WLEDEntity, SelectEntity):
     """Defined a WLED Preset select."""
 
     _attr_icon = "mdi:playlist-play"
+    _attr_name = "Preset"
 
     def __init__(self, coordinator: WLEDDataUpdateCoordinator) -> None:
         """Initialize WLED ."""
         super().__init__(coordinator=coordinator)
 
-        self._attr_name = f"{coordinator.data.info.name} Preset"
         self._attr_unique_id = f"{coordinator.data.info.mac_address}_preset"
         self._attr_options = [preset.name for preset in self.coordinator.data.presets]
 
@@ -106,12 +106,12 @@ class WLEDPlaylistSelect(WLEDEntity, SelectEntity):
     """Define a WLED Playlist select."""
 
     _attr_icon = "mdi:play-speed"
+    _attr_name = "Playlist"
 
     def __init__(self, coordinator: WLEDDataUpdateCoordinator) -> None:
         """Initialize WLED playlist."""
         super().__init__(coordinator=coordinator)
 
-        self._attr_name = f"{coordinator.data.info.name} Playlist"
         self._attr_unique_id = f"{coordinator.data.info.mac_address}_playlist"
         self._attr_options = [
             playlist.name for playlist in self.coordinator.data.playlists
@@ -140,6 +140,7 @@ class WLEDPaletteSelect(WLEDEntity, SelectEntity):
 
     _attr_entity_category = EntityCategory.CONFIG
     _attr_icon = "mdi:palette-outline"
+    _attr_name = "Color palette"
     _segment: int
 
     def __init__(self, coordinator: WLEDDataUpdateCoordinator, segment: int) -> None:
@@ -148,11 +149,8 @@ class WLEDPaletteSelect(WLEDEntity, SelectEntity):
 
         # Segment 0 uses a simpler name, which is more natural for when using
         # a single segment / using WLED with one big LED strip.
-        self._attr_name = (
-            f"{coordinator.data.info.name} Segment {segment} Color Palette"
-        )
-        if segment == 0:
-            self._attr_name = f"{coordinator.data.info.name} Color Palette"
+        if segment != 0:
+            self._attr_name = f"Segment {segment} color palette"
 
         self._attr_unique_id = f"{coordinator.data.info.mac_address}_palette_{segment}"
         self._attr_options = [
diff --git a/homeassistant/components/wled/sensor.py b/homeassistant/components/wled/sensor.py
index 720158938c7..4a677910273 100644
--- a/homeassistant/components/wled/sensor.py
+++ b/homeassistant/components/wled/sensor.py
@@ -50,7 +50,7 @@ class WLEDSensorEntityDescription(
 SENSORS: tuple[WLEDSensorEntityDescription, ...] = (
     WLEDSensorEntityDescription(
         key="estimated_current",
-        name="Estimated Current",
+        name="Estimated current",
         native_unit_of_measurement=ELECTRIC_CURRENT_MILLIAMPERE,
         device_class=SensorDeviceClass.CURRENT,
         state_class=SensorStateClass.MEASUREMENT,
@@ -60,13 +60,13 @@ SENSORS: tuple[WLEDSensorEntityDescription, ...] = (
     ),
     WLEDSensorEntityDescription(
         key="info_leds_count",
-        name="LED Count",
+        name="LED count",
         entity_category=EntityCategory.DIAGNOSTIC,
         value_fn=lambda device: device.info.leds.count,
     ),
     WLEDSensorEntityDescription(
         key="info_leds_max_power",
-        name="Max Current",
+        name="Max current",
         native_unit_of_measurement=ELECTRIC_CURRENT_MILLIAMPERE,
         entity_category=EntityCategory.DIAGNOSTIC,
         device_class=SensorDeviceClass.CURRENT,
@@ -83,7 +83,7 @@ SENSORS: tuple[WLEDSensorEntityDescription, ...] = (
     ),
     WLEDSensorEntityDescription(
         key="free_heap",
-        name="Free Memory",
+        name="Free memory",
         icon="mdi:memory",
         native_unit_of_measurement=DATA_BYTES,
         state_class=SensorStateClass.MEASUREMENT,
@@ -93,7 +93,7 @@ SENSORS: tuple[WLEDSensorEntityDescription, ...] = (
     ),
     WLEDSensorEntityDescription(
         key="wifi_signal",
-        name="Wi-Fi Signal",
+        name="Wi-Fi signal",
         icon="mdi:wifi",
         native_unit_of_measurement=PERCENTAGE,
         entity_category=EntityCategory.DIAGNOSTIC,
@@ -111,7 +111,7 @@ SENSORS: tuple[WLEDSensorEntityDescription, ...] = (
     ),
     WLEDSensorEntityDescription(
         key="wifi_channel",
-        name="Wi-Fi Channel",
+        name="Wi-Fi channel",
         icon="mdi:wifi",
         entity_category=EntityCategory.DIAGNOSTIC,
         entity_registry_enabled_default=False,
@@ -155,7 +155,6 @@ class WLEDSensorEntity(WLEDEntity, SensorEntity):
         """Initialize a WLED sensor entity."""
         super().__init__(coordinator=coordinator)
         self.entity_description = description
-        self._attr_name = f"{coordinator.data.info.name} {description.name}"
         self._attr_unique_id = f"{coordinator.data.info.mac_address}_{description.key}"
 
     @property
diff --git a/homeassistant/components/wled/switch.py b/homeassistant/components/wled/switch.py
index e98b3494ad6..7d0d9ee24fb 100644
--- a/homeassistant/components/wled/switch.py
+++ b/homeassistant/components/wled/switch.py
@@ -55,11 +55,11 @@ class WLEDNightlightSwitch(WLEDEntity, SwitchEntity):
 
     _attr_icon = "mdi:weather-night"
     _attr_entity_category = EntityCategory.CONFIG
+    _attr_name = "Nightlight"
 
     def __init__(self, coordinator: WLEDDataUpdateCoordinator) -> None:
         """Initialize WLED nightlight switch."""
         super().__init__(coordinator=coordinator)
-        self._attr_name = f"{coordinator.data.info.name} Nightlight"
         self._attr_unique_id = f"{coordinator.data.info.mac_address}_nightlight"
 
     @property
@@ -92,11 +92,11 @@ class WLEDSyncSendSwitch(WLEDEntity, SwitchEntity):
 
     _attr_icon = "mdi:upload-network-outline"
     _attr_entity_category = EntityCategory.CONFIG
+    _attr_name = "Sync send"
 
     def __init__(self, coordinator: WLEDDataUpdateCoordinator) -> None:
         """Initialize WLED sync send switch."""
         super().__init__(coordinator=coordinator)
-        self._attr_name = f"{coordinator.data.info.name} Sync Send"
         self._attr_unique_id = f"{coordinator.data.info.mac_address}_sync_send"
 
     @property
@@ -125,11 +125,11 @@ class WLEDSyncReceiveSwitch(WLEDEntity, SwitchEntity):
 
     _attr_icon = "mdi:download-network-outline"
     _attr_entity_category = EntityCategory.CONFIG
+    _attr_name = "Sync receive"
 
     def __init__(self, coordinator: WLEDDataUpdateCoordinator) -> None:
         """Initialize WLED sync receive switch."""
         super().__init__(coordinator=coordinator)
-        self._attr_name = f"{coordinator.data.info.name} Sync Receive"
         self._attr_unique_id = f"{coordinator.data.info.mac_address}_sync_receive"
 
     @property
@@ -158,6 +158,7 @@ class WLEDReverseSwitch(WLEDEntity, SwitchEntity):
 
     _attr_icon = "mdi:swap-horizontal-bold"
     _attr_entity_category = EntityCategory.CONFIG
+    _attr_name = "Reverse"
     _segment: int
 
     def __init__(self, coordinator: WLEDDataUpdateCoordinator, segment: int) -> None:
@@ -166,9 +167,8 @@ class WLEDReverseSwitch(WLEDEntity, SwitchEntity):
 
         # Segment 0 uses a simpler name, which is more natural for when using
         # a single segment / using WLED with one big LED strip.
-        self._attr_name = f"{coordinator.data.info.name} Segment {segment} Reverse"
-        if segment == 0:
-            self._attr_name = f"{coordinator.data.info.name} Reverse"
+        if segment != 0:
+            self._attr_name = f"Segment {segment} reverse"
 
         self._attr_unique_id = f"{coordinator.data.info.mac_address}_reverse_{segment}"
         self._segment = segment
diff --git a/homeassistant/components/wled/update.py b/homeassistant/components/wled/update.py
index f0fc532b3b3..75546fdac1a 100644
--- a/homeassistant/components/wled/update.py
+++ b/homeassistant/components/wled/update.py
@@ -36,11 +36,11 @@ class WLEDUpdateEntity(WLEDEntity, UpdateEntity):
         UpdateEntityFeature.INSTALL | UpdateEntityFeature.SPECIFIC_VERSION
     )
     _attr_title = "WLED"
+    _attr_name = "Firmware"
 
     def __init__(self, coordinator: WLEDDataUpdateCoordinator) -> None:
         """Initialize the update entity."""
         super().__init__(coordinator=coordinator)
-        self._attr_name = f"{coordinator.data.info.name} Firmware"
         self._attr_unique_id = coordinator.data.info.mac_address
 
     @property