Use enums in poolsense (#62071)

This commit is contained in:
Robert Hillis 2021-12-16 11:06:16 -05:00 committed by GitHub
parent b28c821bc3
commit ec3efb4b1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 10 deletions

View file

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
from homeassistant.components.binary_sensor import ( from homeassistant.components.binary_sensor import (
DEVICE_CLASS_PROBLEM, BinarySensorDeviceClass,
BinarySensorEntity, BinarySensorEntity,
BinarySensorEntityDescription, BinarySensorEntityDescription,
) )
@ -15,12 +15,12 @@ BINARY_SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
BinarySensorEntityDescription( BinarySensorEntityDescription(
key="pH Status", key="pH Status",
name="pH Status", name="pH Status",
device_class=DEVICE_CLASS_PROBLEM, device_class=BinarySensorDeviceClass.PROBLEM,
), ),
BinarySensorEntityDescription( BinarySensorEntityDescription(
key="Chlorine Status", key="Chlorine Status",
name="Chlorine Status", name="Chlorine Status",
device_class=DEVICE_CLASS_PROBLEM, device_class=BinarySensorDeviceClass.PROBLEM,
), ),
) )

View file

@ -1,12 +1,13 @@
"""Sensor platform for the PoolSense sensor.""" """Sensor platform for the PoolSense sensor."""
from __future__ import annotations from __future__ import annotations
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription from homeassistant.components.sensor import (
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
)
from homeassistant.const import ( from homeassistant.const import (
CONF_EMAIL, CONF_EMAIL,
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_TIMESTAMP,
ELECTRIC_POTENTIAL_MILLIVOLT, ELECTRIC_POTENTIAL_MILLIVOLT,
PERCENTAGE, PERCENTAGE,
TEMP_CELSIUS, TEMP_CELSIUS,
@ -31,20 +32,20 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
key="Battery", key="Battery",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
name="Battery", name="Battery",
device_class=DEVICE_CLASS_BATTERY, device_class=SensorDeviceClass.BATTERY,
), ),
SensorEntityDescription( SensorEntityDescription(
key="Water Temp", key="Water Temp",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=TEMP_CELSIUS,
icon="mdi:coolant-temperature", icon="mdi:coolant-temperature",
name="Temperature", name="Temperature",
device_class=DEVICE_CLASS_TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
), ),
SensorEntityDescription( SensorEntityDescription(
key="Last Seen", key="Last Seen",
icon="mdi:clock", icon="mdi:clock",
name="Last Seen", name="Last Seen",
device_class=DEVICE_CLASS_TIMESTAMP, device_class=SensorDeviceClass.TIMESTAMP,
), ),
SensorEntityDescription( SensorEntityDescription(
key="Chlorine High", key="Chlorine High",