mirror of https://github.com/home-assistant/core
Add connected relayer region to system health (#90410)
This commit is contained in:
parent
478a1d5e9a
commit
d907bd2ca3
|
@ -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)
|
||||
|
|
|
@ -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"]
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue