Clean up vicare code (#65774)
* Clean up vicare code Remove constants that were only used once Remove _build_entity and use constructor directly * Fix copy/paste issue
This commit is contained in:
parent
9f8c0685e3
commit
99fd16d675
3 changed files with 33 additions and 91 deletions
|
@ -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):
|
def _get_circuits(vicare_api):
|
||||||
"""Return the list of circuits."""
|
"""Return the list of circuits."""
|
||||||
try:
|
try:
|
||||||
|
@ -126,11 +120,11 @@ async def async_setup_entry(
|
||||||
if len(circuits) > 1:
|
if len(circuits) > 1:
|
||||||
suffix = f" {circuit.id}"
|
suffix = f" {circuit.id}"
|
||||||
|
|
||||||
entity = _build_entity(
|
entity = ViCareClimate(
|
||||||
f"{name} Heating{suffix}",
|
f"{name} Heating{suffix}",
|
||||||
api,
|
api,
|
||||||
hass.data[DOMAIN][config_entry.entry_id][VICARE_DEVICE_CONFIG],
|
|
||||||
circuit,
|
circuit,
|
||||||
|
hass.data[DOMAIN][config_entry.entry_id][VICARE_DEVICE_CONFIG],
|
||||||
config_entry.data[CONF_HEATING_TYPE],
|
config_entry.data[CONF_HEATING_TYPE],
|
||||||
)
|
)
|
||||||
entities.append(entity)
|
entities.append(entity)
|
||||||
|
|
|
@ -43,46 +43,6 @@ from .const import (
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_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
|
@dataclass
|
||||||
class ViCareSensorEntityDescription(SensorEntityDescription, ViCareRequiredKeysMixin):
|
class ViCareSensorEntityDescription(SensorEntityDescription, ViCareRequiredKeysMixin):
|
||||||
|
@ -93,84 +53,84 @@ class ViCareSensorEntityDescription(SensorEntityDescription, ViCareRequiredKeysM
|
||||||
|
|
||||||
GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_OUTSIDE_TEMPERATURE,
|
key="outside_temperature",
|
||||||
name="Outside Temperature",
|
name="Outside Temperature",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
value_getter=lambda api: api.getOutsideTemperature(),
|
value_getter=lambda api: api.getOutsideTemperature(),
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_RETURN_TEMPERATURE,
|
key="return_temperature",
|
||||||
name="Return Temperature",
|
name="Return Temperature",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
value_getter=lambda api: api.getReturnTemperature(),
|
value_getter=lambda api: api.getReturnTemperature(),
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_BOILER_TEMPERATURE,
|
key="boiler_temperature",
|
||||||
name="Boiler Temperature",
|
name="Boiler Temperature",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
value_getter=lambda api: api.getBoilerTemperature(),
|
value_getter=lambda api: api.getBoilerTemperature(),
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_DHW_GAS_CONSUMPTION_TODAY,
|
key="hotwater_gas_consumption_today",
|
||||||
name="Hot water gas consumption today",
|
name="Hot water gas consumption today",
|
||||||
value_getter=lambda api: api.getGasConsumptionDomesticHotWaterToday(),
|
value_getter=lambda api: api.getGasConsumptionDomesticHotWaterToday(),
|
||||||
unit_getter=lambda api: api.getGasConsumptionDomesticHotWaterUnit(),
|
unit_getter=lambda api: api.getGasConsumptionDomesticHotWaterUnit(),
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_DHW_GAS_CONSUMPTION_THIS_WEEK,
|
key="hotwater_gas_consumption_heating_this_week",
|
||||||
name="Hot water gas consumption this week",
|
name="Hot water gas consumption this week",
|
||||||
value_getter=lambda api: api.getGasConsumptionDomesticHotWaterThisWeek(),
|
value_getter=lambda api: api.getGasConsumptionDomesticHotWaterThisWeek(),
|
||||||
unit_getter=lambda api: api.getGasConsumptionDomesticHotWaterUnit(),
|
unit_getter=lambda api: api.getGasConsumptionDomesticHotWaterUnit(),
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_DHW_GAS_CONSUMPTION_THIS_MONTH,
|
key="hotwater_gas_consumption_heating_this_month",
|
||||||
name="Hot water gas consumption this month",
|
name="Hot water gas consumption this month",
|
||||||
value_getter=lambda api: api.getGasConsumptionDomesticHotWaterThisMonth(),
|
value_getter=lambda api: api.getGasConsumptionDomesticHotWaterThisMonth(),
|
||||||
unit_getter=lambda api: api.getGasConsumptionDomesticHotWaterUnit(),
|
unit_getter=lambda api: api.getGasConsumptionDomesticHotWaterUnit(),
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_DHW_GAS_CONSUMPTION_THIS_YEAR,
|
key="hotwater_gas_consumption_heating_this_year",
|
||||||
name="Hot water gas consumption this year",
|
name="Hot water gas consumption this year",
|
||||||
value_getter=lambda api: api.getGasConsumptionDomesticHotWaterThisYear(),
|
value_getter=lambda api: api.getGasConsumptionDomesticHotWaterThisYear(),
|
||||||
unit_getter=lambda api: api.getGasConsumptionDomesticHotWaterUnit(),
|
unit_getter=lambda api: api.getGasConsumptionDomesticHotWaterUnit(),
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_GAS_CONSUMPTION_TODAY,
|
key="gas_consumption_heating_today",
|
||||||
name="Heating gas consumption today",
|
name="Heating gas consumption today",
|
||||||
value_getter=lambda api: api.getGasConsumptionHeatingToday(),
|
value_getter=lambda api: api.getGasConsumptionHeatingToday(),
|
||||||
unit_getter=lambda api: api.getGasConsumptionHeatingUnit(),
|
unit_getter=lambda api: api.getGasConsumptionHeatingUnit(),
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_GAS_CONSUMPTION_THIS_WEEK,
|
key="gas_consumption_heating_this_week",
|
||||||
name="Heating gas consumption this week",
|
name="Heating gas consumption this week",
|
||||||
value_getter=lambda api: api.getGasConsumptionHeatingThisWeek(),
|
value_getter=lambda api: api.getGasConsumptionHeatingThisWeek(),
|
||||||
unit_getter=lambda api: api.getGasConsumptionHeatingUnit(),
|
unit_getter=lambda api: api.getGasConsumptionHeatingUnit(),
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_GAS_CONSUMPTION_THIS_MONTH,
|
key="gas_consumption_heating_this_month",
|
||||||
name="Heating gas consumption this month",
|
name="Heating gas consumption this month",
|
||||||
value_getter=lambda api: api.getGasConsumptionHeatingThisMonth(),
|
value_getter=lambda api: api.getGasConsumptionHeatingThisMonth(),
|
||||||
unit_getter=lambda api: api.getGasConsumptionHeatingUnit(),
|
unit_getter=lambda api: api.getGasConsumptionHeatingUnit(),
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_GAS_CONSUMPTION_THIS_YEAR,
|
key="gas_consumption_heating_this_year",
|
||||||
name="Heating gas consumption this year",
|
name="Heating gas consumption this year",
|
||||||
value_getter=lambda api: api.getGasConsumptionHeatingThisYear(),
|
value_getter=lambda api: api.getGasConsumptionHeatingThisYear(),
|
||||||
unit_getter=lambda api: api.getGasConsumptionHeatingUnit(),
|
unit_getter=lambda api: api.getGasConsumptionHeatingUnit(),
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_POWER_PRODUCTION_CURRENT,
|
key="power_production_current",
|
||||||
name="Power production current",
|
name="Power production current",
|
||||||
native_unit_of_measurement=POWER_WATT,
|
native_unit_of_measurement=POWER_WATT,
|
||||||
value_getter=lambda api: api.getPowerProductionCurrent(),
|
value_getter=lambda api: api.getPowerProductionCurrent(),
|
||||||
|
@ -178,7 +138,7 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_POWER_PRODUCTION_TODAY,
|
key="power_production_today",
|
||||||
name="Power production today",
|
name="Power production today",
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
value_getter=lambda api: api.getPowerProductionToday(),
|
value_getter=lambda api: api.getPowerProductionToday(),
|
||||||
|
@ -186,7 +146,7 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_POWER_PRODUCTION_THIS_WEEK,
|
key="power_production_this_week",
|
||||||
name="Power production this week",
|
name="Power production this week",
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
value_getter=lambda api: api.getPowerProductionThisWeek(),
|
value_getter=lambda api: api.getPowerProductionThisWeek(),
|
||||||
|
@ -194,7 +154,7 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_POWER_PRODUCTION_THIS_MONTH,
|
key="power_production_this_month",
|
||||||
name="Power production this month",
|
name="Power production this month",
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
value_getter=lambda api: api.getPowerProductionThisMonth(),
|
value_getter=lambda api: api.getPowerProductionThisMonth(),
|
||||||
|
@ -202,7 +162,7 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_POWER_PRODUCTION_THIS_YEAR,
|
key="power_production_this_year",
|
||||||
name="Power production this year",
|
name="Power production this year",
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
value_getter=lambda api: api.getPowerProductionThisYear(),
|
value_getter=lambda api: api.getPowerProductionThisYear(),
|
||||||
|
@ -210,21 +170,21 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_SOLAR_STORAGE_TEMPERATURE,
|
key="solar storage temperature",
|
||||||
name="Solar Storage Temperature",
|
name="Solar Storage Temperature",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
value_getter=lambda api: api.getSolarStorageTemperature(),
|
value_getter=lambda api: api.getSolarStorageTemperature(),
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_COLLECTOR_TEMPERATURE,
|
key="collector temperature",
|
||||||
name="Solar Collector Temperature",
|
name="Solar Collector Temperature",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
value_getter=lambda api: api.getSolarCollectorTemperature(),
|
value_getter=lambda api: api.getSolarCollectorTemperature(),
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_SOLAR_POWER_PRODUCTION,
|
key="solar power production",
|
||||||
name="Solar Power Production",
|
name="Solar Power Production",
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
value_getter=lambda api: api.getSolarPowerProduction(),
|
value_getter=lambda api: api.getSolarPowerProduction(),
|
||||||
|
@ -235,7 +195,7 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
||||||
|
|
||||||
CIRCUIT_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
CIRCUIT_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_SUPPLY_TEMPERATURE,
|
key="supply_temperature",
|
||||||
name="Supply Temperature",
|
name="Supply Temperature",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
value_getter=lambda api: api.getSupplyTemperature(),
|
value_getter=lambda api: api.getSupplyTemperature(),
|
||||||
|
@ -244,20 +204,20 @@ CIRCUIT_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
||||||
|
|
||||||
BURNER_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
BURNER_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_BURNER_STARTS,
|
key="burner_starts",
|
||||||
name="Burner Starts",
|
name="Burner Starts",
|
||||||
icon="mdi:counter",
|
icon="mdi:counter",
|
||||||
value_getter=lambda api: api.getStarts(),
|
value_getter=lambda api: api.getStarts(),
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_BURNER_HOURS,
|
key="burner_hours",
|
||||||
name="Burner Hours",
|
name="Burner Hours",
|
||||||
icon="mdi:counter",
|
icon="mdi:counter",
|
||||||
native_unit_of_measurement=TIME_HOURS,
|
native_unit_of_measurement=TIME_HOURS,
|
||||||
value_getter=lambda api: api.getHours(),
|
value_getter=lambda api: api.getHours(),
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_BURNER_MODULATION,
|
key="burner_modulation",
|
||||||
name="Burner Modulation",
|
name="Burner Modulation",
|
||||||
icon="mdi:percent",
|
icon="mdi:percent",
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
|
@ -267,48 +227,48 @@ BURNER_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
||||||
|
|
||||||
COMPRESSOR_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
COMPRESSOR_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_COMPRESSOR_STARTS,
|
key="compressor_starts",
|
||||||
name="Compressor Starts",
|
name="Compressor Starts",
|
||||||
icon="mdi:counter",
|
icon="mdi:counter",
|
||||||
value_getter=lambda api: api.getStarts(),
|
value_getter=lambda api: api.getStarts(),
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_COMPRESSOR_HOURS,
|
key="compressor_hours",
|
||||||
name="Compressor Hours",
|
name="Compressor Hours",
|
||||||
icon="mdi:counter",
|
icon="mdi:counter",
|
||||||
native_unit_of_measurement=TIME_HOURS,
|
native_unit_of_measurement=TIME_HOURS,
|
||||||
value_getter=lambda api: api.getHours(),
|
value_getter=lambda api: api.getHours(),
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_COMPRESSOR_HOURS_LOADCLASS1,
|
key="compressor_hours_loadclass1",
|
||||||
name="Compressor Hours Load Class 1",
|
name="Compressor Hours Load Class 1",
|
||||||
icon="mdi:counter",
|
icon="mdi:counter",
|
||||||
native_unit_of_measurement=TIME_HOURS,
|
native_unit_of_measurement=TIME_HOURS,
|
||||||
value_getter=lambda api: api.getHoursLoadClass1(),
|
value_getter=lambda api: api.getHoursLoadClass1(),
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_COMPRESSOR_HOURS_LOADCLASS2,
|
key="compressor_hours_loadclass2",
|
||||||
name="Compressor Hours Load Class 2",
|
name="Compressor Hours Load Class 2",
|
||||||
icon="mdi:counter",
|
icon="mdi:counter",
|
||||||
native_unit_of_measurement=TIME_HOURS,
|
native_unit_of_measurement=TIME_HOURS,
|
||||||
value_getter=lambda api: api.getHoursLoadClass2(),
|
value_getter=lambda api: api.getHoursLoadClass2(),
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_COMPRESSOR_HOURS_LOADCLASS3,
|
key="compressor_hours_loadclass3",
|
||||||
name="Compressor Hours Load Class 3",
|
name="Compressor Hours Load Class 3",
|
||||||
icon="mdi:counter",
|
icon="mdi:counter",
|
||||||
native_unit_of_measurement=TIME_HOURS,
|
native_unit_of_measurement=TIME_HOURS,
|
||||||
value_getter=lambda api: api.getHoursLoadClass3(),
|
value_getter=lambda api: api.getHoursLoadClass3(),
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_COMPRESSOR_HOURS_LOADCLASS4,
|
key="compressor_hours_loadclass4",
|
||||||
name="Compressor Hours Load Class 4",
|
name="Compressor Hours Load Class 4",
|
||||||
icon="mdi:counter",
|
icon="mdi:counter",
|
||||||
native_unit_of_measurement=TIME_HOURS,
|
native_unit_of_measurement=TIME_HOURS,
|
||||||
value_getter=lambda api: api.getHoursLoadClass4(),
|
value_getter=lambda api: api.getHoursLoadClass4(),
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_COMPRESSOR_HOURS_LOADCLASS5,
|
key="compressor_hours_loadclass5",
|
||||||
name="Compressor Hours Load Class 5",
|
name="Compressor Hours Load Class 5",
|
||||||
icon="mdi:counter",
|
icon="mdi:counter",
|
||||||
native_unit_of_measurement=TIME_HOURS,
|
native_unit_of_measurement=TIME_HOURS,
|
||||||
|
|
|
@ -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):
|
def _get_circuits(vicare_api):
|
||||||
"""Return the list of circuits."""
|
"""Return the list of circuits."""
|
||||||
try:
|
try:
|
||||||
|
@ -93,7 +81,7 @@ async def async_setup_entry(
|
||||||
if len(circuits) > 1:
|
if len(circuits) > 1:
|
||||||
suffix = f" {circuit.id}"
|
suffix = f" {circuit.id}"
|
||||||
|
|
||||||
entity = _build_entity(
|
entity = ViCareWater(
|
||||||
f"{name} Water{suffix}",
|
f"{name} Water{suffix}",
|
||||||
api,
|
api,
|
||||||
circuit,
|
circuit,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue