From fa59b7f8ac89f0aa5caf5eedfea08ed453a87299 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Tue, 18 Jul 2023 21:32:38 +0200 Subject: [PATCH] Add entity translations to Forecast Solar (#96476) --- .../components/forecast_solar/sensor.py | 22 +++++------ .../components/forecast_solar/strings.json | 37 +++++++++++++++++++ 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/forecast_solar/sensor.py b/homeassistant/components/forecast_solar/sensor.py index 2858bff098e..1b511f03eda 100644 --- a/homeassistant/components/forecast_solar/sensor.py +++ b/homeassistant/components/forecast_solar/sensor.py @@ -38,7 +38,7 @@ class ForecastSolarSensorEntityDescription(SensorEntityDescription): SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = ( ForecastSolarSensorEntityDescription( key="energy_production_today", - name="Estimated energy production - today", + translation_key="energy_production_today", state=lambda estimate: estimate.energy_production_today, device_class=SensorDeviceClass.ENERGY, native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, @@ -47,7 +47,7 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = ( ), ForecastSolarSensorEntityDescription( key="energy_production_today_remaining", - name="Estimated energy production - remaining today", + translation_key="energy_production_today_remaining", state=lambda estimate: estimate.energy_production_today_remaining, device_class=SensorDeviceClass.ENERGY, native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, @@ -56,7 +56,7 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = ( ), ForecastSolarSensorEntityDescription( key="energy_production_tomorrow", - name="Estimated energy production - tomorrow", + translation_key="energy_production_tomorrow", state=lambda estimate: estimate.energy_production_tomorrow, device_class=SensorDeviceClass.ENERGY, native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, @@ -65,17 +65,17 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = ( ), ForecastSolarSensorEntityDescription( key="power_highest_peak_time_today", - name="Highest power peak time - today", + translation_key="power_highest_peak_time_today", device_class=SensorDeviceClass.TIMESTAMP, ), ForecastSolarSensorEntityDescription( key="power_highest_peak_time_tomorrow", - name="Highest power peak time - tomorrow", + translation_key="power_highest_peak_time_tomorrow", device_class=SensorDeviceClass.TIMESTAMP, ), ForecastSolarSensorEntityDescription( key="power_production_now", - name="Estimated power production - now", + translation_key="power_production_now", device_class=SensorDeviceClass.POWER, state=lambda estimate: estimate.power_production_now, state_class=SensorStateClass.MEASUREMENT, @@ -83,37 +83,37 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = ( ), ForecastSolarSensorEntityDescription( key="power_production_next_hour", + translation_key="power_production_next_hour", state=lambda estimate: estimate.power_production_at_time( estimate.now() + timedelta(hours=1) ), - name="Estimated power production - next hour", device_class=SensorDeviceClass.POWER, entity_registry_enabled_default=False, native_unit_of_measurement=UnitOfPower.WATT, ), ForecastSolarSensorEntityDescription( key="power_production_next_12hours", + translation_key="power_production_next_12hours", state=lambda estimate: estimate.power_production_at_time( estimate.now() + timedelta(hours=12) ), - name="Estimated power production - next 12 hours", device_class=SensorDeviceClass.POWER, entity_registry_enabled_default=False, native_unit_of_measurement=UnitOfPower.WATT, ), ForecastSolarSensorEntityDescription( key="power_production_next_24hours", + translation_key="power_production_next_24hours", state=lambda estimate: estimate.power_production_at_time( estimate.now() + timedelta(hours=24) ), - name="Estimated power production - next 24 hours", device_class=SensorDeviceClass.POWER, entity_registry_enabled_default=False, native_unit_of_measurement=UnitOfPower.WATT, ), ForecastSolarSensorEntityDescription( key="energy_current_hour", - name="Estimated energy production - this hour", + translation_key="energy_current_hour", state=lambda estimate: estimate.energy_current_hour, device_class=SensorDeviceClass.ENERGY, native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, @@ -122,8 +122,8 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = ( ), ForecastSolarSensorEntityDescription( key="energy_next_hour", + translation_key="energy_next_hour", state=lambda estimate: estimate.sum_energy_production(1), - name="Estimated energy production - next hour", device_class=SensorDeviceClass.ENERGY, native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, diff --git a/homeassistant/components/forecast_solar/strings.json b/homeassistant/components/forecast_solar/strings.json index 7e8c32017ce..43e6fca4ada 100644 --- a/homeassistant/components/forecast_solar/strings.json +++ b/homeassistant/components/forecast_solar/strings.json @@ -31,5 +31,42 @@ } } } + }, + "entity": { + "sensor": { + "energy_production_today": { + "name": "Estimated energy production - today" + }, + "energy_production_today_remaining": { + "name": "Estimated energy production - remaining today" + }, + "energy_production_tomorrow": { + "name": "Estimated energy production - tomorrow" + }, + "power_highest_peak_time_today": { + "name": "Highest power peak time - today" + }, + "power_highest_peak_time_tomorrow": { + "name": "Highest power peak time - tomorrow" + }, + "power_production_now": { + "name": "Estimated power production - now" + }, + "power_production_next_hour": { + "name": "Estimated power production - next hour" + }, + "power_production_next_12hours": { + "name": "Estimated power production - next 12 hours" + }, + "power_production_next_24hours": { + "name": "Estimated power production - next 24 hours" + }, + "energy_current_hour": { + "name": "Estimated energy production - this hour" + }, + "energy_next_hour": { + "name": "Estimated energy production - next hour" + } + } } }