Fix webostv notify service (#66760)
parent
750b48dcaf
commit
e79348f952
|
@ -46,8 +46,8 @@ class LgWebOSNotificationService(BaseNotificationService):
|
||||||
if not self._client.is_connected():
|
if not self._client.is_connected():
|
||||||
await self._client.connect()
|
await self._client.connect()
|
||||||
|
|
||||||
data = kwargs.get(ATTR_DATA)
|
data = kwargs.get(ATTR_DATA, {})
|
||||||
icon_path = data.get(CONF_ICON, "") if data else None
|
icon_path = data.get(CONF_ICON)
|
||||||
await self._client.send_message(message, icon_path=icon_path)
|
await self._client.send_message(message, icon_path=icon_path)
|
||||||
except WebOsTvPairError:
|
except WebOsTvPairError:
|
||||||
_LOGGER.error("Pairing with TV failed")
|
_LOGGER.error("Pairing with TV failed")
|
||||||
|
|
|
@ -36,6 +36,21 @@ async def test_notify(hass, client):
|
||||||
assert client.connect.call_count == 1
|
assert client.connect.call_count == 1
|
||||||
client.send_message.assert_called_with(MESSAGE, icon_path=ICON_PATH)
|
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):
|
async def test_notify_not_connected(hass, client, monkeypatch):
|
||||||
"""Test sending a message when client is not connected."""
|
"""Test sending a message when client is not connected."""
|
||||||
|
|
Loading…
Reference in New Issue