diff --git a/homeassistant/components/sabnzbd/sensor.py b/homeassistant/components/sabnzbd/sensor.py index 8edc579b7abb6d..d4920ef77f345d 100644 --- a/homeassistant/components/sabnzbd/sensor.py +++ b/homeassistant/components/sabnzbd/sensor.py @@ -17,7 +17,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import DOMAIN, SIGNAL_SABNZBD_UPDATED -from .const import DEFAULT_NAME, KEY_API_DATA, KEY_NAME +from .const import DEFAULT_NAME, KEY_API_DATA @dataclass @@ -37,51 +37,51 @@ class SabnzbdSensorEntityDescription(SensorEntityDescription, SabnzbdRequiredKey SENSOR_TYPES: tuple[SabnzbdSensorEntityDescription, ...] = ( SabnzbdSensorEntityDescription( key="status", - name="Status", + translation_key="status", ), SabnzbdSensorEntityDescription( key=SPEED_KEY, - name="Speed", + translation_key="speed", device_class=SensorDeviceClass.DATA_RATE, native_unit_of_measurement=UnitOfDataRate.MEGABYTES_PER_SECOND, state_class=SensorStateClass.MEASUREMENT, ), SabnzbdSensorEntityDescription( key="mb", - name="Queue", + translation_key="queue", native_unit_of_measurement=UnitOfInformation.MEGABYTES, device_class=SensorDeviceClass.DATA_SIZE, state_class=SensorStateClass.MEASUREMENT, ), SabnzbdSensorEntityDescription( key="mbleft", - name="Left", + translation_key="left", native_unit_of_measurement=UnitOfInformation.MEGABYTES, device_class=SensorDeviceClass.DATA_SIZE, state_class=SensorStateClass.MEASUREMENT, ), SabnzbdSensorEntityDescription( key="diskspacetotal1", - name="Disk", + translation_key="total_disk_space", native_unit_of_measurement=UnitOfInformation.GIGABYTES, device_class=SensorDeviceClass.DATA_SIZE, state_class=SensorStateClass.MEASUREMENT, ), SabnzbdSensorEntityDescription( key="diskspace1", - name="Disk Free", + translation_key="free_disk_space", native_unit_of_measurement=UnitOfInformation.GIGABYTES, device_class=SensorDeviceClass.DATA_SIZE, state_class=SensorStateClass.MEASUREMENT, ), SabnzbdSensorEntityDescription( key="noofslots_total", - name="Queue Count", + translation_key="queue_count", state_class=SensorStateClass.TOTAL, ), SabnzbdSensorEntityDescription( key="day_size", - name="Daily Total", + translation_key="daily_total", native_unit_of_measurement=UnitOfInformation.GIGABYTES, device_class=SensorDeviceClass.DATA_SIZE, entity_registry_enabled_default=False, @@ -89,7 +89,7 @@ class SabnzbdSensorEntityDescription(SensorEntityDescription, SabnzbdRequiredKey ), SabnzbdSensorEntityDescription( key="week_size", - name="Weekly Total", + translation_key="weekly_total", native_unit_of_measurement=UnitOfInformation.GIGABYTES, device_class=SensorDeviceClass.DATA_SIZE, entity_registry_enabled_default=False, @@ -97,7 +97,7 @@ class SabnzbdSensorEntityDescription(SensorEntityDescription, SabnzbdRequiredKey ), SabnzbdSensorEntityDescription( key="month_size", - name="Monthly Total", + translation_key="monthly_total", native_unit_of_measurement=UnitOfInformation.GIGABYTES, device_class=SensorDeviceClass.DATA_SIZE, entity_registry_enabled_default=False, @@ -105,7 +105,7 @@ class SabnzbdSensorEntityDescription(SensorEntityDescription, SabnzbdRequiredKey ), SabnzbdSensorEntityDescription( key="total_size", - name="Total", + translation_key="overall_total", native_unit_of_measurement=UnitOfInformation.GIGABYTES, device_class=SensorDeviceClass.DATA_SIZE, state_class=SensorStateClass.TOTAL_INCREASING, @@ -137,13 +137,9 @@ async def async_setup_entry( entry_id = config_entry.entry_id sab_api_data = hass.data[DOMAIN][entry_id][KEY_API_DATA] - client_name = hass.data[DOMAIN][entry_id][KEY_NAME] async_add_entities( - [ - SabnzbdSensor(sab_api_data, client_name, sensor, entry_id) - for sensor in SENSOR_TYPES - ] + [SabnzbdSensor(sab_api_data, sensor, entry_id) for sensor in SENSOR_TYPES] ) @@ -152,11 +148,11 @@ class SabnzbdSensor(SensorEntity): entity_description: SabnzbdSensorEntityDescription _attr_should_poll = False + _attr_has_entity_name = True def __init__( self, sabnzbd_api_data, - client_name, description: SabnzbdSensorEntityDescription, entry_id, ) -> None: @@ -165,7 +161,6 @@ def __init__( self._attr_unique_id = f"{entry_id}_{description.key}" self.entity_description = description self._sabnzbd_api = sabnzbd_api_data - self._attr_name = f"{client_name} {description.name}" self._attr_device_info = DeviceInfo( entry_type=DeviceEntryType.SERVICE, identifiers={(DOMAIN, entry_id)}, diff --git a/homeassistant/components/sabnzbd/strings.json b/homeassistant/components/sabnzbd/strings.json index a8e146eeb27333..8d3fb84fb9ff9b 100644 --- a/homeassistant/components/sabnzbd/strings.json +++ b/homeassistant/components/sabnzbd/strings.json @@ -14,6 +14,43 @@ "invalid_api_key": "[%key:common::config_flow::error::invalid_api_key%]" } }, + "entity": { + "sensor": { + "status": { + "name": "Status" + }, + "speed": { + "name": "Speed" + }, + "queue": { + "name": "Queue" + }, + "left": { + "name": "Left" + }, + "total_disk_space": { + "name": "Total disk space" + }, + "free_disk_space": { + "name": "Free disk space" + }, + "queue_count": { + "name": "Queue count" + }, + "daily_total": { + "name": "Daily total" + }, + "weekly_total": { + "name": "Weekly total" + }, + "monthly_total": { + "name": "Monthly total" + }, + "overall_total": { + "name": "Overall total" + } + } + }, "services": { "pause": { "name": "[%key:common::action::pause%]",