Added device class to speedtestdotnet sensor entities. (#100500)

Added device class to sensor entities.
pull/100503/head^2
Dennis 2023-09-17 00:40:16 +02:00 committed by GitHub
parent 9931f45532
commit ddeb2854aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -6,6 +6,7 @@ from dataclasses import dataclass
from typing import Any, cast
from homeassistant.components.sensor import (
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
SensorStateClass,
@ -45,12 +46,14 @@ SENSOR_TYPES: tuple[SpeedtestSensorEntityDescription, ...] = (
translation_key="ping",
native_unit_of_measurement=UnitOfTime.MILLISECONDS,
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.DURATION,
),
SpeedtestSensorEntityDescription(
key="download",
translation_key="download",
native_unit_of_measurement=UnitOfDataRate.MEGABITS_PER_SECOND,
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.DATA_RATE,
value=lambda value: round(value / 10**6, 2),
),
SpeedtestSensorEntityDescription(
@ -58,6 +61,7 @@ SENSOR_TYPES: tuple[SpeedtestSensorEntityDescription, ...] = (
translation_key="upload",
native_unit_of_measurement=UnitOfDataRate.MEGABITS_PER_SECOND,
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.DATA_RATE,
value=lambda value: round(value / 10**6, 2),
),
)