mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Use enums in vicare (#61994)
This commit is contained in:
parent
b1117c17f1
commit
b03ead1c9b
@ -13,7 +13,7 @@ from PyViCare.PyViCareUtils import (
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import (
|
from homeassistant.components.binary_sensor import (
|
||||||
DEVICE_CLASS_POWER,
|
BinarySensorDeviceClass,
|
||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
BinarySensorEntityDescription,
|
BinarySensorEntityDescription,
|
||||||
)
|
)
|
||||||
@ -40,7 +40,7 @@ CIRCUIT_SENSORS: tuple[ViCareBinarySensorEntityDescription, ...] = (
|
|||||||
ViCareBinarySensorEntityDescription(
|
ViCareBinarySensorEntityDescription(
|
||||||
key=SENSOR_CIRCULATION_PUMP_ACTIVE,
|
key=SENSOR_CIRCULATION_PUMP_ACTIVE,
|
||||||
name="Circulation pump active",
|
name="Circulation pump active",
|
||||||
device_class=DEVICE_CLASS_POWER,
|
device_class=BinarySensorDeviceClass.POWER,
|
||||||
value_getter=lambda api: api.getCirculationPumpActive(),
|
value_getter=lambda api: api.getCirculationPumpActive(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -49,7 +49,7 @@ BURNER_SENSORS: tuple[ViCareBinarySensorEntityDescription, ...] = (
|
|||||||
ViCareBinarySensorEntityDescription(
|
ViCareBinarySensorEntityDescription(
|
||||||
key=SENSOR_BURNER_ACTIVE,
|
key=SENSOR_BURNER_ACTIVE,
|
||||||
name="Burner active",
|
name="Burner active",
|
||||||
device_class=DEVICE_CLASS_POWER,
|
device_class=BinarySensorDeviceClass.POWER,
|
||||||
value_getter=lambda api: api.getActive(),
|
value_getter=lambda api: api.getActive(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -58,7 +58,7 @@ COMPRESSOR_SENSORS: tuple[ViCareBinarySensorEntityDescription, ...] = (
|
|||||||
ViCareBinarySensorEntityDescription(
|
ViCareBinarySensorEntityDescription(
|
||||||
key=SENSOR_COMPRESSOR_ACTIVE,
|
key=SENSOR_COMPRESSOR_ACTIVE,
|
||||||
name="Compressor active",
|
name="Compressor active",
|
||||||
device_class=DEVICE_CLASS_POWER,
|
device_class=BinarySensorDeviceClass.POWER,
|
||||||
value_getter=lambda api: api.getActive(),
|
value_getter=lambda api: api.getActive(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -1,13 +1,8 @@
|
|||||||
"""Constants for the ViCare integration."""
|
"""Constants for the ViCare integration."""
|
||||||
import enum
|
import enum
|
||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.components.sensor import SensorDeviceClass
|
||||||
DEVICE_CLASS_ENERGY,
|
from homeassistant.const import ENERGY_KILO_WATT_HOUR, VOLUME_CUBIC_METERS, Platform
|
||||||
DEVICE_CLASS_GAS,
|
|
||||||
ENERGY_KILO_WATT_HOUR,
|
|
||||||
VOLUME_CUBIC_METERS,
|
|
||||||
Platform,
|
|
||||||
)
|
|
||||||
|
|
||||||
DOMAIN = "vicare"
|
DOMAIN = "vicare"
|
||||||
|
|
||||||
@ -31,8 +26,8 @@ VICARE_CUBIC_METER = "cubicMeter"
|
|||||||
VICARE_KWH = "kilowattHour"
|
VICARE_KWH = "kilowattHour"
|
||||||
|
|
||||||
VICARE_UNIT_TO_DEVICE_CLASS = {
|
VICARE_UNIT_TO_DEVICE_CLASS = {
|
||||||
VICARE_KWH: DEVICE_CLASS_ENERGY,
|
VICARE_KWH: SensorDeviceClass.ENERGY,
|
||||||
VICARE_CUBIC_METER: DEVICE_CLASS_GAS,
|
VICARE_CUBIC_METER: SensorDeviceClass.GAS,
|
||||||
}
|
}
|
||||||
|
|
||||||
VICARE_UNIT_TO_UNIT_OF_MEASUREMENT = {
|
VICARE_UNIT_TO_UNIT_OF_MEASUREMENT = {
|
||||||
|
@ -15,16 +15,13 @@ from PyViCare.PyViCareUtils import (
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
STATE_CLASS_MEASUREMENT,
|
SensorDeviceClass,
|
||||||
STATE_CLASS_TOTAL_INCREASING,
|
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
DEVICE_CLASS_ENERGY,
|
|
||||||
DEVICE_CLASS_POWER,
|
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
|
||||||
ENERGY_KILO_WATT_HOUR,
|
ENERGY_KILO_WATT_HOUR,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
POWER_WATT,
|
POWER_WATT,
|
||||||
@ -94,21 +91,21 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
|||||||
name="Outside Temperature",
|
name="Outside Temperature",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
value_getter=lambda api: api.getOutsideTemperature(),
|
value_getter=lambda api: api.getOutsideTemperature(),
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_RETURN_TEMPERATURE,
|
key=SENSOR_RETURN_TEMPERATURE,
|
||||||
name="Return Temperature",
|
name="Return Temperature",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
value_getter=lambda api: api.getReturnTemperature(),
|
value_getter=lambda api: api.getReturnTemperature(),
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_BOILER_TEMPERATURE,
|
key=SENSOR_BOILER_TEMPERATURE,
|
||||||
name="Boiler Temperature",
|
name="Boiler Temperature",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
value_getter=lambda api: api.getBoilerTemperature(),
|
value_getter=lambda api: api.getBoilerTemperature(),
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_DHW_GAS_CONSUMPTION_TODAY,
|
key=SENSOR_DHW_GAS_CONSUMPTION_TODAY,
|
||||||
@ -116,8 +113,8 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
|||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
value_getter=lambda api: api.getGasConsumptionDomesticHotWaterToday(),
|
value_getter=lambda api: api.getGasConsumptionDomesticHotWaterToday(),
|
||||||
unit_getter=lambda api: api.getGasConsumptionDomesticHotWaterUnit(),
|
unit_getter=lambda api: api.getGasConsumptionDomesticHotWaterUnit(),
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_DHW_GAS_CONSUMPTION_THIS_WEEK,
|
key=SENSOR_DHW_GAS_CONSUMPTION_THIS_WEEK,
|
||||||
@ -125,8 +122,8 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
|||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
value_getter=lambda api: api.getGasConsumptionDomesticHotWaterThisWeek(),
|
value_getter=lambda api: api.getGasConsumptionDomesticHotWaterThisWeek(),
|
||||||
unit_getter=lambda api: api.getGasConsumptionDomesticHotWaterUnit(),
|
unit_getter=lambda api: api.getGasConsumptionDomesticHotWaterUnit(),
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_DHW_GAS_CONSUMPTION_THIS_MONTH,
|
key=SENSOR_DHW_GAS_CONSUMPTION_THIS_MONTH,
|
||||||
@ -134,8 +131,8 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
|||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
value_getter=lambda api: api.getGasConsumptionDomesticHotWaterThisMonth(),
|
value_getter=lambda api: api.getGasConsumptionDomesticHotWaterThisMonth(),
|
||||||
unit_getter=lambda api: api.getGasConsumptionDomesticHotWaterUnit(),
|
unit_getter=lambda api: api.getGasConsumptionDomesticHotWaterUnit(),
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_DHW_GAS_CONSUMPTION_THIS_YEAR,
|
key=SENSOR_DHW_GAS_CONSUMPTION_THIS_YEAR,
|
||||||
@ -143,8 +140,8 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
|||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
value_getter=lambda api: api.getGasConsumptionDomesticHotWaterThisYear(),
|
value_getter=lambda api: api.getGasConsumptionDomesticHotWaterThisYear(),
|
||||||
unit_getter=lambda api: api.getGasConsumptionDomesticHotWaterUnit(),
|
unit_getter=lambda api: api.getGasConsumptionDomesticHotWaterUnit(),
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_GAS_CONSUMPTION_TODAY,
|
key=SENSOR_GAS_CONSUMPTION_TODAY,
|
||||||
@ -152,8 +149,8 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
|||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
value_getter=lambda api: api.getGasConsumptionHeatingToday(),
|
value_getter=lambda api: api.getGasConsumptionHeatingToday(),
|
||||||
unit_getter=lambda api: api.getGasConsumptionHeatingUnit(),
|
unit_getter=lambda api: api.getGasConsumptionHeatingUnit(),
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_GAS_CONSUMPTION_THIS_WEEK,
|
key=SENSOR_GAS_CONSUMPTION_THIS_WEEK,
|
||||||
@ -161,8 +158,8 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
|||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
value_getter=lambda api: api.getGasConsumptionHeatingThisWeek(),
|
value_getter=lambda api: api.getGasConsumptionHeatingThisWeek(),
|
||||||
unit_getter=lambda api: api.getGasConsumptionHeatingUnit(),
|
unit_getter=lambda api: api.getGasConsumptionHeatingUnit(),
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_GAS_CONSUMPTION_THIS_MONTH,
|
key=SENSOR_GAS_CONSUMPTION_THIS_MONTH,
|
||||||
@ -170,8 +167,8 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
|||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
value_getter=lambda api: api.getGasConsumptionHeatingThisMonth(),
|
value_getter=lambda api: api.getGasConsumptionHeatingThisMonth(),
|
||||||
unit_getter=lambda api: api.getGasConsumptionHeatingUnit(),
|
unit_getter=lambda api: api.getGasConsumptionHeatingUnit(),
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_GAS_CONSUMPTION_THIS_YEAR,
|
key=SENSOR_GAS_CONSUMPTION_THIS_YEAR,
|
||||||
@ -179,48 +176,48 @@ GLOBAL_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
|||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
value_getter=lambda api: api.getGasConsumptionHeatingThisYear(),
|
value_getter=lambda api: api.getGasConsumptionHeatingThisYear(),
|
||||||
unit_getter=lambda api: api.getGasConsumptionHeatingUnit(),
|
unit_getter=lambda api: api.getGasConsumptionHeatingUnit(),
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_POWER_PRODUCTION_CURRENT,
|
key=SENSOR_POWER_PRODUCTION_CURRENT,
|
||||||
name="Power production current",
|
name="Power production current",
|
||||||
native_unit_of_measurement=POWER_WATT,
|
native_unit_of_measurement=POWER_WATT,
|
||||||
value_getter=lambda api: api.getPowerProductionCurrent(),
|
value_getter=lambda api: api.getPowerProductionCurrent(),
|
||||||
device_class=DEVICE_CLASS_POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_POWER_PRODUCTION_TODAY,
|
key=SENSOR_POWER_PRODUCTION_TODAY,
|
||||||
name="Power production today",
|
name="Power production today",
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
value_getter=lambda api: api.getPowerProductionToday(),
|
value_getter=lambda api: api.getPowerProductionToday(),
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_POWER_PRODUCTION_THIS_WEEK,
|
key=SENSOR_POWER_PRODUCTION_THIS_WEEK,
|
||||||
name="Power production this week",
|
name="Power production this week",
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
value_getter=lambda api: api.getPowerProductionThisWeek(),
|
value_getter=lambda api: api.getPowerProductionThisWeek(),
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_POWER_PRODUCTION_THIS_MONTH,
|
key=SENSOR_POWER_PRODUCTION_THIS_MONTH,
|
||||||
name="Power production this month",
|
name="Power production this month",
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
value_getter=lambda api: api.getPowerProductionThisMonth(),
|
value_getter=lambda api: api.getPowerProductionThisMonth(),
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
ViCareSensorEntityDescription(
|
ViCareSensorEntityDescription(
|
||||||
key=SENSOR_POWER_PRODUCTION_THIS_YEAR,
|
key=SENSOR_POWER_PRODUCTION_THIS_YEAR,
|
||||||
name="Power production this year",
|
name="Power production this year",
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
value_getter=lambda api: api.getPowerProductionThisYear(),
|
value_getter=lambda api: api.getPowerProductionThisYear(),
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user