1 """Support for Iperf3 sensors."""
3 from __future__
import annotations
13 from .
import ATTR_VERSION, DATA_UPDATED, DOMAIN
as IPERF3_DOMAIN, SENSOR_TYPES
15 ATTR_PROTOCOL =
"Protocol"
16 ATTR_REMOTE_HOST =
"Remote Server"
17 ATTR_REMOTE_PORT =
"Remote Port"
23 async_add_entities: AddEntitiesCallback,
24 discovery_info: DiscoveryInfoType |
None =
None,
26 """Set up the Iperf3 sensor."""
27 if not discovery_info:
32 for iperf3_host
in hass.data[IPERF3_DOMAIN].values()
33 for description
in SENSOR_TYPES
34 if description.key
in discovery_info[CONF_MONITORED_CONDITIONS]
41 """A Iperf3 sensor implementation."""
43 _attr_attribution =
"Data retrieved using Iperf3"
44 _attr_should_poll =
False
46 def __init__(self, iperf3_data, description: SensorEntityDescription) ->
None:
47 """Initialize the sensor."""
50 self.
_attr_name_attr_name = f
"{description.name} {iperf3_data.host}"
54 """Return the state attributes."""
59 ATTR_VERSION: self.
_iperf3_data_iperf3_data.data[ATTR_VERSION],
63 """Handle entity which will be added."""
77 """Get the latest data and update the states."""
None async_added_to_hass(self)
None __init__(self, iperf3_data, SensorEntityDescription description)
def extra_state_attributes(self)
def _schedule_immediate_update(self, host)
None async_schedule_update_ha_state(self, bool force_refresh=False)
None async_on_remove(self, CALLBACK_TYPE func)
State|None async_get_last_state(self)
None async_setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback async_add_entities, DiscoveryInfoType|None discovery_info=None)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)