Add vicare solar collector and pump information (#64178)

* Added solar collector and pump information

* moved sensors to GLOBAL_SENSORS
This commit is contained in:
Bernhard Hecker 2022-01-20 14:21:48 +01:00 committed by GitHub
parent 144371d843
commit 4715163150
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 0 deletions

View File

@ -35,6 +35,7 @@ _LOGGER = logging.getLogger(__name__)
SENSOR_CIRCULATION_PUMP_ACTIVE = "circulationpump_active"
SENSOR_BURNER_ACTIVE = "burner_active"
SENSOR_COMPRESSOR_ACTIVE = "compressor_active"
SENSOR_SOLAR_PUMP_ACTIVE = "solar_pump_active"
@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):
"""Create a ViCare binary sensor entity."""
@ -123,6 +133,17 @@ async def async_setup_entry(
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 circuit in hass.data[DOMAIN][config_entry.entry_id][VICARE_CIRCUITS]:
suffix = ""

View File

@ -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_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):
@ -221,6 +226,28 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
device_class=SensorDeviceClass.ENERGY,
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, ...] = (