diff --git a/homeassistant/components/deluge/sensor.py b/homeassistant/components/deluge/sensor.py index eed194640dd..9242e3e2d5e 100644 --- a/homeassistant/components/deluge/sensor.py +++ b/homeassistant/components/deluge/sensor.py @@ -28,11 +28,11 @@ def get_state(data: dict[str, float], key: str) -> str | float: download = data[DATA_KEYS[1]] - data[DATA_KEYS[3]] if key == CURRENT_STATUS: if upload > 0 and download > 0: - return "Up/Down" + return "seeding_and_downloading" if upload > 0 and download == 0: - return "Seeding" + return "seeding" if upload == 0 and download > 0: - return "Downloading" + return "downloading" return STATE_IDLE kb_spd = float(upload if key == UPLOAD_SPEED else download) / 1024 return round(kb_spd, 2 if kb_spd < 0.1 else 1) @@ -48,12 +48,14 @@ class DelugeSensorEntityDescription(SensorEntityDescription): SENSOR_TYPES: tuple[DelugeSensorEntityDescription, ...] = ( DelugeSensorEntityDescription( key=CURRENT_STATUS, - name="Status", + translation_key="status", value=lambda data: get_state(data, CURRENT_STATUS), + device_class=SensorDeviceClass.ENUM, + options=["seeding_and_downloading", "seeding", "downloading", "idle"], ), DelugeSensorEntityDescription( key=DOWNLOAD_SPEED, - name="Down speed", + translation_key="download_speed", device_class=SensorDeviceClass.DATA_RATE, native_unit_of_measurement=UnitOfDataRate.KILOBYTES_PER_SECOND, state_class=SensorStateClass.MEASUREMENT, @@ -61,7 +63,7 @@ SENSOR_TYPES: tuple[DelugeSensorEntityDescription, ...] = ( ), DelugeSensorEntityDescription( key=UPLOAD_SPEED, - name="Up speed", + translation_key="upload_speed", device_class=SensorDeviceClass.DATA_RATE, native_unit_of_measurement=UnitOfDataRate.KILOBYTES_PER_SECOND, state_class=SensorStateClass.MEASUREMENT, diff --git a/homeassistant/components/deluge/strings.json b/homeassistant/components/deluge/strings.json index f11e1a2bd3e..e0266d004e2 100644 --- a/homeassistant/components/deluge/strings.json +++ b/homeassistant/components/deluge/strings.json @@ -19,5 +19,24 @@ "abort": { "already_configured": "[%key:common::config_flow::abort::already_configured_service%]" } + }, + "entity": { + "sensor": { + "status": { + "name": "Status", + "state": { + "seeding_and_downloading": "Up/Down", + "seeding": "Seeding", + "downloading": "Downloading", + "idle": "[%key:common::state::idle%]" + } + }, + "download_speed": { + "name": "Download speed" + }, + "upload_speed": { + "name": "Upload speed" + } + } } } diff --git a/homeassistant/components/deluge/switch.py b/homeassistant/components/deluge/switch.py index f9e89543d26..483b02844d6 100644 --- a/homeassistant/components/deluge/switch.py +++ b/homeassistant/components/deluge/switch.py @@ -24,6 +24,8 @@ async def async_setup_entry( class DelugeSwitch(DelugeEntity, SwitchEntity): """Representation of a Deluge switch.""" + _attr_name = None + def __init__(self, coordinator: DelugeDataUpdateCoordinator) -> None: """Initialize the Deluge switch.""" super().__init__(coordinator)