Add contents to connection_info handler in cloud client (#95059)

This commit is contained in:
Joakim Sørensen 2023-06-27 17:45:41 +02:00 committed by GitHub
parent cd26de73b4
commit db01aecb02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 2 deletions

View file

@ -17,6 +17,7 @@ from homeassistant.components.alexa import (
smart_home as alexa_smart_home,
)
from homeassistant.components.google_assistant import smart_home as ga
from homeassistant.const import __version__ as HA_VERSION
from homeassistant.core import Context, HassJob, HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.event import async_call_later
@ -216,7 +217,14 @@ class CloudClient(Interface):
self, payload: dict[str, Any]
) -> dict[str, Any]:
"""Process cloud connection info message to client."""
return {}
return {
"remote": {
"connected": self.cloud.remote.is_connected,
"enabled": self._prefs.remote_enabled,
"instance_domain": self.cloud.remote.instance_domain,
},
"version": HA_VERSION,
}
async def async_alexa_message(self, payload: dict[Any, Any]) -> dict[Any, Any]:
"""Process cloud alexa message to client."""

View file

@ -18,7 +18,7 @@ from homeassistant.components.homeassistant.exposed_entities import (
ExposedEntities,
async_expose_entity,
)
from homeassistant.const import CONTENT_TYPE_JSON
from homeassistant.const import CONTENT_TYPE_JSON, __version__ as HA_VERSION
from homeassistant.core import HomeAssistant, State
from homeassistant.helpers import entity_registry as er
from homeassistant.setup import async_setup_component
@ -353,3 +353,18 @@ async def test_system_msg(hass: HomeAssistant) -> None:
assert response is None
assert cloud.client.relayer_region == "xx-earth-616"
async def test_cloud_connection_info(hass: HomeAssistant) -> None:
"""Test connection info msg."""
with patch("hass_nabucasa.Cloud.initialize"):
setup = await async_setup_component(hass, "cloud", {"cloud": {}})
assert setup
cloud = hass.data["cloud"]
response = await cloud.client.async_cloud_connection_info({})
assert response == {
"remote": {"connected": False, "enabled": False, "instance_domain": None},
"version": HA_VERSION,
}