diff --git a/supervisor/dbus/const.py b/supervisor/dbus/const.py index 0fa6462ca..ca490e7e5 100644 --- a/supervisor/dbus/const.py +++ b/supervisor/dbus/const.py @@ -14,6 +14,9 @@ DBUS_NAME_RAUC = "de.pengutronix.rauc" DBUS_NAME_RAUC_INSTALLER = "de.pengutronix.rauc.Installer" DBUS_NAME_RAUC_INSTALLER_COMPLETED = "de.pengutronix.rauc.Installer.Completed" DBUS_NAME_SETTINGS_CONNECTION = "org.freedesktop.NetworkManager.Settings.Connection" +DBUS_NAME_NM_CONNECTION_ACTIVE_CHANGED = ( + "org.freedesktop.NetworkManager.Connection.Active.PropertiesChanged" +) DBUS_NAME_SYSTEMD = "org.freedesktop.systemd1" DBUS_OBJECT_BASE = "/" diff --git a/supervisor/host/network.py b/supervisor/host/network.py index 7a3c758b3..5e386900a 100644 --- a/supervisor/host/network.py +++ b/supervisor/host/network.py @@ -10,6 +10,7 @@ import attr from ..coresys import CoreSys, CoreSysAttributes from ..dbus.const import ( + DBUS_NAME_NM_CONNECTION_ACTIVE_CHANGED, ConnectionStateType, DeviceType, InterfaceMethod as NMInterfaceMethod, @@ -161,6 +162,9 @@ class NetworkManager(CoreSysAttributes): _LOGGER.warning("Requested Network interface update is not possible") raise HostNetworkError() + await self.sys_dbus.network.dbus.wait_signal( + DBUS_NAME_NM_CONNECTION_ACTIVE_CHANGED + ) await self.update() async def scan_wifi(self, interface: Interface) -> List[AccessPoint]: diff --git a/supervisor/utils/gdbus.py b/supervisor/utils/gdbus.py index c838598a2..d6c291cc3 100644 --- a/supervisor/utils/gdbus.py +++ b/supervisor/utils/gdbus.py @@ -48,7 +48,9 @@ RE_GVARIANT_TUPLE_C: re.Pattern[Any] = re.compile( RE_BIN_STRING_OCT: re.Pattern[Any] = re.compile(r"\\\\(\d{3})") RE_BIN_STRING_HEX: re.Pattern[Any] = re.compile(r"\\\\x([0-9A-Za-z]{2})") -RE_MONITOR_OUTPUT: re.Pattern[Any] = re.compile(r".+?: (?P[^ ].+) (?P.*)") +RE_MONITOR_OUTPUT: re.Pattern[Any] = re.compile( + r".+?: (?P[^\s].+?) (?P.*)" +) # Map GDBus to errors MAP_GDBUS_ERROR: Dict[str, Any] = { diff --git a/tests/conftest.py b/tests/conftest.py index 0c86af4a3..09a5f90c7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -63,6 +63,9 @@ def dbus() -> DBus: return load_json_fixture(f"{fixture}.json") + async def mock_wait_signal(_, __): + pass + async def mock_send(_, command, silent=False): if silent: return "" @@ -86,9 +89,13 @@ def dbus() -> DBus: return load_fixture(f"{fixture}.{filetype}") with patch("supervisor.utils.gdbus.DBus._send", new=mock_send), patch( + "supervisor.utils.gdbus.DBus.wait_signal", new=mock_wait_signal + ), patch( "supervisor.dbus.interface.DBusInterface.is_connected", return_value=True, - ), patch("supervisor.utils.gdbus.DBus.get_properties", new=mock_get_properties): + ), patch( + "supervisor.utils.gdbus.DBus.get_properties", new=mock_get_properties + ): yield dbus_commands