Use device class enum instead of string (#82935)

This commit is contained in:
Franck Nijhof 2022-11-29 16:40:59 +01:00 committed by GitHub
parent 2d7701cab5
commit a69e0defe6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View file

@ -206,7 +206,7 @@ SENSOR_TYPES: tuple[RingSensorEntityDescription, ...] = (
name="Battery",
category=["doorbots", "authorized_doorbots", "stickup_cams"],
native_unit_of_measurement=PERCENTAGE,
device_class="battery",
device_class=SensorDeviceClass.BATTERY,
cls=RingSensor,
),
RingSensorEntityDescription(
@ -255,7 +255,7 @@ SENSOR_TYPES: tuple[RingSensorEntityDescription, ...] = (
category=["chimes", "doorbots", "authorized_doorbots", "stickup_cams"],
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
icon="mdi:wifi",
device_class="signal_strength",
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
cls=HealthDataRingSensor,
),
)

View file

@ -5,7 +5,11 @@ import logging
import voluptuous as vol
from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorEntity
from homeassistant.components.binary_sensor import (
PLATFORM_SCHEMA,
BinarySensorDeviceClass,
BinarySensorEntity,
)
from homeassistant.const import CONF_NAME
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
@ -32,7 +36,6 @@ from . import (
_LOGGER = logging.getLogger(__name__)
DEFAULT_DEVICE_CLASS = "power"
DEFAULT_NAME = "Vultr {}"
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
@ -64,7 +67,7 @@ def setup_platform(
class VultrBinarySensor(BinarySensorEntity):
"""Representation of a Vultr subscription sensor."""
_attr_device_class = DEFAULT_DEVICE_CLASS
_attr_device_class = BinarySensorDeviceClass.POWER
def __init__(self, vultr, subscription, name):
"""Initialize a new Vultr binary sensor."""

View file

@ -47,7 +47,7 @@ SENSOR_TYPES: dict[str, SensorEntityDescription] = {
),
SENSOR_MOISTURE: SensorEntityDescription(
key=SENSOR_MOISTURE,
device_class=SENSOR_MOISTURE,
device_class=SensorDeviceClass.MOISTURE,
state_class=SensorStateClass.MEASUREMENT,
),
SENSOR_LIGHT: SensorEntityDescription(