1 """Network helper class for the network integration."""
3 from __future__
import annotations
14 ATTR_CONFIGURED_ADAPTERS,
16 DEFAULT_CONFIGURED_ADAPTERS,
20 from .models
import Adapter
21 from .util
import async_load_adapters, enable_adapters, enable_auto_detected_adapters
23 _LOGGER = logging.getLogger(__name__)
26 @singleton(DATA_NETWORK)
28 """Get network singleton."""
30 await network.async_setup()
31 network.async_configure()
33 _LOGGER.debug(
"Adapters: %s", network.adapters)
38 """Network helper class for the network integration."""
40 def __init__(self, hass: HomeAssistant) ->
None:
41 """Initialize the Network class."""
42 self.
_store_store = Store[dict[str, list[str]]](
43 hass, STORAGE_VERSION, STORAGE_KEY, atomic_writes=
True
45 self.
_data_data: dict[str, list[str]] = {}
46 self.
adaptersadapters: list[Adapter] = []
50 """Return the configured adapters."""
51 return self.
_data_data.
get(ATTR_CONFIGURED_ADAPTERS, DEFAULT_CONFIGURED_ADAPTERS)
54 """Set up the network config."""
55 storage_load_task = create_eager_task(self.
async_loadasync_load())
57 await storage_load_task
61 """Configure from storage."""
66 """Reconfigure network."""
67 self.
_data_data[ATTR_CONFIGURED_ADAPTERS] = config[ATTR_CONFIGURED_ADAPTERS]
77 """Save preferences."""
None async_reconfig(self, dict[str, Any] config)
list[str] configured_adapters(self)
None __init__(self, HomeAssistant hass)
None async_configure(self)
web.Response get(self, web.Request request, str config_key)
Network async_get_network(HomeAssistant hass)
list[Adapter] async_load_adapters()
bool enable_adapters(list[Adapter] adapters, list[str] enabled_interfaces)
None enable_auto_detected_adapters(list[Adapter] adapters)
None async_save(self, _T data)