diff --git a/hass_nabucasa/client.py b/hass_nabucasa/client.py index 0ec4f2a63..febf95ddf 100644 --- a/hass_nabucasa/client.py +++ b/hass_nabucasa/client.py @@ -68,6 +68,10 @@ async def async_cloud_connect_update(self, connect: bool) -> None: async def async_alexa_message(self, payload: dict[Any, Any]) -> dict[Any, Any]: """process cloud alexa message to client.""" + @abstractmethod + async def async_system_message(self, payload: dict[Any, Any]) -> None: + """process cloud system message to client.""" + @abstractmethod async def async_google_message(self, payload: dict[Any, Any]) -> dict[Any, Any]: """Process cloud google message to client.""" diff --git a/hass_nabucasa/iot.py b/hass_nabucasa/iot.py index 02920d4dd..4012858b7 100644 --- a/hass_nabucasa/iot.py +++ b/hass_nabucasa/iot.py @@ -140,8 +140,8 @@ async def _async_handle_handler_message(self, message: dict[str, Any]) -> None: @HANDLERS.register("system") async def async_handle_system(cloud: Cloud, payload: dict[str, Any]) -> None: - """We ignore incoming system IoT messages.""" - return None + """Handle an incoming IoT message for System.""" + return await cloud.client.async_system_message(payload) @HANDLERS.register("alexa") diff --git a/tests/common.py b/tests/common.py index bae565bf9..8b48254c0 100644 --- a/tests/common.py +++ b/tests/common.py @@ -24,6 +24,7 @@ def __init__(self, loop, websession): self.mock_alexa = [] self.mock_google = [] self.mock_webhooks = [] + self.mock_system = [] self.mock_return = [] self._base_path = None @@ -98,6 +99,11 @@ async def async_webhook_message(self, payload): self.mock_webhooks.append(payload) return self.mock_return.pop() + async def async_system_message(self, payload): + """Process cloud system message to client.""" + self.mock_system.append(payload) + return self.mock_return.pop() + async def async_cloudhooks_update(self, data): """Update internal cloudhooks data.""" self._cloudhooks = data diff --git a/tests/test_iot.py b/tests/test_iot.py index 33c6a9c15..7092df3ab 100644 --- a/tests/test_iot.py +++ b/tests/test_iot.py @@ -179,6 +179,15 @@ async def test_handler_webhook(cloud_mock): assert resp == {"test": 5} +async def test_handler_system(cloud_mock): + """Test handler system.""" + cloud_mock.client.mock_return.append({"test": 5}) + resp = await iot.async_handle_system(cloud_mock, {"test-discovery": True}) + + assert len(cloud_mock.client.mock_system) == 1 + assert resp == {"test": 5} + + async def test_handler_remote_sni(cloud_mock): """Test handler Webhook.""" assert not cloud_mock.client.pref_should_connect