From 201229d20cb16bf24d25098465267480a02fd491 Mon Sep 17 00:00:00 2001 From: Hans Oischinger Date: Mon, 24 Jan 2022 11:16:35 +0100 Subject: [PATCH] Add more vicare binary sensors and clean up constants (#64780) * Add some binary sensors and clean up constants * Remove duplicated code --- .../components/vicare/binary_sensor.py | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/vicare/binary_sensor.py b/homeassistant/components/vicare/binary_sensor.py index c96b3b819b3..133c7307d61 100644 --- a/homeassistant/components/vicare/binary_sensor.py +++ b/homeassistant/components/vicare/binary_sensor.py @@ -32,12 +32,6 @@ from .const import ( _LOGGER = logging.getLogger(__name__) -SENSOR_CIRCULATION_PUMP_ACTIVE = "circulationpump_active" -SENSOR_BURNER_ACTIVE = "burner_active" -SENSOR_CHARGING_ACTIVE = "charging_active" -SENSOR_COMPRESSOR_ACTIVE = "compressor_active" -SENSOR_SOLAR_PUMP_ACTIVE = "solar_pump_active" - @dataclass class ViCareBinarySensorEntityDescription( @@ -48,16 +42,22 @@ class ViCareBinarySensorEntityDescription( CIRCUIT_SENSORS: tuple[ViCareBinarySensorEntityDescription, ...] = ( ViCareBinarySensorEntityDescription( - key=SENSOR_CIRCULATION_PUMP_ACTIVE, + key="circulationpump_active", name="Circulation pump active", device_class=BinarySensorDeviceClass.POWER, value_getter=lambda api: api.getCirculationPumpActive(), ), + ViCareBinarySensorEntityDescription( + key="frost_protection_active", + name="Frost protection active", + device_class=BinarySensorDeviceClass.POWER, + value_getter=lambda api: api.getFrostProtectionActive(), + ), ) BURNER_SENSORS: tuple[ViCareBinarySensorEntityDescription, ...] = ( ViCareBinarySensorEntityDescription( - key=SENSOR_BURNER_ACTIVE, + key="burner_active", name="Burner active", device_class=BinarySensorDeviceClass.POWER, value_getter=lambda api: api.getActive(), @@ -66,7 +66,7 @@ BURNER_SENSORS: tuple[ViCareBinarySensorEntityDescription, ...] = ( COMPRESSOR_SENSORS: tuple[ViCareBinarySensorEntityDescription, ...] = ( ViCareBinarySensorEntityDescription( - key=SENSOR_COMPRESSOR_ACTIVE, + key="compressor_active", name="Compressor active", device_class=BinarySensorDeviceClass.POWER, value_getter=lambda api: api.getActive(), @@ -75,17 +75,29 @@ COMPRESSOR_SENSORS: tuple[ViCareBinarySensorEntityDescription, ...] = ( GLOBAL_SENSORS: tuple[ViCareBinarySensorEntityDescription, ...] = ( ViCareBinarySensorEntityDescription( - key=SENSOR_SOLAR_PUMP_ACTIVE, + key="solar_pump_active", name="Solar pump active", device_class=BinarySensorDeviceClass.POWER, value_getter=lambda api: api.getSolarPumpActive(), ), ViCareBinarySensorEntityDescription( - key=SENSOR_CHARGING_ACTIVE, - name="Domestic Hot Water Charging active", + key="charging_active", + name="DHW Charging active", device_class=BinarySensorDeviceClass.RUNNING, value_getter=lambda api: api.getDomesticHotWaterChargingActive(), ), + ViCareBinarySensorEntityDescription( + key="dhw_circulationpump_active", + name="DHW Circulation Pump Active", + device_class=BinarySensorDeviceClass.POWER, + value_getter=lambda api: api.getDomesticHotWaterCirculationPumpActive(), + ), + ViCareBinarySensorEntityDescription( + key="dhw_pump_active", + name="DHW Pump Active", + device_class=BinarySensorDeviceClass.POWER, + value_getter=lambda api: api.getDomesticHotWaterPumpActive(), + ), )