mirror of
https://github.com/home-assistant/core.git
synced 2025-08-04 02:58:23 +00:00
Add jitter sensor to Ping integration (#149899)
This commit is contained in:
parent
627785edc1
commit
b9e16d54c4
@ -79,6 +79,7 @@ class PingDataICMPLib(PingData):
|
|||||||
"min": data.min_rtt,
|
"min": data.min_rtt,
|
||||||
"max": data.max_rtt,
|
"max": data.max_rtt,
|
||||||
"avg": data.avg_rtt,
|
"avg": data.avg_rtt,
|
||||||
|
"jitter": data.jitter,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,6 +71,17 @@ SENSORS: tuple[PingSensorEntityDescription, ...] = (
|
|||||||
value_fn=lambda result: result.data.get("min"),
|
value_fn=lambda result: result.data.get("min"),
|
||||||
has_fn=lambda result: "min" in result.data,
|
has_fn=lambda result: "min" in result.data,
|
||||||
),
|
),
|
||||||
|
PingSensorEntityDescription(
|
||||||
|
key="jitter",
|
||||||
|
translation_key="jitter",
|
||||||
|
native_unit_of_measurement=UnitOfTime.MILLISECONDS,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
device_class=SensorDeviceClass.DURATION,
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
value_fn=lambda result: result.data.get("jitter"),
|
||||||
|
has_fn=lambda result: "jitter" in result.data,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
},
|
},
|
||||||
"round_trip_time_min": {
|
"round_trip_time_min": {
|
||||||
"name": "Round-trip time minimum"
|
"name": "Round-trip time minimum"
|
||||||
|
},
|
||||||
|
"jitter": {
|
||||||
|
"name": "Jitter"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,59 @@
|
|||||||
# serializer version: 1
|
# serializer version: 1
|
||||||
|
# name: test_setup_and_update[jitter]
|
||||||
|
EntityRegistryEntrySnapshot({
|
||||||
|
'aliases': set({
|
||||||
|
}),
|
||||||
|
'area_id': None,
|
||||||
|
'capabilities': dict({
|
||||||
|
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||||
|
}),
|
||||||
|
'config_entry_id': <ANY>,
|
||||||
|
'config_subentry_id': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'disabled_by': None,
|
||||||
|
'domain': 'sensor',
|
||||||
|
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
|
||||||
|
'entity_id': 'sensor.10_10_10_10_jitter',
|
||||||
|
'has_entity_name': True,
|
||||||
|
'hidden_by': None,
|
||||||
|
'icon': None,
|
||||||
|
'id': <ANY>,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'name': None,
|
||||||
|
'options': dict({
|
||||||
|
'sensor': dict({
|
||||||
|
'suggested_display_precision': 0,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
'original_device_class': <SensorDeviceClass.DURATION: 'duration'>,
|
||||||
|
'original_icon': None,
|
||||||
|
'original_name': 'Jitter',
|
||||||
|
'platform': 'ping',
|
||||||
|
'previous_unique_id': None,
|
||||||
|
'suggested_object_id': None,
|
||||||
|
'supported_features': 0,
|
||||||
|
'translation_key': 'jitter',
|
||||||
|
'unit_of_measurement': <UnitOfTime.MILLISECONDS: 'ms'>,
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_setup_and_update[jitter].1
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'device_class': 'duration',
|
||||||
|
'friendly_name': '10.10.10.10 Jitter',
|
||||||
|
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||||
|
'unit_of_measurement': <UnitOfTime.MILLISECONDS: 'ms'>,
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'sensor.10_10_10_10_jitter',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': '3.5',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
# name: test_setup_and_update[round_trip_time_average]
|
# name: test_setup_and_update[round_trip_time_average]
|
||||||
EntityRegistryEntrySnapshot({
|
EntityRegistryEntrySnapshot({
|
||||||
'aliases': set({
|
'aliases': set({
|
||||||
|
@ -16,6 +16,7 @@ from homeassistant.helpers import entity_registry as er
|
|||||||
"round_trip_time_maximum",
|
"round_trip_time_maximum",
|
||||||
"round_trip_time_mean_deviation", # should be None in the snapshot
|
"round_trip_time_mean_deviation", # should be None in the snapshot
|
||||||
"round_trip_time_minimum",
|
"round_trip_time_minimum",
|
||||||
|
"jitter",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_setup_and_update(
|
async def test_setup_and_update(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user