Add state class measurement to all suitable sensors on Speedtest.net (#53693)
* Add state class measurement * use tuple instead of list
This commit is contained in:
parent
1265aa0f64
commit
bffa9f960d
3 changed files with 45 additions and 23 deletions
|
@ -1,17 +1,38 @@
|
|||
"""Consts used by Speedtest.net."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Final
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
SensorEntityDescription,
|
||||
)
|
||||
from homeassistant.const import DATA_RATE_MEGABITS_PER_SECOND, TIME_MILLISECONDS
|
||||
|
||||
DOMAIN: Final = "speedtestdotnet"
|
||||
|
||||
SPEED_TEST_SERVICE: Final = "speedtest"
|
||||
|
||||
SENSOR_TYPES: Final = {
|
||||
"ping": ["Ping", TIME_MILLISECONDS],
|
||||
"download": ["Download", DATA_RATE_MEGABITS_PER_SECOND],
|
||||
"upload": ["Upload", DATA_RATE_MEGABITS_PER_SECOND],
|
||||
}
|
||||
SENSOR_TYPES: Final[tuple[SensorEntityDescription, ...]] = (
|
||||
SensorEntityDescription(
|
||||
key="ping",
|
||||
name="Ping",
|
||||
unit_of_measurement=TIME_MILLISECONDS,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="download",
|
||||
name="Download",
|
||||
unit_of_measurement=DATA_RATE_MEGABITS_PER_SECOND,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="upload",
|
||||
name="Upload",
|
||||
unit_of_measurement=DATA_RATE_MEGABITS_PER_SECOND,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
),
|
||||
)
|
||||
|
||||
CONF_SERVER_NAME: Final = "server_name"
|
||||
CONF_SERVER_ID: Final = "server_id"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue