mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 08:47:10 +00:00
Added device class to speedtestdotnet sensor entities. (#100500)
Added device class to sensor entities.
This commit is contained in:
parent
9931f45532
commit
ddeb2854aa
@ -6,6 +6,7 @@ from dataclasses import dataclass
|
|||||||
from typing import Any, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
|
SensorDeviceClass,
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
@ -45,12 +46,14 @@ SENSOR_TYPES: tuple[SpeedtestSensorEntityDescription, ...] = (
|
|||||||
translation_key="ping",
|
translation_key="ping",
|
||||||
native_unit_of_measurement=UnitOfTime.MILLISECONDS,
|
native_unit_of_measurement=UnitOfTime.MILLISECONDS,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
device_class=SensorDeviceClass.DURATION,
|
||||||
),
|
),
|
||||||
SpeedtestSensorEntityDescription(
|
SpeedtestSensorEntityDescription(
|
||||||
key="download",
|
key="download",
|
||||||
translation_key="download",
|
translation_key="download",
|
||||||
native_unit_of_measurement=UnitOfDataRate.MEGABITS_PER_SECOND,
|
native_unit_of_measurement=UnitOfDataRate.MEGABITS_PER_SECOND,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
device_class=SensorDeviceClass.DATA_RATE,
|
||||||
value=lambda value: round(value / 10**6, 2),
|
value=lambda value: round(value / 10**6, 2),
|
||||||
),
|
),
|
||||||
SpeedtestSensorEntityDescription(
|
SpeedtestSensorEntityDescription(
|
||||||
@ -58,6 +61,7 @@ SENSOR_TYPES: tuple[SpeedtestSensorEntityDescription, ...] = (
|
|||||||
translation_key="upload",
|
translation_key="upload",
|
||||||
native_unit_of_measurement=UnitOfDataRate.MEGABITS_PER_SECOND,
|
native_unit_of_measurement=UnitOfDataRate.MEGABITS_PER_SECOND,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
device_class=SensorDeviceClass.DATA_RATE,
|
||||||
value=lambda value: round(value / 10**6, 2),
|
value=lambda value: round(value / 10**6, 2),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user