diff --git a/homeassistant/components/vicare/climate.py b/homeassistant/components/vicare/climate.py index 451ea70edab..c0c0db85cf3 100644 --- a/homeassistant/components/vicare/climate.py +++ b/homeassistant/components/vicare/climate.py @@ -95,12 +95,6 @@ HA_TO_VICARE_PRESET_HEATING = { } -def _build_entity(name, vicare_api, circuit, device_config, heating_type): - """Create a ViCare climate entity.""" - _LOGGER.debug("Found device %s", name) - return ViCareClimate(name, vicare_api, device_config, circuit, heating_type) - - def _get_circuits(vicare_api): """Return the list of circuits.""" try: @@ -126,11 +120,11 @@ async def async_setup_entry( if len(circuits) > 1: suffix = f" {circuit.id}" - entity = _build_entity( + entity = ViCareClimate( f"{name} Heating{suffix}", api, - hass.data[DOMAIN][config_entry.entry_id][VICARE_DEVICE_CONFIG], circuit, + hass.data[DOMAIN][config_entry.entry_id][VICARE_DEVICE_CONFIG], config_entry.data[CONF_HEATING_TYPE], ) entities.append(entity) diff --git a/homeassistant/components/vicare/sensor.py b/homeassistant/components/vicare/sensor.py index 42594ec202e..23096cfeacd 100644 --- a/homeassistant/components/vicare/sensor.py +++ b/homeassistant/components/vicare/sensor.py @@ -43,46 +43,6 @@ from .const import ( _LOGGER = logging.getLogger(__name__) -SENSOR_OUTSIDE_TEMPERATURE = "outside_temperature" -SENSOR_SUPPLY_TEMPERATURE = "supply_temperature" -SENSOR_RETURN_TEMPERATURE = "return_temperature" - -# gas sensors -SENSOR_BOILER_TEMPERATURE = "boiler_temperature" -SENSOR_BURNER_MODULATION = "burner_modulation" -SENSOR_BURNER_STARTS = "burner_starts" -SENSOR_BURNER_HOURS = "burner_hours" -SENSOR_BURNER_POWER = "burner_power" -SENSOR_DHW_GAS_CONSUMPTION_TODAY = "hotwater_gas_consumption_today" -SENSOR_DHW_GAS_CONSUMPTION_THIS_WEEK = "hotwater_gas_consumption_heating_this_week" -SENSOR_DHW_GAS_CONSUMPTION_THIS_MONTH = "hotwater_gas_consumption_heating_this_month" -SENSOR_DHW_GAS_CONSUMPTION_THIS_YEAR = "hotwater_gas_consumption_heating_this_year" -SENSOR_GAS_CONSUMPTION_TODAY = "gas_consumption_heating_today" -SENSOR_GAS_CONSUMPTION_THIS_WEEK = "gas_consumption_heating_this_week" -SENSOR_GAS_CONSUMPTION_THIS_MONTH = "gas_consumption_heating_this_month" -SENSOR_GAS_CONSUMPTION_THIS_YEAR = "gas_consumption_heating_this_year" - -# heatpump sensors -SENSOR_COMPRESSOR_STARTS = "compressor_starts" -SENSOR_COMPRESSOR_HOURS = "compressor_hours" -SENSOR_COMPRESSOR_HOURS_LOADCLASS1 = "compressor_hours_loadclass1" -SENSOR_COMPRESSOR_HOURS_LOADCLASS2 = "compressor_hours_loadclass2" -SENSOR_COMPRESSOR_HOURS_LOADCLASS3 = "compressor_hours_loadclass3" -SENSOR_COMPRESSOR_HOURS_LOADCLASS4 = "compressor_hours_loadclass4" -SENSOR_COMPRESSOR_HOURS_LOADCLASS5 = "compressor_hours_loadclass5" - -# fuelcell sensors -SENSOR_POWER_PRODUCTION_CURRENT = "power_production_current" -SENSOR_POWER_PRODUCTION_TODAY = "power_production_today" -SENSOR_POWER_PRODUCTION_THIS_WEEK = "power_production_this_week" -SENSOR_POWER_PRODUCTION_THIS_MONTH = "power_production_this_month" -SENSOR_POWER_PRODUCTION_THIS_YEAR = "power_production_this_year" - -# solar sensors -SENSOR_COLLECTOR_TEMPERATURE = "collector temperature" -SENSOR_SOLAR_STORAGE_TEMPERATURE = "solar storage temperature" -SENSOR_SOLAR_POWER_PRODUCTION = "solar power production" - @dataclass class ViCareSensorEntityDescription(SensorEntityDescription, ViCareRequiredKeysMixin): @@ -93,84 +53,84 @@ class ViCareSensorEntityDescription(SensorEntityDescription, ViCareRequiredKeysM GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( ViCareSensorEntityDescription( - key=SENSOR_OUTSIDE_TEMPERATURE, + key="outside_temperature", name="Outside Temperature", native_unit_of_measurement=TEMP_CELSIUS, value_getter=lambda api: api.getOutsideTemperature(), device_class=SensorDeviceClass.TEMPERATURE, ), ViCareSensorEntityDescription( - key=SENSOR_RETURN_TEMPERATURE, + key="return_temperature", name="Return Temperature", native_unit_of_measurement=TEMP_CELSIUS, value_getter=lambda api: api.getReturnTemperature(), device_class=SensorDeviceClass.TEMPERATURE, ), ViCareSensorEntityDescription( - key=SENSOR_BOILER_TEMPERATURE, + key="boiler_temperature", name="Boiler Temperature", native_unit_of_measurement=TEMP_CELSIUS, value_getter=lambda api: api.getBoilerTemperature(), device_class=SensorDeviceClass.TEMPERATURE, ), ViCareSensorEntityDescription( - key=SENSOR_DHW_GAS_CONSUMPTION_TODAY, + key="hotwater_gas_consumption_today", name="Hot water gas consumption today", value_getter=lambda api: api.getGasConsumptionDomesticHotWaterToday(), unit_getter=lambda api: api.getGasConsumptionDomesticHotWaterUnit(), state_class=SensorStateClass.TOTAL_INCREASING, ), ViCareSensorEntityDescription( - key=SENSOR_DHW_GAS_CONSUMPTION_THIS_WEEK, + key="hotwater_gas_consumption_heating_this_week", name="Hot water gas consumption this week", value_getter=lambda api: api.getGasConsumptionDomesticHotWaterThisWeek(), unit_getter=lambda api: api.getGasConsumptionDomesticHotWaterUnit(), state_class=SensorStateClass.TOTAL_INCREASING, ), ViCareSensorEntityDescription( - key=SENSOR_DHW_GAS_CONSUMPTION_THIS_MONTH, + key="hotwater_gas_consumption_heating_this_month", name="Hot water gas consumption this month", value_getter=lambda api: api.getGasConsumptionDomesticHotWaterThisMonth(), unit_getter=lambda api: api.getGasConsumptionDomesticHotWaterUnit(), state_class=SensorStateClass.TOTAL_INCREASING, ), ViCareSensorEntityDescription( - key=SENSOR_DHW_GAS_CONSUMPTION_THIS_YEAR, + key="hotwater_gas_consumption_heating_this_year", name="Hot water gas consumption this year", value_getter=lambda api: api.getGasConsumptionDomesticHotWaterThisYear(), unit_getter=lambda api: api.getGasConsumptionDomesticHotWaterUnit(), state_class=SensorStateClass.TOTAL_INCREASING, ), ViCareSensorEntityDescription( - key=SENSOR_GAS_CONSUMPTION_TODAY, + key="gas_consumption_heating_today", name="Heating gas consumption today", value_getter=lambda api: api.getGasConsumptionHeatingToday(), unit_getter=lambda api: api.getGasConsumptionHeatingUnit(), state_class=SensorStateClass.TOTAL_INCREASING, ), ViCareSensorEntityDescription( - key=SENSOR_GAS_CONSUMPTION_THIS_WEEK, + key="gas_consumption_heating_this_week", name="Heating gas consumption this week", value_getter=lambda api: api.getGasConsumptionHeatingThisWeek(), unit_getter=lambda api: api.getGasConsumptionHeatingUnit(), state_class=SensorStateClass.TOTAL_INCREASING, ), ViCareSensorEntityDescription( - key=SENSOR_GAS_CONSUMPTION_THIS_MONTH, + key="gas_consumption_heating_this_month", name="Heating gas consumption this month", value_getter=lambda api: api.getGasConsumptionHeatingThisMonth(), unit_getter=lambda api: api.getGasConsumptionHeatingUnit(), state_class=SensorStateClass.TOTAL_INCREASING, ), ViCareSensorEntityDescription( - key=SENSOR_GAS_CONSUMPTION_THIS_YEAR, + key="gas_consumption_heating_this_year", name="Heating gas consumption this year", value_getter=lambda api: api.getGasConsumptionHeatingThisYear(), unit_getter=lambda api: api.getGasConsumptionHeatingUnit(), state_class=SensorStateClass.TOTAL_INCREASING, ), ViCareSensorEntityDescription( - key=SENSOR_POWER_PRODUCTION_CURRENT, + key="power_production_current", name="Power production current", native_unit_of_measurement=POWER_WATT, value_getter=lambda api: api.getPowerProductionCurrent(), @@ -178,7 +138,7 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( state_class=SensorStateClass.MEASUREMENT, ), ViCareSensorEntityDescription( - key=SENSOR_POWER_PRODUCTION_TODAY, + key="power_production_today", name="Power production today", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, value_getter=lambda api: api.getPowerProductionToday(), @@ -186,7 +146,7 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( state_class=SensorStateClass.TOTAL_INCREASING, ), ViCareSensorEntityDescription( - key=SENSOR_POWER_PRODUCTION_THIS_WEEK, + key="power_production_this_week", name="Power production this week", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, value_getter=lambda api: api.getPowerProductionThisWeek(), @@ -194,7 +154,7 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( state_class=SensorStateClass.TOTAL_INCREASING, ), ViCareSensorEntityDescription( - key=SENSOR_POWER_PRODUCTION_THIS_MONTH, + key="power_production_this_month", name="Power production this month", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, value_getter=lambda api: api.getPowerProductionThisMonth(), @@ -202,7 +162,7 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( state_class=SensorStateClass.TOTAL_INCREASING, ), ViCareSensorEntityDescription( - key=SENSOR_POWER_PRODUCTION_THIS_YEAR, + key="power_production_this_year", name="Power production this year", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, value_getter=lambda api: api.getPowerProductionThisYear(), @@ -210,21 +170,21 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( state_class=SensorStateClass.TOTAL_INCREASING, ), ViCareSensorEntityDescription( - key=SENSOR_SOLAR_STORAGE_TEMPERATURE, + key="solar storage temperature", name="Solar Storage Temperature", native_unit_of_measurement=TEMP_CELSIUS, value_getter=lambda api: api.getSolarStorageTemperature(), device_class=SensorDeviceClass.TEMPERATURE, ), ViCareSensorEntityDescription( - key=SENSOR_COLLECTOR_TEMPERATURE, + key="collector temperature", name="Solar Collector Temperature", native_unit_of_measurement=TEMP_CELSIUS, value_getter=lambda api: api.getSolarCollectorTemperature(), device_class=SensorDeviceClass.TEMPERATURE, ), ViCareSensorEntityDescription( - key=SENSOR_SOLAR_POWER_PRODUCTION, + key="solar power production", name="Solar Power Production", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, value_getter=lambda api: api.getSolarPowerProduction(), @@ -235,7 +195,7 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( CIRCUIT_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( ViCareSensorEntityDescription( - key=SENSOR_SUPPLY_TEMPERATURE, + key="supply_temperature", name="Supply Temperature", native_unit_of_measurement=TEMP_CELSIUS, value_getter=lambda api: api.getSupplyTemperature(), @@ -244,20 +204,20 @@ CIRCUIT_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( BURNER_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( ViCareSensorEntityDescription( - key=SENSOR_BURNER_STARTS, + key="burner_starts", name="Burner Starts", icon="mdi:counter", value_getter=lambda api: api.getStarts(), ), ViCareSensorEntityDescription( - key=SENSOR_BURNER_HOURS, + key="burner_hours", name="Burner Hours", icon="mdi:counter", native_unit_of_measurement=TIME_HOURS, value_getter=lambda api: api.getHours(), ), ViCareSensorEntityDescription( - key=SENSOR_BURNER_MODULATION, + key="burner_modulation", name="Burner Modulation", icon="mdi:percent", native_unit_of_measurement=PERCENTAGE, @@ -267,48 +227,48 @@ BURNER_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( COMPRESSOR_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( ViCareSensorEntityDescription( - key=SENSOR_COMPRESSOR_STARTS, + key="compressor_starts", name="Compressor Starts", icon="mdi:counter", value_getter=lambda api: api.getStarts(), ), ViCareSensorEntityDescription( - key=SENSOR_COMPRESSOR_HOURS, + key="compressor_hours", name="Compressor Hours", icon="mdi:counter", native_unit_of_measurement=TIME_HOURS, value_getter=lambda api: api.getHours(), ), ViCareSensorEntityDescription( - key=SENSOR_COMPRESSOR_HOURS_LOADCLASS1, + key="compressor_hours_loadclass1", name="Compressor Hours Load Class 1", icon="mdi:counter", native_unit_of_measurement=TIME_HOURS, value_getter=lambda api: api.getHoursLoadClass1(), ), ViCareSensorEntityDescription( - key=SENSOR_COMPRESSOR_HOURS_LOADCLASS2, + key="compressor_hours_loadclass2", name="Compressor Hours Load Class 2", icon="mdi:counter", native_unit_of_measurement=TIME_HOURS, value_getter=lambda api: api.getHoursLoadClass2(), ), ViCareSensorEntityDescription( - key=SENSOR_COMPRESSOR_HOURS_LOADCLASS3, + key="compressor_hours_loadclass3", name="Compressor Hours Load Class 3", icon="mdi:counter", native_unit_of_measurement=TIME_HOURS, value_getter=lambda api: api.getHoursLoadClass3(), ), ViCareSensorEntityDescription( - key=SENSOR_COMPRESSOR_HOURS_LOADCLASS4, + key="compressor_hours_loadclass4", name="Compressor Hours Load Class 4", icon="mdi:counter", native_unit_of_measurement=TIME_HOURS, value_getter=lambda api: api.getHoursLoadClass4(), ), ViCareSensorEntityDescription( - key=SENSOR_COMPRESSOR_HOURS_LOADCLASS5, + key="compressor_hours_loadclass5", name="Compressor Hours Load Class 5", icon="mdi:counter", native_unit_of_measurement=TIME_HOURS, diff --git a/homeassistant/components/vicare/water_heater.py b/homeassistant/components/vicare/water_heater.py index 0107ff8fe4c..8a7169333bf 100644 --- a/homeassistant/components/vicare/water_heater.py +++ b/homeassistant/components/vicare/water_heater.py @@ -56,18 +56,6 @@ HA_TO_VICARE_HVAC_DHW = { } -def _build_entity(name, vicare_api, circuit, device_config, heating_type): - """Create a ViCare water_heater entity.""" - _LOGGER.debug("Found device %s", name) - return ViCareWater( - name, - vicare_api, - circuit, - device_config, - heating_type, - ) - - def _get_circuits(vicare_api): """Return the list of circuits.""" try: @@ -93,7 +81,7 @@ async def async_setup_entry( if len(circuits) > 1: suffix = f" {circuit.id}" - entity = _build_entity( + entity = ViCareWater( f"{name} Water{suffix}", api, circuit,