mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Add vicare solar collector and pump information (#64178)
* Added solar collector and pump information * moved sensors to GLOBAL_SENSORS
This commit is contained in:
parent
144371d843
commit
4715163150
@ -35,6 +35,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
SENSOR_CIRCULATION_PUMP_ACTIVE = "circulationpump_active"
|
SENSOR_CIRCULATION_PUMP_ACTIVE = "circulationpump_active"
|
||||||
SENSOR_BURNER_ACTIVE = "burner_active"
|
SENSOR_BURNER_ACTIVE = "burner_active"
|
||||||
SENSOR_COMPRESSOR_ACTIVE = "compressor_active"
|
SENSOR_COMPRESSOR_ACTIVE = "compressor_active"
|
||||||
|
SENSOR_SOLAR_PUMP_ACTIVE = "solar_pump_active"
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -71,6 +72,15 @@ COMPRESSOR_SENSORS: tuple[ViCareBinarySensorEntityDescription, ...] = (
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
GLOBAL_SENSORS: tuple[ViCareBinarySensorEntityDescription, ...] = (
|
||||||
|
ViCareBinarySensorEntityDescription(
|
||||||
|
key=SENSOR_SOLAR_PUMP_ACTIVE,
|
||||||
|
name="Solar pump active",
|
||||||
|
device_class=BinarySensorDeviceClass.POWER,
|
||||||
|
value_getter=lambda api: api.getSolarPumpActive(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _build_entity(name, vicare_api, device_config, sensor):
|
def _build_entity(name, vicare_api, device_config, sensor):
|
||||||
"""Create a ViCare binary sensor entity."""
|
"""Create a ViCare binary sensor entity."""
|
||||||
@ -123,6 +133,17 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
entities = []
|
entities = []
|
||||||
|
|
||||||
|
for description in GLOBAL_SENSORS:
|
||||||
|
entity = await hass.async_add_executor_job(
|
||||||
|
_build_entity,
|
||||||
|
f"{name} {description.name}",
|
||||||
|
api,
|
||||||
|
hass.data[DOMAIN][config_entry.entry_id][VICARE_DEVICE_CONFIG],
|
||||||
|
description,
|
||||||
|
)
|
||||||
|
if entity is not None:
|
||||||
|
entities.append(entity)
|
||||||
|
|
||||||
for description in CIRCUIT_SENSORS:
|
for description in CIRCUIT_SENSORS:
|
||||||
for circuit in hass.data[DOMAIN][config_entry.entry_id][VICARE_CIRCUITS]:
|
for circuit in hass.data[DOMAIN][config_entry.entry_id][VICARE_CIRCUITS]:
|
||||||
suffix = ""
|
suffix = ""
|
||||||
|
@ -79,6 +79,11 @@ SENSOR_POWER_PRODUCTION_THIS_WEEK = "power_production_this_week"
|
|||||||
SENSOR_POWER_PRODUCTION_THIS_MONTH = "power_production_this_month"
|
SENSOR_POWER_PRODUCTION_THIS_MONTH = "power_production_this_month"
|
||||||
SENSOR_POWER_PRODUCTION_THIS_YEAR = "power_production_this_year"
|
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):
|
||||||
@ -221,6 +226,28 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
|||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
|
ViCareSensorEntityDescription(
|
||||||
|
key=SENSOR_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,
|
||||||
|
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,
|
||||||
|
name="Solar Power Production",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
value_getter=lambda api: api.getSolarPowerProduction(),
|
||||||
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
CIRCUIT_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
CIRCUIT_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user