Expose ping drop rate Starlink sensor (#91444)

This commit is contained in:
Jack Boswell 2023-04-17 06:25:36 +12:00 committed by GitHub
parent 1dc0870163
commit 00191ace6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,7 +12,13 @@ from homeassistant.components.sensor import (
SensorStateClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import DEGREE, EntityCategory, UnitOfDataRate, UnitOfTime
from homeassistant.const import (
DEGREE,
PERCENTAGE,
EntityCategory,
UnitOfDataRate,
UnitOfTime,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType
@ -119,4 +125,11 @@ SENSORS: tuple[StarlinkSensorEntityDescription, ...] = (
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: now() - timedelta(seconds=data.status["uptime"]),
),
StarlinkSensorEntityDescription(
key="ping_drop_rate",
name="Ping Drop Rate",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=PERCENTAGE,
value_fn=lambda data: data.status["pop_ping_drop_rate"],
),
)