mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 10:47:10 +00:00
Use new enums in speedtestdotnet (#62405)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
8bd03d520b
commit
5251c1b934
@ -5,10 +5,7 @@ from collections.abc import Callable
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Final
|
from typing import Final
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import SensorEntityDescription, SensorStateClass
|
||||||
STATE_CLASS_MEASUREMENT,
|
|
||||||
SensorEntityDescription,
|
|
||||||
)
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
DATA_RATE_MEGABITS_PER_SECOND,
|
DATA_RATE_MEGABITS_PER_SECOND,
|
||||||
TIME_MILLISECONDS,
|
TIME_MILLISECONDS,
|
||||||
@ -32,20 +29,20 @@ SENSOR_TYPES: Final[tuple[SpeedtestSensorEntityDescription, ...]] = (
|
|||||||
key="ping",
|
key="ping",
|
||||||
name="Ping",
|
name="Ping",
|
||||||
native_unit_of_measurement=TIME_MILLISECONDS,
|
native_unit_of_measurement=TIME_MILLISECONDS,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SpeedtestSensorEntityDescription(
|
SpeedtestSensorEntityDescription(
|
||||||
key="download",
|
key="download",
|
||||||
name="Download",
|
name="Download",
|
||||||
native_unit_of_measurement=DATA_RATE_MEGABITS_PER_SECOND,
|
native_unit_of_measurement=DATA_RATE_MEGABITS_PER_SECOND,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
value=lambda value: round(value / 10 ** 6, 2),
|
value=lambda value: round(value / 10 ** 6, 2),
|
||||||
),
|
),
|
||||||
SpeedtestSensorEntityDescription(
|
SpeedtestSensorEntityDescription(
|
||||||
key="upload",
|
key="upload",
|
||||||
name="Upload",
|
name="Upload",
|
||||||
native_unit_of_measurement=DATA_RATE_MEGABITS_PER_SECOND,
|
native_unit_of_measurement=DATA_RATE_MEGABITS_PER_SECOND,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
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