From 539b9d76fcc2f249d547c41d5f07dcf18ae0c0af Mon Sep 17 00:00:00 2001 From: Christopher Fenner <9592452+CFenner@users.noreply.github.com> Date: Fri, 7 Jun 2024 10:21:24 +0200 Subject: [PATCH] Add photovoltaic sensors to ViCare integration (#113664) * Add photovoltaic sensors * Update strings.json * Apply suggestions from code review * change uom for daily sensor --- homeassistant/components/vicare/sensor.py | 40 ++++++++++++++++++++ homeassistant/components/vicare/strings.json | 12 ++++++ 2 files changed, 52 insertions(+) diff --git a/homeassistant/components/vicare/sensor.py b/homeassistant/components/vicare/sensor.py index 41266f8bde7..0e98729e40f 100644 --- a/homeassistant/components/vicare/sensor.py +++ b/homeassistant/components/vicare/sensor.py @@ -694,10 +694,50 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( key="photovoltaic_energy_production_today", translation_key="photovoltaic_energy_production_today", native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, + suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, state_class=SensorStateClass.TOTAL_INCREASING, value_getter=lambda api: api.getPhotovoltaicProductionCumulatedCurrentDay(), unit_getter=lambda api: api.getPhotovoltaicProductionCumulatedUnit(), ), + ViCareSensorEntityDescription( + key="photovoltaic_energy_production_this_week", + translation_key="photovoltaic_energy_production_this_week", + native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, + suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + state_class=SensorStateClass.TOTAL_INCREASING, + value_getter=lambda api: api.getPhotovoltaicProductionCumulatedCurrentWeek(), + unit_getter=lambda api: api.getPhotovoltaicProductionCumulatedUnit(), + entity_registry_enabled_default=False, + ), + ViCareSensorEntityDescription( + key="photovoltaic_energy_production_this_month", + translation_key="photovoltaic_energy_production_this_month", + native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, + suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + state_class=SensorStateClass.TOTAL_INCREASING, + value_getter=lambda api: api.getPhotovoltaicProductionCumulatedCurrentMonth(), + unit_getter=lambda api: api.getPhotovoltaicProductionCumulatedUnit(), + entity_registry_enabled_default=False, + ), + ViCareSensorEntityDescription( + key="photovoltaic_energy_production_this_year", + translation_key="photovoltaic_energy_production_this_year", + native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, + suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + state_class=SensorStateClass.TOTAL_INCREASING, + value_getter=lambda api: api.getPhotovoltaicProductionCumulatedCurrentYear(), + unit_getter=lambda api: api.getPhotovoltaicProductionCumulatedUnit(), + entity_registry_enabled_default=False, + ), + ViCareSensorEntityDescription( + key="photovoltaic_energy_production_total", + translation_key="photovoltaic_energy_production_total", + native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, + suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + state_class=SensorStateClass.TOTAL_INCREASING, + value_getter=lambda api: api.getPhotovoltaicProductionCumulatedLifeCycle(), + unit_getter=lambda api: api.getPhotovoltaicProductionCumulatedUnit(), + ), ViCareSensorEntityDescription( key="photovoltaic_status", translation_key="photovoltaic_status", diff --git a/homeassistant/components/vicare/strings.json b/homeassistant/components/vicare/strings.json index f81d01b71cf..de92d0ec271 100644 --- a/homeassistant/components/vicare/strings.json +++ b/homeassistant/components/vicare/strings.json @@ -319,6 +319,18 @@ "photovoltaic_energy_production_today": { "name": "Solar energy production today" }, + "photovoltaic_energy_production_this_week": { + "name": "Solar energy production this week" + }, + "photovoltaic_energy_production_this_month": { + "name": "Solar energy production this month" + }, + "photovoltaic_energy_production_this_year": { + "name": "Solar energy production this year" + }, + "photovoltaic_energy_production_total": { + "name": "Solar energy production total" + }, "photovoltaic_status": { "name": "Solar state", "state": {