Use DataRate unit and device class in integrations (#83610)
This commit is contained in:
parent
3970da0ad3
commit
535aba10ee
21 changed files with 132 additions and 111 deletions
|
@ -6,12 +6,13 @@ from dataclasses import dataclass
|
|||
from typing import Any
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
SensorEntityDescription,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import DATA_RATE_KILOBYTES_PER_SECOND, STATE_IDLE, Platform
|
||||
from homeassistant.const import STATE_IDLE, Platform, UnitOfDataRate
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_platform
|
||||
from homeassistant.helpers.typing import StateType
|
||||
|
@ -53,14 +54,16 @@ SENSOR_TYPES: tuple[DelugeSensorEntityDescription, ...] = (
|
|||
DelugeSensorEntityDescription(
|
||||
key=DOWNLOAD_SPEED,
|
||||
name="Down speed",
|
||||
native_unit_of_measurement=DATA_RATE_KILOBYTES_PER_SECOND,
|
||||
device_class=SensorDeviceClass.DATA_RATE,
|
||||
native_unit_of_measurement=UnitOfDataRate.KILOBYTES_PER_SECOND,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value=lambda data: get_state(data, DOWNLOAD_SPEED),
|
||||
),
|
||||
DelugeSensorEntityDescription(
|
||||
key=UPLOAD_SPEED,
|
||||
name="Up speed",
|
||||
native_unit_of_measurement=DATA_RATE_KILOBYTES_PER_SECOND,
|
||||
device_class=SensorDeviceClass.DATA_RATE,
|
||||
native_unit_of_measurement=UnitOfDataRate.KILOBYTES_PER_SECOND,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value=lambda data: get_state(data, UPLOAD_SPEED),
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue