From dbe4252d34be1e33fd1de9abc2970ec8ac05564e Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Mon, 26 Jun 2023 23:39:02 +0200 Subject: [PATCH] Add entity translation to Aussie broadband (#95134) --- .../components/aussie_broadband/sensor.py | 24 ++++++------ .../components/aussie_broadband/strings.json | 37 +++++++++++++++++++ 2 files changed, 49 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/aussie_broadband/sensor.py b/homeassistant/components/aussie_broadband/sensor.py index 1ed146b6237..fa407949b40 100644 --- a/homeassistant/components/aussie_broadband/sensor.py +++ b/homeassistant/components/aussie_broadband/sensor.py @@ -35,7 +35,7 @@ SENSOR_DESCRIPTIONS: tuple[SensorValueEntityDescription, ...] = ( # Internet Services sensors SensorValueEntityDescription( key="usedMb", - name="Data used", + translation_key="data_used", state_class=SensorStateClass.TOTAL_INCREASING, native_unit_of_measurement=UnitOfInformation.MEGABYTES, device_class=SensorDeviceClass.DATA_SIZE, @@ -43,7 +43,7 @@ SENSOR_DESCRIPTIONS: tuple[SensorValueEntityDescription, ...] = ( ), SensorValueEntityDescription( key="downloadedMb", - name="Downloaded", + translation_key="downloaded", state_class=SensorStateClass.TOTAL_INCREASING, native_unit_of_measurement=UnitOfInformation.MEGABYTES, device_class=SensorDeviceClass.DATA_SIZE, @@ -51,7 +51,7 @@ SENSOR_DESCRIPTIONS: tuple[SensorValueEntityDescription, ...] = ( ), SensorValueEntityDescription( key="uploadedMb", - name="Uploaded", + translation_key="uploaded", state_class=SensorStateClass.TOTAL_INCREASING, native_unit_of_measurement=UnitOfInformation.MEGABYTES, device_class=SensorDeviceClass.DATA_SIZE, @@ -60,21 +60,21 @@ SENSOR_DESCRIPTIONS: tuple[SensorValueEntityDescription, ...] = ( # Mobile Phone Services sensors SensorValueEntityDescription( key="national", - name="National calls", + translation_key="national_calls", state_class=SensorStateClass.TOTAL_INCREASING, icon="mdi:phone", value=lambda x: x.get("calls"), ), SensorValueEntityDescription( key="mobile", - name="Mobile calls", + translation_key="mobile_calls", state_class=SensorStateClass.TOTAL_INCREASING, icon="mdi:phone", value=lambda x: x.get("calls"), ), SensorValueEntityDescription( key="international", - name="International calls", + translation_key="international_calls", entity_registry_enabled_default=False, state_class=SensorStateClass.TOTAL_INCREASING, icon="mdi:phone-plus", @@ -82,14 +82,14 @@ SENSOR_DESCRIPTIONS: tuple[SensorValueEntityDescription, ...] = ( ), SensorValueEntityDescription( key="sms", - name="SMS sent", + translation_key="sms_sent", state_class=SensorStateClass.TOTAL_INCREASING, icon="mdi:message-processing", value=lambda x: x.get("calls"), ), SensorValueEntityDescription( key="internet", - name="Data used", + translation_key="data_used", state_class=SensorStateClass.TOTAL_INCREASING, native_unit_of_measurement=UnitOfInformation.KILOBYTES, device_class=SensorDeviceClass.DATA_SIZE, @@ -98,7 +98,7 @@ SENSOR_DESCRIPTIONS: tuple[SensorValueEntityDescription, ...] = ( ), SensorValueEntityDescription( key="voicemail", - name="Voicemail calls", + translation_key="voicemail_calls", entity_registry_enabled_default=False, state_class=SensorStateClass.TOTAL_INCREASING, icon="mdi:phone", @@ -106,7 +106,7 @@ SENSOR_DESCRIPTIONS: tuple[SensorValueEntityDescription, ...] = ( ), SensorValueEntityDescription( key="other", - name="Other calls", + translation_key="other_calls", entity_registry_enabled_default=False, state_class=SensorStateClass.TOTAL_INCREASING, icon="mdi:phone", @@ -115,13 +115,13 @@ SENSOR_DESCRIPTIONS: tuple[SensorValueEntityDescription, ...] = ( # Generic sensors SensorValueEntityDescription( key="daysTotal", - name="Billing cycle length", + translation_key="billing_cycle_length", native_unit_of_measurement=UnitOfTime.DAYS, icon="mdi:calendar-range", ), SensorValueEntityDescription( key="daysRemaining", - name="Billing cycle remaining", + translation_key="billing_cycle_remaining", native_unit_of_measurement=UnitOfTime.DAYS, icon="mdi:calendar-clock", ), diff --git a/homeassistant/components/aussie_broadband/strings.json b/homeassistant/components/aussie_broadband/strings.json index c2052defa81..90e4f094ee6 100644 --- a/homeassistant/components/aussie_broadband/strings.json +++ b/homeassistant/components/aussie_broadband/strings.json @@ -46,5 +46,42 @@ "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]", "unknown": "[%key:common::config_flow::error::unknown%]" } + }, + "entity": { + "sensor": { + "data_used": { + "name": "Data used" + }, + "downloaded": { + "name": "Downloaded" + }, + "uploaded": { + "name": "Uploaded" + }, + "national_calls": { + "name": "National calls" + }, + "mobile_calls": { + "name": "Mobile calls" + }, + "international_calls": { + "name": "International calls" + }, + "sms_sent": { + "name": "SMS sent" + }, + "voicemail_calls": { + "name": "Voicemail calls" + }, + "other_calls": { + "name": "Other calls" + }, + "billing_cycle_length": { + "name": "Billing cycle length" + }, + "billing_cycle_remaining": { + "name": "Billing cycle remaining" + } + } } }