diff --git a/homeassistant/components/cloud/client.py b/homeassistant/components/cloud/client.py index 08d43644249..900779f6b01 100644 --- a/homeassistant/components/cloud/client.py +++ b/homeassistant/components/cloud/client.py @@ -47,6 +47,7 @@ class CloudClient(Interface): self._google_config: google_config.CloudGoogleConfig | None = None self._alexa_config_init_lock = asyncio.Lock() self._google_config_init_lock = asyncio.Lock() + self._relayer_region: str | None = None @property def base_path(self) -> Path: @@ -84,6 +85,11 @@ class CloudClient(Interface): """Return true if we want start a remote connection.""" return self._prefs.remote_enabled + @property + def relayer_region(self) -> str | None: + """Return the connected relayer region.""" + return self._relayer_region + async def get_alexa_config(self) -> alexa_config.CloudAlexaConfig: """Return Alexa config.""" if self._alexa_config is None: @@ -256,6 +262,11 @@ class CloudClient(Interface): "headers": {"Content-Type": response.content_type}, } + async def async_system_message(self, payload: dict[Any, Any] | None) -> None: + """Handle system messages.""" + if payload and (region := payload.get("region")): + self._relayer_region = region + async def async_cloudhooks_update(self, data: dict[str, dict[str, str]]) -> None: """Update local list of cloudhooks.""" await self._prefs.async_update(cloudhooks=data) diff --git a/homeassistant/components/cloud/manifest.json b/homeassistant/components/cloud/manifest.json index 7bd4a822fba..2bff4003669 100644 --- a/homeassistant/components/cloud/manifest.json +++ b/homeassistant/components/cloud/manifest.json @@ -8,5 +8,5 @@ "integration_type": "system", "iot_class": "cloud_push", "loggers": ["hass_nabucasa"], - "requirements": ["hass-nabucasa==0.62.0"] + "requirements": ["hass-nabucasa==0.63.1"] } diff --git a/homeassistant/components/cloud/strings.json b/homeassistant/components/cloud/strings.json index e437fca9ed3..432a4db0f77 100644 --- a/homeassistant/components/cloud/strings.json +++ b/homeassistant/components/cloud/strings.json @@ -5,6 +5,7 @@ "can_reach_cloud": "Reach Home Assistant Cloud", "can_reach_cloud_auth": "Reach Authentication Server", "relayer_connected": "Relayer Connected", + "relayer_region": "Relayer Region", "remote_connected": "Remote Connected", "remote_enabled": "Remote Enabled", "remote_server": "Remote Server", diff --git a/homeassistant/components/cloud/system_health.py b/homeassistant/components/cloud/system_health.py index 9f836114b3e..b1f1774aa47 100644 --- a/homeassistant/components/cloud/system_health.py +++ b/homeassistant/components/cloud/system_health.py @@ -28,6 +28,7 @@ async def system_health_info(hass): if cloud.is_logged_in: data["subscription_expiration"] = cloud.expiration_date data["relayer_connected"] = cloud.is_connected + data["relayer_region"] = client.relayer_region data["remote_enabled"] = client.prefs.remote_enabled data["remote_connected"] = cloud.remote.is_connected data["alexa_enabled"] = client.prefs.alexa_enabled diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index 518bea69fbe..dea105f2967 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -22,7 +22,7 @@ cryptography==40.0.1 dbus-fast==1.84.2 fnvhash==0.1.0 ha-av==10.0.0 -hass-nabucasa==0.62.0 +hass-nabucasa==0.63.1 hassil==1.0.6 home-assistant-bluetooth==1.9.3 home-assistant-frontend==20230309.1 diff --git a/requirements_all.txt b/requirements_all.txt index 46599fbafe7..27a50ca564f 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -868,7 +868,7 @@ ha-philipsjs==3.0.0 habitipy==0.2.0 # homeassistant.components.cloud -hass-nabucasa==0.62.0 +hass-nabucasa==0.63.1 # homeassistant.components.splunk hass_splunk==0.1.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 7b41d469361..f4a9437f9b3 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -666,7 +666,7 @@ ha-philipsjs==3.0.0 habitipy==0.2.0 # homeassistant.components.cloud -hass-nabucasa==0.62.0 +hass-nabucasa==0.63.1 # homeassistant.components.conversation hassil==1.0.6 diff --git a/tests/components/cloud/test_client.py b/tests/components/cloud/test_client.py index 9f463803b82..b7bfed53aac 100644 --- a/tests/components/cloud/test_client.py +++ b/tests/components/cloud/test_client.py @@ -312,3 +312,22 @@ async def test_login_recovers_bad_internet( await hass.async_block_till_done() assert len(client._alexa_config.async_enable_proactive_mode.mock_calls) == 2 + + +async def test_system_msg(hass: HomeAssistant) -> None: + """Test system msg.""" + with patch("hass_nabucasa.Cloud.initialize"): + setup = await async_setup_component(hass, "cloud", {"cloud": {}}) + assert setup + cloud = hass.data["cloud"] + + assert cloud.client.relayer_region is None + + response = await cloud.client.async_system_message( + { + "region": "xx-earth-616", + } + ) + + assert response is None + assert cloud.client.relayer_region == "xx-earth-616" diff --git a/tests/components/cloud/test_system_health.py b/tests/components/cloud/test_system_health.py index b2b74d89299..96b87936da4 100644 --- a/tests/components/cloud/test_system_health.py +++ b/tests/components/cloud/test_system_health.py @@ -36,11 +36,12 @@ async def test_cloud_system_health( expiration_date=now, is_connected=True, client=Mock( + relayer_region="xx-earth-616", prefs=Mock( remote_enabled=True, alexa_enabled=True, google_enabled=False, - ) + ), ), ) @@ -54,6 +55,7 @@ async def test_cloud_system_health( "logged_in": True, "subscription_expiration": now, "relayer_connected": True, + "relayer_region": "xx-earth-616", "remote_enabled": True, "remote_connected": False, "remote_server": "us-west-1",