Add more vicare binary sensors and clean up constants (#64780)

* Add some binary sensors and clean up constants

* Remove duplicated code
pull/64833/head
Hans Oischinger 2022-01-24 11:16:35 +01:00 committed by GitHub
parent 157f145ea9
commit 201229d20c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 12 deletions

View File

@ -32,12 +32,6 @@ from .const import (
_LOGGER = logging.getLogger(__name__) _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 @dataclass
class ViCareBinarySensorEntityDescription( class ViCareBinarySensorEntityDescription(
@ -48,16 +42,22 @@ class ViCareBinarySensorEntityDescription(
CIRCUIT_SENSORS: tuple[ViCareBinarySensorEntityDescription, ...] = ( CIRCUIT_SENSORS: tuple[ViCareBinarySensorEntityDescription, ...] = (
ViCareBinarySensorEntityDescription( ViCareBinarySensorEntityDescription(
key=SENSOR_CIRCULATION_PUMP_ACTIVE, key="circulationpump_active",
name="Circulation pump active", name="Circulation pump active",
device_class=BinarySensorDeviceClass.POWER, device_class=BinarySensorDeviceClass.POWER,
value_getter=lambda api: api.getCirculationPumpActive(), 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, ...] = ( BURNER_SENSORS: tuple[ViCareBinarySensorEntityDescription, ...] = (
ViCareBinarySensorEntityDescription( ViCareBinarySensorEntityDescription(
key=SENSOR_BURNER_ACTIVE, key="burner_active",
name="Burner active", name="Burner active",
device_class=BinarySensorDeviceClass.POWER, device_class=BinarySensorDeviceClass.POWER,
value_getter=lambda api: api.getActive(), value_getter=lambda api: api.getActive(),
@ -66,7 +66,7 @@ BURNER_SENSORS: tuple[ViCareBinarySensorEntityDescription, ...] = (
COMPRESSOR_SENSORS: tuple[ViCareBinarySensorEntityDescription, ...] = ( COMPRESSOR_SENSORS: tuple[ViCareBinarySensorEntityDescription, ...] = (
ViCareBinarySensorEntityDescription( ViCareBinarySensorEntityDescription(
key=SENSOR_COMPRESSOR_ACTIVE, key="compressor_active",
name="Compressor active", name="Compressor active",
device_class=BinarySensorDeviceClass.POWER, device_class=BinarySensorDeviceClass.POWER,
value_getter=lambda api: api.getActive(), value_getter=lambda api: api.getActive(),
@ -75,17 +75,29 @@ COMPRESSOR_SENSORS: tuple[ViCareBinarySensorEntityDescription, ...] = (
GLOBAL_SENSORS: tuple[ViCareBinarySensorEntityDescription, ...] = ( GLOBAL_SENSORS: tuple[ViCareBinarySensorEntityDescription, ...] = (
ViCareBinarySensorEntityDescription( ViCareBinarySensorEntityDescription(
key=SENSOR_SOLAR_PUMP_ACTIVE, key="solar_pump_active",
name="Solar pump active", name="Solar pump active",
device_class=BinarySensorDeviceClass.POWER, device_class=BinarySensorDeviceClass.POWER,
value_getter=lambda api: api.getSolarPumpActive(), value_getter=lambda api: api.getSolarPumpActive(),
), ),
ViCareBinarySensorEntityDescription( ViCareBinarySensorEntityDescription(
key=SENSOR_CHARGING_ACTIVE, key="charging_active",
name="Domestic Hot Water Charging active", name="DHW Charging active",
device_class=BinarySensorDeviceClass.RUNNING, device_class=BinarySensorDeviceClass.RUNNING,
value_getter=lambda api: api.getDomesticHotWaterChargingActive(), 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(),
),
) )