diff --git a/homeassistant/components/webostv/notify.py b/homeassistant/components/webostv/notify.py index df2ed7e5063..7348e978d02 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 a5188545737..7e150c6eb78 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."""