From 20d9f2d3b7dc512948bcf5971127231a61c7a47d Mon Sep 17 00:00:00 2001 From: Hans Oischinger Date: Mon, 9 May 2022 12:11:09 +0200 Subject: [PATCH] Vicare Gas & Power consumption summary sensors (#66458) --- homeassistant/components/vicare/sensor.py | 141 ++++++++++++++++++++-- 1 file changed, 131 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/vicare/sensor.py b/homeassistant/components/vicare/sensor.py index 249cadaee86..60a39b454a2 100644 --- a/homeassistant/components/vicare/sensor.py +++ b/homeassistant/components/vicare/sensor.py @@ -27,6 +27,7 @@ from homeassistant.const import ( POWER_WATT, TEMP_CELSIUS, TIME_HOURS, + VOLUME_CUBIC_METERS, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -132,6 +133,126 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( unit_getter=lambda api: api.getGasConsumptionHeatingUnit(), state_class=SensorStateClass.TOTAL_INCREASING, ), + ViCareSensorEntityDescription( + key="gas_summary_consumption_heating_currentday", + name="Heating gas consumption current day", + native_unit_of_measurement=VOLUME_CUBIC_METERS, + value_getter=lambda api: api.getGasSummaryConsumptionHeatingCurrentDay(), + unit_getter=lambda api: api.getGasSummaryConsumptionHeatingUnit(), + state_class=SensorStateClass.TOTAL_INCREASING, + ), + ViCareSensorEntityDescription( + key="gas_summary_consumption_heating_currentmonth", + name="Heating gas consumption current month", + native_unit_of_measurement=VOLUME_CUBIC_METERS, + value_getter=lambda api: api.getGasSummaryConsumptionHeatingCurrentMonth(), + unit_getter=lambda api: api.getGasSummaryConsumptionHeatingUnit(), + state_class=SensorStateClass.TOTAL_INCREASING, + ), + ViCareSensorEntityDescription( + key="gas_summary_consumption_heating_currentyear", + name="Heating gas consumption current year", + native_unit_of_measurement=VOLUME_CUBIC_METERS, + value_getter=lambda api: api.getGasSummaryConsumptionHeatingCurrentYear(), + unit_getter=lambda api: api.getGasSummaryConsumptionHeatingUnit(), + state_class=SensorStateClass.TOTAL_INCREASING, + ), + ViCareSensorEntityDescription( + key="hotwater_gas_summary_consumption_heating_currentday", + name="Hot water gas consumption current day", + native_unit_of_measurement=VOLUME_CUBIC_METERS, + value_getter=lambda api: api.getGasSummaryConsumptionDomesticHotWaterCurrentDay(), + unit_getter=lambda api: api.getGasSummaryConsumptionDomesticHotWaterUnit(), + state_class=SensorStateClass.TOTAL_INCREASING, + ), + ViCareSensorEntityDescription( + key="hotwater_gas_summary_consumption_heating_currentmonth", + name="Hot water gas consumption current month", + native_unit_of_measurement=VOLUME_CUBIC_METERS, + value_getter=lambda api: api.getGasSummaryConsumptionDomesticHotWaterCurrentMonth(), + unit_getter=lambda api: api.getGasSummaryConsumptionDomesticHotWaterUnit(), + state_class=SensorStateClass.TOTAL_INCREASING, + ), + ViCareSensorEntityDescription( + key="hotwater_gas_summary_consumption_heating_currentyear", + name="Hot water gas consumption current year", + native_unit_of_measurement=VOLUME_CUBIC_METERS, + value_getter=lambda api: api.getGasSummaryConsumptionDomesticHotWaterCurrentYear(), + unit_getter=lambda api: api.getGasSummaryConsumptionDomesticHotWaterUnit(), + state_class=SensorStateClass.TOTAL_INCREASING, + ), + ViCareSensorEntityDescription( + key="hotwater_gas_summary_consumption_heating_lastsevendays", + name="Hot water gas consumption last seven days", + native_unit_of_measurement=VOLUME_CUBIC_METERS, + value_getter=lambda api: api.getGasSummaryConsumptionDomesticHotWaterLastSevenDays(), + unit_getter=lambda api: api.getGasSummaryConsumptionDomesticHotWaterUnit(), + state_class=SensorStateClass.TOTAL_INCREASING, + ), + ViCareSensorEntityDescription( + key="energy_summary_consumption_heating_currentday", + name="Energy consumption of gas heating current day", + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, + value_getter=lambda api: api.getPowerSummaryConsumptionHeatingCurrentDay(), + unit_getter=lambda api: api.getPowerSummaryConsumptionHeatingUnit(), + state_class=SensorStateClass.TOTAL_INCREASING, + ), + ViCareSensorEntityDescription( + key="energy_summary_consumption_heating_currentmonth", + name="Energy consumption of gas heating current month", + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, + value_getter=lambda api: api.getPowerSummaryConsumptionHeatingCurrentMonth(), + unit_getter=lambda api: api.getPowerSummaryConsumptionHeatingUnit(), + state_class=SensorStateClass.TOTAL_INCREASING, + ), + ViCareSensorEntityDescription( + key="energy_summary_consumption_heating_currentyear", + name="Energy consumption of gas heating current year", + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, + value_getter=lambda api: api.getPowerSummaryConsumptionHeatingCurrentYear(), + unit_getter=lambda api: api.getPowerSummaryConsumptionHeatingUnit(), + state_class=SensorStateClass.TOTAL_INCREASING, + ), + ViCareSensorEntityDescription( + key="energy_summary_consumption_heating_lastsevendays", + name="Energy consumption of gas heating last seven days", + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, + value_getter=lambda api: api.getPowerSummaryConsumptionHeatingLastSevenDays(), + unit_getter=lambda api: api.getPowerSummaryConsumptionHeatingUnit(), + state_class=SensorStateClass.TOTAL_INCREASING, + ), + ViCareSensorEntityDescription( + key="energy_dhw_summary_consumption_heating_currentday", + name="Energy consumption of hot water gas heating current day", + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, + value_getter=lambda api: api.getPowerSummaryConsumptionDomesticHotWaterCurrentDay(), + unit_getter=lambda api: api.getPowerSummaryConsumptionDomesticHotWaterUnit(), + state_class=SensorStateClass.TOTAL_INCREASING, + ), + ViCareSensorEntityDescription( + key="energy_dhw_summary_consumption_heating_currentmonth", + name="Energy consumption of hot water gas heating current month", + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, + value_getter=lambda api: api.getPowerSummaryConsumptionDomesticHotWaterCurrentMonth(), + unit_getter=lambda api: api.getPowerSummaryConsumptionDomesticHotWaterUnit(), + state_class=SensorStateClass.TOTAL_INCREASING, + ), + ViCareSensorEntityDescription( + key="energy_dhw_summary_consumption_heating_currentyear", + name="Energy consumption of hot water gas heating current year", + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, + value_getter=lambda api: api.getPowerSummaryConsumptionDomesticHotWaterCurrentYear(), + unit_getter=lambda api: api.getPowerSummaryConsumptionDomesticHotWaterUnit(), + state_class=SensorStateClass.TOTAL_INCREASING, + ), + ViCareSensorEntityDescription( + key="energy_summary_dhw_consumption_heating_lastsevendays", + name="Energy consumption of hot water gas heating last seven days", + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, + value_getter=lambda api: api.getPowerSummaryConsumptionDomesticHotWaterLastSevenDays(), + unit_getter=lambda api: api.getPowerSummaryConsumptionDomesticHotWaterUnit(), + state_class=SensorStateClass.TOTAL_INCREASING, + ), ViCareSensorEntityDescription( key="power_production_current", name="Power production current", @@ -142,7 +263,7 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( ), ViCareSensorEntityDescription( key="power_production_today", - name="Power production today", + name="Energy production today", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, value_getter=lambda api: api.getPowerProductionToday(), device_class=SensorDeviceClass.ENERGY, @@ -158,7 +279,7 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( ), ViCareSensorEntityDescription( key="power_production_this_month", - name="Power production this month", + name="Energy production this month", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, value_getter=lambda api: api.getPowerProductionThisMonth(), device_class=SensorDeviceClass.ENERGY, @@ -166,7 +287,7 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( ), ViCareSensorEntityDescription( key="power_production_this_year", - name="Power production this year", + name="Energy production this year", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, value_getter=lambda api: api.getPowerProductionThisYear(), device_class=SensorDeviceClass.ENERGY, @@ -190,7 +311,7 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( ), ViCareSensorEntityDescription( key="solar power production today", - name="Solar power production today", + name="Solar energy production today", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, value_getter=lambda api: api.getSolarPowerProductionToday(), unit_getter=lambda api: api.getSolarPowerProductionUnit(), @@ -199,7 +320,7 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( ), ViCareSensorEntityDescription( key="solar power production this week", - name="Solar power production this week", + name="Solar energy production this week", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, value_getter=lambda api: api.getSolarPowerProductionThisWeek(), unit_getter=lambda api: api.getSolarPowerProductionUnit(), @@ -208,7 +329,7 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( ), ViCareSensorEntityDescription( key="solar power production this month", - name="Solar power production this month", + name="Solar energy production this month", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, value_getter=lambda api: api.getSolarPowerProductionThisMonth(), unit_getter=lambda api: api.getSolarPowerProductionUnit(), @@ -217,7 +338,7 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( ), ViCareSensorEntityDescription( key="solar power production this year", - name="Solar power production this year", + name="Solar energy production this year", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, value_getter=lambda api: api.getSolarPowerProductionThisYear(), unit_getter=lambda api: api.getSolarPowerProductionUnit(), @@ -226,7 +347,7 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( ), ViCareSensorEntityDescription( key="power consumption today", - name="Power consumption today", + name="Energy consumption today", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, value_getter=lambda api: api.getPowerConsumptionToday(), unit_getter=lambda api: api.getPowerConsumptionUnit(), @@ -244,7 +365,7 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( ), ViCareSensorEntityDescription( key="power consumption this month", - name="Power consumption this month", + name="Energy consumption this month", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, value_getter=lambda api: api.getPowerConsumptionThisMonth(), unit_getter=lambda api: api.getPowerConsumptionUnit(), @@ -253,7 +374,7 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( ), ViCareSensorEntityDescription( key="power consumption this year", - name="Power consumption this year", + name="Energy consumption this year", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, value_getter=lambda api: api.getPowerConsumptionThisYear(), unit_getter=lambda api: api.getPowerConsumptionUnit(),