From 2f3cbdbc9725ad8b9f1eeefefce07a23f3cd41be Mon Sep 17 00:00:00 2001 From: figorr <77553975+figorr@users.noreply.github.com> Date: Tue, 1 Oct 2024 19:12:15 +0200 Subject: [PATCH] Name sensors translation. Added name sensors translation. --- custom_components/ecowater_softener/sensor.py | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/custom_components/ecowater_softener/sensor.py b/custom_components/ecowater_softener/sensor.py index 1e65fb7..00f52a4 100644 --- a/custom_components/ecowater_softener/sensor.py +++ b/custom_components/ecowater_softener/sensor.py @@ -38,7 +38,8 @@ RECHARGE_ENABLED, RECHARGE_STATUS, ROCK_REMOVED, - ROCK_REMOVED_DAILY_AVERAGE + ROCK_REMOVED_DAILY_AVERAGE, + LAST_UPDATE ) from .coordinator import EcowaterDataCoordinator @@ -50,7 +51,7 @@ class EcowaterSensorEntityDescription(SensorEntityDescription): SENSOR_TYPES: tuple[EcowaterSensorEntityDescription, ...] = ( EcowaterSensorEntityDescription( key=WATER_AVAILABLE, - name="Water Available", + translation_key="water_available", icon="mdi:water", device_class=SensorDeviceClass.WATER, state_class=SensorStateClass.TOTAL, @@ -58,7 +59,7 @@ class EcowaterSensorEntityDescription(SensorEntityDescription): ), EcowaterSensorEntityDescription( key=WATER_USAGE_TODAY, - name="Water Used Today", + translation_key="water_usage_today", icon="mdi:water", device_class=SensorDeviceClass.WATER, state_class=SensorStateClass.TOTAL_INCREASING, @@ -66,7 +67,7 @@ class EcowaterSensorEntityDescription(SensorEntityDescription): ), EcowaterSensorEntityDescription( key=WATER_USAGE_DAILY_AVERAGE, - name="Average Water Used per Day", + translation_key="water_usage_daily_average", icon="mdi:water", device_class=SensorDeviceClass.WATER, state_class=SensorStateClass.TOTAL, @@ -74,7 +75,7 @@ class EcowaterSensorEntityDescription(SensorEntityDescription): ), EcowaterSensorEntityDescription( key=CURRENT_WATER_FLOW, - name="Water Flow", + translation_key="current_water_flow", icon="mdi:water", device_class=SensorDeviceClass.VOLUME_FLOW_RATE, state_class=SensorStateClass.MEASUREMENT, @@ -82,53 +83,53 @@ class EcowaterSensorEntityDescription(SensorEntityDescription): ), EcowaterSensorEntityDescription( key=SALT_LEVEL_PERCENTAGE, - name="Salt Level Percentage", + translation_key="salt_level_percentage", icon="mdi:altimeter", state_class=SensorStateClass.MEASUREMENT, native_unit_of_measurement=PERCENTAGE ), EcowaterSensorEntityDescription( key=OUT_OF_SALT_ON, - name="Out of Salt Date", + translation_key="out_of_salt_on", icon="mdi:calendar", device_class=SensorDeviceClass.DATE ), EcowaterSensorEntityDescription( key=DAYS_UNTIL_OUT_OF_SALT, - name="Days Until Out of Salt", + translation_key="days_until_out_of_salt", icon="mdi:calendar", native_unit_of_measurement=UnitOfTime.DAYS ), EcowaterSensorEntityDescription( key=SALT_TYPE, - name="Salt Type", + translation_key="salt_type", icon="mdi:shaker-outline" ), EcowaterSensorEntityDescription( key=LAST_RECHARGE, - name="Last Recharge Date", + translation_key="last_recharge_date", icon="mdi:calendar", device_class=SensorDeviceClass.DATE ), EcowaterSensorEntityDescription( key=DAYS_SINCE_RECHARGE, - name="Days Since Last Recharge", + translation_key="days_since_recharge", icon="mdi:calendar", native_unit_of_measurement=UnitOfTime.DAYS ), EcowaterSensorEntityDescription( key=RECHARGE_ENABLED, - name="Recharge Enabled", + translation_key="recharge_enabled", icon="mdi:refresh" ), EcowaterSensorEntityDescription( key=RECHARGE_STATUS, - name="Recharge Status", + translation_key="recharge_status", icon="mdi:refresh" ), EcowaterSensorEntityDescription( key=ROCK_REMOVED, - name="Rock Removed", + translation_key="rock_removed", icon="mdi:grain", device_class=SensorDeviceClass.WEIGHT, state_class=SensorStateClass.TOTAL, @@ -136,12 +137,12 @@ class EcowaterSensorEntityDescription(SensorEntityDescription): ), EcowaterSensorEntityDescription( key=ROCK_REMOVED_DAILY_AVERAGE, - name="Average Rock Removed per Day", + translation_key="rock_removed_daily_average", icon="mdi:grain", device_class=SensorDeviceClass.WEIGHT, state_class=SensorStateClass.TOTAL, native_unit_of_measurement=UnitOfMass.POUNDS - ), + ) ) async def async_setup_entry(