mirror of
https://github.com/home-assistant/core.git
synced 2025-07-12 15:57:06 +00:00
Fix entity names for HA hardware firmware update entities (#142029)
* Fix entity names for HA hardware firmware update entities * Fix unit tests
This commit is contained in:
parent
f29444002e
commit
d888c70ff0
@ -95,8 +95,7 @@ class BaseFirmwareUpdateEntity(
|
|||||||
_attr_supported_features = (
|
_attr_supported_features = (
|
||||||
UpdateEntityFeature.INSTALL | UpdateEntityFeature.PROGRESS
|
UpdateEntityFeature.INSTALL | UpdateEntityFeature.PROGRESS
|
||||||
)
|
)
|
||||||
# Until this entity can be associated with a device, we must manually name it
|
_attr_has_entity_name = True
|
||||||
_attr_has_entity_name = False
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -195,10 +194,6 @@ class BaseFirmwareUpdateEntity(
|
|||||||
|
|
||||||
def _update_attributes(self) -> None:
|
def _update_attributes(self) -> None:
|
||||||
"""Recompute the attributes of the entity."""
|
"""Recompute the attributes of the entity."""
|
||||||
|
|
||||||
# This entity is not currently associated with a device so we must manually
|
|
||||||
# give it a name
|
|
||||||
self._attr_name = f"{self._config_entry.title} Update"
|
|
||||||
self._attr_title = self.entity_description.firmware_name or "Unknown"
|
self._attr_title = self.entity_description.firmware_name or "Unknown"
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -168,7 +168,6 @@ class FirmwareUpdateEntity(BaseFirmwareUpdateEntity):
|
|||||||
"""SkyConnect firmware update entity."""
|
"""SkyConnect firmware update entity."""
|
||||||
|
|
||||||
bootloader_reset_type = None
|
bootloader_reset_type = None
|
||||||
_attr_has_entity_name = True
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -152,7 +152,7 @@
|
|||||||
},
|
},
|
||||||
"entity": {
|
"entity": {
|
||||||
"update": {
|
"update": {
|
||||||
"firmware": {
|
"radio_firmware": {
|
||||||
"name": "Radio firmware"
|
"name": "Radio firmware"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ FIRMWARE_ENTITY_DESCRIPTIONS: dict[
|
|||||||
] = {
|
] = {
|
||||||
ApplicationType.EZSP: FirmwareUpdateEntityDescription(
|
ApplicationType.EZSP: FirmwareUpdateEntityDescription(
|
||||||
key="radio_firmware",
|
key="radio_firmware",
|
||||||
|
translation_key="radio_firmware",
|
||||||
display_precision=0,
|
display_precision=0,
|
||||||
device_class=UpdateDeviceClass.FIRMWARE,
|
device_class=UpdateDeviceClass.FIRMWARE,
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
@ -55,6 +56,7 @@ FIRMWARE_ENTITY_DESCRIPTIONS: dict[
|
|||||||
),
|
),
|
||||||
ApplicationType.SPINEL: FirmwareUpdateEntityDescription(
|
ApplicationType.SPINEL: FirmwareUpdateEntityDescription(
|
||||||
key="radio_firmware",
|
key="radio_firmware",
|
||||||
|
translation_key="radio_firmware",
|
||||||
display_precision=0,
|
display_precision=0,
|
||||||
device_class=UpdateDeviceClass.FIRMWARE,
|
device_class=UpdateDeviceClass.FIRMWARE,
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
@ -65,7 +67,8 @@ FIRMWARE_ENTITY_DESCRIPTIONS: dict[
|
|||||||
firmware_name="OpenThread RCP",
|
firmware_name="OpenThread RCP",
|
||||||
),
|
),
|
||||||
ApplicationType.CPC: FirmwareUpdateEntityDescription(
|
ApplicationType.CPC: FirmwareUpdateEntityDescription(
|
||||||
key="firmware",
|
key="radio_firmware",
|
||||||
|
translation_key="radio_firmware",
|
||||||
display_precision=0,
|
display_precision=0,
|
||||||
device_class=UpdateDeviceClass.FIRMWARE,
|
device_class=UpdateDeviceClass.FIRMWARE,
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
@ -76,7 +79,8 @@ FIRMWARE_ENTITY_DESCRIPTIONS: dict[
|
|||||||
firmware_name="Multiprotocol",
|
firmware_name="Multiprotocol",
|
||||||
),
|
),
|
||||||
ApplicationType.GECKO_BOOTLOADER: FirmwareUpdateEntityDescription(
|
ApplicationType.GECKO_BOOTLOADER: FirmwareUpdateEntityDescription(
|
||||||
key="firmware",
|
key="radio_firmware",
|
||||||
|
translation_key="radio_firmware",
|
||||||
display_precision=0,
|
display_precision=0,
|
||||||
device_class=UpdateDeviceClass.FIRMWARE,
|
device_class=UpdateDeviceClass.FIRMWARE,
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
@ -88,6 +92,7 @@ FIRMWARE_ENTITY_DESCRIPTIONS: dict[
|
|||||||
),
|
),
|
||||||
None: FirmwareUpdateEntityDescription(
|
None: FirmwareUpdateEntityDescription(
|
||||||
key="radio_firmware",
|
key="radio_firmware",
|
||||||
|
translation_key="radio_firmware",
|
||||||
display_precision=0,
|
display_precision=0,
|
||||||
device_class=UpdateDeviceClass.FIRMWARE,
|
device_class=UpdateDeviceClass.FIRMWARE,
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
@ -168,7 +173,6 @@ class FirmwareUpdateEntity(BaseFirmwareUpdateEntity):
|
|||||||
"""Yellow firmware update entity."""
|
"""Yellow firmware update entity."""
|
||||||
|
|
||||||
bootloader_reset_type = "yellow" # Triggers a GPIO reset
|
bootloader_reset_type = "yellow" # Triggers a GPIO reset
|
||||||
_attr_has_entity_name = True
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -43,6 +43,7 @@ from homeassistant.core import (
|
|||||||
)
|
)
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
@ -61,7 +62,7 @@ from tests.common import (
|
|||||||
TEST_DOMAIN = "test"
|
TEST_DOMAIN = "test"
|
||||||
TEST_DEVICE = "/dev/serial/by-id/some-unique-serial-device-12345"
|
TEST_DEVICE = "/dev/serial/by-id/some-unique-serial-device-12345"
|
||||||
TEST_FIRMWARE_RELEASES_URL = "https://example.org/firmware"
|
TEST_FIRMWARE_RELEASES_URL = "https://example.org/firmware"
|
||||||
TEST_UPDATE_ENTITY_ID = "update.test_firmware"
|
TEST_UPDATE_ENTITY_ID = "update.mock_name_firmware"
|
||||||
TEST_MANIFEST = FirmwareManifest(
|
TEST_MANIFEST = FirmwareManifest(
|
||||||
url=URL("https://example.org/firmware"),
|
url=URL("https://example.org/firmware"),
|
||||||
html_url=URL("https://example.org/release_notes"),
|
html_url=URL("https://example.org/release_notes"),
|
||||||
@ -205,6 +206,12 @@ class MockFirmwareUpdateEntity(BaseFirmwareUpdateEntity):
|
|||||||
"""Initialize the mock SkyConnect firmware update entity."""
|
"""Initialize the mock SkyConnect firmware update entity."""
|
||||||
super().__init__(device, config_entry, update_coordinator, entity_description)
|
super().__init__(device, config_entry, update_coordinator, entity_description)
|
||||||
self._attr_unique_id = self.entity_description.key
|
self._attr_unique_id = self.entity_description.key
|
||||||
|
self._attr_device_info = DeviceInfo(
|
||||||
|
identifiers={(TEST_DOMAIN, "yellow")},
|
||||||
|
name="Mock Name",
|
||||||
|
model="Mock Model",
|
||||||
|
manufacturer="Mock Manufacturer",
|
||||||
|
)
|
||||||
|
|
||||||
# Use the cached firmware info if it exists
|
# Use the cached firmware info if it exists
|
||||||
if self._config_entry.data["firmware"] is not None:
|
if self._config_entry.data["firmware"] is not None:
|
||||||
|
@ -17,7 +17,7 @@ from homeassistant.setup import async_setup_component
|
|||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
UPDATE_ENTITY_ID = "update.home_assistant_yellow_firmware"
|
UPDATE_ENTITY_ID = "update.home_assistant_yellow_radio_firmware"
|
||||||
|
|
||||||
|
|
||||||
async def test_yellow_update_entity(hass: HomeAssistant) -> None:
|
async def test_yellow_update_entity(hass: HomeAssistant) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user