diff --git a/homeassistant/components/vicare/binary_sensor.py b/homeassistant/components/vicare/binary_sensor.py index 8751804b8e4..f167b11f72d 100644 --- a/homeassistant/components/vicare/binary_sensor.py +++ b/homeassistant/components/vicare/binary_sensor.py @@ -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 = "" diff --git a/homeassistant/components/vicare/sensor.py b/homeassistant/components/vicare/sensor.py index 2b16810a621..9ff94c455a7 100644 --- a/homeassistant/components/vicare/sensor.py +++ b/homeassistant/components/vicare/sensor.py @@ -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, ...] = (