Skip to content

Commit 6a01249

Browse files
authored
Fix entity names for HA hardware firmware update entities (#142029)
* Fix entity names for HA hardware firmware update entities * Fix unit tests
1 parent 74c2060 commit 6a01249

File tree

6 files changed

+18
-13
lines changed

6 files changed

+18
-13
lines changed

homeassistant/components/homeassistant_hardware/update.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ class BaseFirmwareUpdateEntity(
9595
_attr_supported_features = (
9696
UpdateEntityFeature.INSTALL | UpdateEntityFeature.PROGRESS
9797
)
98-
# Until this entity can be associated with a device, we must manually name it
99-
_attr_has_entity_name = False
98+
_attr_has_entity_name = True
10099

101100
def __init__(
102101
self,
@@ -195,10 +194,6 @@ def _firmware_info_callback(self, firmware_info: FirmwareInfo) -> None:
195194

196195
def _update_attributes(self) -> None:
197196
"""Recompute the attributes of the entity."""
198-
199-
# This entity is not currently associated with a device so we must manually
200-
# give it a name
201-
self._attr_name = f"{self._config_entry.title} Update"
202197
self._attr_title = self.entity_description.firmware_name or "Unknown"
203198

204199
if (

homeassistant/components/homeassistant_sky_connect/update.py

-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ class FirmwareUpdateEntity(BaseFirmwareUpdateEntity):
168168
"""SkyConnect firmware update entity."""
169169

170170
bootloader_reset_type = None
171-
_attr_has_entity_name = True
172171

173172
def __init__(
174173
self,

homeassistant/components/homeassistant_yellow/strings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
},
153153
"entity": {
154154
"update": {
155-
"firmware": {
155+
"radio_firmware": {
156156
"name": "Radio firmware"
157157
}
158158
}

homeassistant/components/homeassistant_yellow/update.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
] = {
4545
ApplicationType.EZSP: FirmwareUpdateEntityDescription(
4646
key="radio_firmware",
47+
translation_key="radio_firmware",
4748
display_precision=0,
4849
device_class=UpdateDeviceClass.FIRMWARE,
4950
entity_category=EntityCategory.CONFIG,
@@ -55,6 +56,7 @@
5556
),
5657
ApplicationType.SPINEL: FirmwareUpdateEntityDescription(
5758
key="radio_firmware",
59+
translation_key="radio_firmware",
5860
display_precision=0,
5961
device_class=UpdateDeviceClass.FIRMWARE,
6062
entity_category=EntityCategory.CONFIG,
@@ -65,7 +67,8 @@
6567
firmware_name="OpenThread RCP",
6668
),
6769
ApplicationType.CPC: FirmwareUpdateEntityDescription(
68-
key="firmware",
70+
key="radio_firmware",
71+
translation_key="radio_firmware",
6972
display_precision=0,
7073
device_class=UpdateDeviceClass.FIRMWARE,
7174
entity_category=EntityCategory.CONFIG,
@@ -76,7 +79,8 @@
7679
firmware_name="Multiprotocol",
7780
),
7881
ApplicationType.GECKO_BOOTLOADER: FirmwareUpdateEntityDescription(
79-
key="firmware",
82+
key="radio_firmware",
83+
translation_key="radio_firmware",
8084
display_precision=0,
8185
device_class=UpdateDeviceClass.FIRMWARE,
8286
entity_category=EntityCategory.CONFIG,
@@ -88,6 +92,7 @@
8892
),
8993
None: FirmwareUpdateEntityDescription(
9094
key="radio_firmware",
95+
translation_key="radio_firmware",
9196
display_precision=0,
9297
device_class=UpdateDeviceClass.FIRMWARE,
9398
entity_category=EntityCategory.CONFIG,
@@ -168,7 +173,6 @@ class FirmwareUpdateEntity(BaseFirmwareUpdateEntity):
168173
"""Yellow firmware update entity."""
169174

170175
bootloader_reset_type = "yellow" # Triggers a GPIO reset
171-
_attr_has_entity_name = True
172176

173177
def __init__(
174178
self,

tests/components/homeassistant_hardware/test_update.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
)
4444
from homeassistant.helpers import entity_registry as er
4545
from homeassistant.helpers.aiohttp_client import async_get_clientsession
46+
from homeassistant.helpers.device_registry import DeviceInfo
4647
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
4748
from homeassistant.setup import async_setup_component
4849
from homeassistant.util import dt as dt_util
@@ -61,7 +62,7 @@
6162
TEST_DOMAIN = "test"
6263
TEST_DEVICE = "/dev/serial/by-id/some-unique-serial-device-12345"
6364
TEST_FIRMWARE_RELEASES_URL = "https://example.org/firmware"
64-
TEST_UPDATE_ENTITY_ID = "update.test_firmware"
65+
TEST_UPDATE_ENTITY_ID = "update.mock_name_firmware"
6566
TEST_MANIFEST = FirmwareManifest(
6667
url=URL("https://example.org/firmware"),
6768
html_url=URL("https://example.org/release_notes"),
@@ -205,6 +206,12 @@ def __init__(
205206
"""Initialize the mock SkyConnect firmware update entity."""
206207
super().__init__(device, config_entry, update_coordinator, entity_description)
207208
self._attr_unique_id = self.entity_description.key
209+
self._attr_device_info = DeviceInfo(
210+
identifiers={(TEST_DOMAIN, "yellow")},
211+
name="Mock Name",
212+
model="Mock Model",
213+
manufacturer="Mock Manufacturer",
214+
)
208215

209216
# Use the cached firmware info if it exists
210217
if self._config_entry.data["firmware"] is not None:

tests/components/homeassistant_yellow/test_update.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from tests.common import MockConfigEntry
1919

20-
UPDATE_ENTITY_ID = "update.home_assistant_yellow_firmware"
20+
UPDATE_ENTITY_ID = "update.home_assistant_yellow_radio_firmware"
2121

2222

2323
async def test_yellow_update_entity(hass: HomeAssistant) -> None:

0 commit comments

Comments
 (0)