Add statistics support to iperf3 (#85771)
This commit is contained in:
parent
1f6efe8c3e
commit
578a1cdc02
2 changed files with 7 additions and 3 deletions
|
@ -11,6 +11,7 @@ from homeassistant.components.sensor import (
|
||||||
DOMAIN as SENSOR_DOMAIN,
|
DOMAIN as SENSOR_DOMAIN,
|
||||||
SensorDeviceClass,
|
SensorDeviceClass,
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
|
@ -48,16 +49,22 @@ ATTR_UPLOAD = "upload"
|
||||||
ATTR_VERSION = "Version"
|
ATTR_VERSION = "Version"
|
||||||
ATTR_HOST = "host"
|
ATTR_HOST = "host"
|
||||||
|
|
||||||
|
ICON = "mdi:speedometer"
|
||||||
|
|
||||||
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key=ATTR_DOWNLOAD,
|
key=ATTR_DOWNLOAD,
|
||||||
name=ATTR_DOWNLOAD.capitalize(),
|
name=ATTR_DOWNLOAD.capitalize(),
|
||||||
|
icon=ICON,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
device_class=SensorDeviceClass.DATA_RATE,
|
device_class=SensorDeviceClass.DATA_RATE,
|
||||||
native_unit_of_measurement=UnitOfDataRate.MEGABITS_PER_SECOND,
|
native_unit_of_measurement=UnitOfDataRate.MEGABITS_PER_SECOND,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key=ATTR_UPLOAD,
|
key=ATTR_UPLOAD,
|
||||||
name=ATTR_UPLOAD.capitalize(),
|
name=ATTR_UPLOAD.capitalize(),
|
||||||
|
icon=ICON,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
device_class=SensorDeviceClass.DATA_RATE,
|
device_class=SensorDeviceClass.DATA_RATE,
|
||||||
native_unit_of_measurement=UnitOfDataRate.MEGABITS_PER_SECOND,
|
native_unit_of_measurement=UnitOfDataRate.MEGABITS_PER_SECOND,
|
||||||
),
|
),
|
||||||
|
|
|
@ -11,8 +11,6 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
from . import ATTR_VERSION, DATA_UPDATED, DOMAIN as IPERF3_DOMAIN, SENSOR_TYPES
|
from . import ATTR_VERSION, DATA_UPDATED, DOMAIN as IPERF3_DOMAIN, SENSOR_TYPES
|
||||||
|
|
||||||
ICON = "mdi:speedometer"
|
|
||||||
|
|
||||||
ATTR_PROTOCOL = "Protocol"
|
ATTR_PROTOCOL = "Protocol"
|
||||||
ATTR_REMOTE_HOST = "Remote Server"
|
ATTR_REMOTE_HOST = "Remote Server"
|
||||||
ATTR_REMOTE_PORT = "Remote Port"
|
ATTR_REMOTE_PORT = "Remote Port"
|
||||||
|
@ -41,7 +39,6 @@ class Iperf3Sensor(RestoreEntity, SensorEntity):
|
||||||
"""A Iperf3 sensor implementation."""
|
"""A Iperf3 sensor implementation."""
|
||||||
|
|
||||||
_attr_attribution = "Data retrieved using Iperf3"
|
_attr_attribution = "Data retrieved using Iperf3"
|
||||||
_attr_icon = ICON
|
|
||||||
_attr_should_poll = False
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(self, iperf3_data, description: SensorEntityDescription):
|
def __init__(self, iperf3_data, description: SensorEntityDescription):
|
||||||
|
|
Loading…
Add table
Reference in a new issue