diff --git a/homeassistant/components/webostv/notify.py b/homeassistant/components/webostv/notify.py index df2ed7e50634c1647426c1ed6d34b799c6dee8c7..7348e978d026f799113483e8f3d6c111249aed2f 100644 --- a/homeassistant/components/webostv/notify.py +++ b/homeassistant/components/webostv/notify.py @@ -46,8 +46,8 @@ class LgWebOSNotificationService(BaseNotificationService): if not self._client.is_connected(): await self._client.connect() - data = kwargs.get(ATTR_DATA) - icon_path = data.get(CONF_ICON, "") if data else None + data = kwargs.get(ATTR_DATA, {}) + icon_path = data.get(CONF_ICON) await self._client.send_message(message, icon_path=icon_path) except WebOsTvPairError: _LOGGER.error("Pairing with TV failed") diff --git a/tests/components/webostv/test_notify.py b/tests/components/webostv/test_notify.py index a518854573762cf1ed67aa05048615a2de6e5014..7e150c6eb7828d526dc544663d06e90ab2a8bc84 100644 --- a/tests/components/webostv/test_notify.py +++ b/tests/components/webostv/test_notify.py @@ -36,6 +36,21 @@ async def test_notify(hass, client): assert client.connect.call_count == 1 client.send_message.assert_called_with(MESSAGE, icon_path=ICON_PATH) + await hass.services.async_call( + NOTIFY_DOMAIN, + TV_NAME, + { + ATTR_MESSAGE: MESSAGE, + CONF_SERVICE_DATA: { + "OTHER_DATA": "not_used", + }, + }, + blocking=True, + ) + assert client.mock_calls[0] == call.connect() + assert client.connect.call_count == 1 + client.send_message.assert_called_with(MESSAGE, icon_path=None) + async def test_notify_not_connected(hass, client, monkeypatch): """Test sending a message when client is not connected."""