mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use device class enum instead of string (#82935)
This commit is contained in:
parent
2d7701cab5
commit
a69e0defe6
@ -206,7 +206,7 @@ SENSOR_TYPES: tuple[RingSensorEntityDescription, ...] = (
|
|||||||
name="Battery",
|
name="Battery",
|
||||||
category=["doorbots", "authorized_doorbots", "stickup_cams"],
|
category=["doorbots", "authorized_doorbots", "stickup_cams"],
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
device_class="battery",
|
device_class=SensorDeviceClass.BATTERY,
|
||||||
cls=RingSensor,
|
cls=RingSensor,
|
||||||
),
|
),
|
||||||
RingSensorEntityDescription(
|
RingSensorEntityDescription(
|
||||||
@ -255,7 +255,7 @@ SENSOR_TYPES: tuple[RingSensorEntityDescription, ...] = (
|
|||||||
category=["chimes", "doorbots", "authorized_doorbots", "stickup_cams"],
|
category=["chimes", "doorbots", "authorized_doorbots", "stickup_cams"],
|
||||||
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||||
icon="mdi:wifi",
|
icon="mdi:wifi",
|
||||||
device_class="signal_strength",
|
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
|
||||||
cls=HealthDataRingSensor,
|
cls=HealthDataRingSensor,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -5,7 +5,11 @@ import logging
|
|||||||
|
|
||||||
import voluptuous as vol
|
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.const import CONF_NAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
@ -32,7 +36,6 @@ from . import (
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_DEVICE_CLASS = "power"
|
|
||||||
DEFAULT_NAME = "Vultr {}"
|
DEFAULT_NAME = "Vultr {}"
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
{
|
{
|
||||||
@ -64,7 +67,7 @@ def setup_platform(
|
|||||||
class VultrBinarySensor(BinarySensorEntity):
|
class VultrBinarySensor(BinarySensorEntity):
|
||||||
"""Representation of a Vultr subscription sensor."""
|
"""Representation of a Vultr subscription sensor."""
|
||||||
|
|
||||||
_attr_device_class = DEFAULT_DEVICE_CLASS
|
_attr_device_class = BinarySensorDeviceClass.POWER
|
||||||
|
|
||||||
def __init__(self, vultr, subscription, name):
|
def __init__(self, vultr, subscription, name):
|
||||||
"""Initialize a new Vultr binary sensor."""
|
"""Initialize a new Vultr binary sensor."""
|
||||||
|
@ -47,7 +47,7 @@ SENSOR_TYPES: dict[str, SensorEntityDescription] = {
|
|||||||
),
|
),
|
||||||
SENSOR_MOISTURE: SensorEntityDescription(
|
SENSOR_MOISTURE: SensorEntityDescription(
|
||||||
key=SENSOR_MOISTURE,
|
key=SENSOR_MOISTURE,
|
||||||
device_class=SENSOR_MOISTURE,
|
device_class=SensorDeviceClass.MOISTURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SENSOR_LIGHT: SensorEntityDescription(
|
SENSOR_LIGHT: SensorEntityDescription(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user