diff --git a/homeassistant/components/nzbget/__init__.py b/homeassistant/components/nzbget/__init__.py index c5512076172..c3b6aab619b 100644 --- a/homeassistant/components/nzbget/__init__.py +++ b/homeassistant/components/nzbget/__init__.py @@ -5,6 +5,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_SCAN_INTERVAL, Platform from homeassistant.core import HomeAssistant, ServiceCall from homeassistant.helpers import config_validation as cv +from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo from homeassistant.helpers.update_coordinator import CoordinatorEntity from .const import ( @@ -107,15 +108,20 @@ async def _async_update_listener(hass: HomeAssistant, entry: ConfigEntry) -> Non class NZBGetEntity(CoordinatorEntity[NZBGetDataUpdateCoordinator]): """Defines a base NZBGet entity.""" + _attr_has_entity_name = True + def __init__( - self, *, entry_id: str, name: str, coordinator: NZBGetDataUpdateCoordinator + self, + *, + entry_id: str, + entry_name: str, + coordinator: NZBGetDataUpdateCoordinator, ) -> None: """Initialize the NZBGet entity.""" super().__init__(coordinator) - self._name = name self._entry_id = entry_id - - @property - def name(self) -> str: - """Return the name of the entity.""" - return self._name + self._attr_device_info = DeviceInfo( + identifiers={(DOMAIN, entry_id)}, + name=entry_name, + entry_type=DeviceEntryType.SERVICE, + ) diff --git a/homeassistant/components/nzbget/sensor.py b/homeassistant/components/nzbget/sensor.py index 7f4d31c3adf..d76e004d720 100644 --- a/homeassistant/components/nzbget/sensor.py +++ b/homeassistant/components/nzbget/sensor.py @@ -25,63 +25,63 @@ _LOGGER = logging.getLogger(__name__) SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="ArticleCacheMB", - name="Article Cache", + translation_key="article_cache", native_unit_of_measurement=UnitOfInformation.MEGABYTES, device_class=SensorDeviceClass.DATA_SIZE, ), SensorEntityDescription( key="AverageDownloadRate", - name="Average Speed", + translation_key="average_speed", device_class=SensorDeviceClass.DATA_RATE, native_unit_of_measurement=UnitOfDataRate.BYTES_PER_SECOND, suggested_unit_of_measurement=UnitOfDataRate.MEGABYTES_PER_SECOND, ), SensorEntityDescription( key="DownloadPaused", - name="Download Paused", + translation_key="download_paused", ), SensorEntityDescription( key="DownloadRate", - name="Speed", + translation_key="speed", device_class=SensorDeviceClass.DATA_RATE, native_unit_of_measurement=UnitOfDataRate.BYTES_PER_SECOND, suggested_unit_of_measurement=UnitOfDataRate.MEGABYTES_PER_SECOND, ), SensorEntityDescription( key="DownloadedSizeMB", - name="Size", + translation_key="size", native_unit_of_measurement=UnitOfInformation.MEGABYTES, device_class=SensorDeviceClass.DATA_SIZE, ), SensorEntityDescription( key="FreeDiskSpaceMB", - name="Disk Free", + translation_key="disk_free", native_unit_of_measurement=UnitOfInformation.MEGABYTES, device_class=SensorDeviceClass.DATA_SIZE, ), SensorEntityDescription( key="PostJobCount", - name="Post Processing Jobs", + translation_key="post_processing_jobs", native_unit_of_measurement="Jobs", ), SensorEntityDescription( key="PostPaused", - name="Post Processing Paused", + translation_key="post_processing_paused", ), SensorEntityDescription( key="RemainingSizeMB", - name="Queue Size", + translation_key="queue_size", native_unit_of_measurement=UnitOfInformation.MEGABYTES, device_class=SensorDeviceClass.DATA_SIZE, ), SensorEntityDescription( key="UpTimeSec", - name="Uptime", + translation_key="uptime", device_class=SensorDeviceClass.TIMESTAMP, ), SensorEntityDescription( key="DownloadLimit", - name="Speed Limit", + translation_key="speed_limit", device_class=SensorDeviceClass.DATA_RATE, native_unit_of_measurement=UnitOfDataRate.BYTES_PER_SECOND, suggested_unit_of_measurement=UnitOfDataRate.MEGABYTES_PER_SECOND, @@ -120,7 +120,7 @@ class NZBGetSensor(NZBGetEntity, SensorEntity): super().__init__( coordinator=coordinator, entry_id=entry_id, - name=f"{entry_name} {description.name}", + entry_name=entry_name, ) self.entity_description = description diff --git a/homeassistant/components/nzbget/strings.json b/homeassistant/components/nzbget/strings.json index 7a3c438d11f..a1faa63bb39 100644 --- a/homeassistant/components/nzbget/strings.json +++ b/homeassistant/components/nzbget/strings.json @@ -32,6 +32,48 @@ } } }, + "entity": { + "sensor": { + "article_cache": { + "name": "Article cache" + }, + "average_speed": { + "name": "Average speed" + }, + "download_paused": { + "name": "Download paused" + }, + "speed": { + "name": "Speed" + }, + "size": { + "name": "Size" + }, + "disk_free": { + "name": "Disk free" + }, + "post_processing_jobs": { + "name": "Post processing jobs" + }, + "post_processing_paused": { + "name": "Post processing paused" + }, + "queue_size": { + "name": "Queue size" + }, + "uptime": { + "name": "Uptime" + }, + "speed_limit": { + "name": "Speed limit" + } + }, + "switch": { + "download": { + "name": "Download" + } + } + }, "services": { "pause": { "name": "[%key:common::action::pause%]", diff --git a/homeassistant/components/nzbget/switch.py b/homeassistant/components/nzbget/switch.py index 74b49b63501..e6a2b213873 100644 --- a/homeassistant/components/nzbget/switch.py +++ b/homeassistant/components/nzbget/switch.py @@ -38,6 +38,8 @@ async def async_setup_entry( class NZBGetDownloadSwitch(NZBGetEntity, SwitchEntity): """Representation of a NZBGet download switch.""" + _attr_translation_key = "download" + def __init__( self, coordinator: NZBGetDataUpdateCoordinator, @@ -50,7 +52,7 @@ class NZBGetDownloadSwitch(NZBGetEntity, SwitchEntity): super().__init__( coordinator=coordinator, entry_id=entry_id, - name=f"{entry_name} Download", + entry_name=entry_name, ) @property