1 """Support for LG WebOS TV notification service."""
3 from __future__
import annotations
8 from aiowebostv
import WebOsClient, WebOsTvPairError
15 from .const
import ATTR_CONFIG_ENTRY_ID, DATA_CONFIG_ENTRY, DOMAIN, WEBOSTV_EXCEPTIONS
17 _LOGGER = logging.getLogger(__name__)
23 discovery_info: DiscoveryInfoType |
None =
None,
24 ) -> BaseNotificationService |
None:
25 """Return the notify service."""
27 if discovery_info
is None:
30 client = hass.data[DOMAIN][DATA_CONFIG_ENTRY][discovery_info[ATTR_CONFIG_ENTRY_ID]]
36 """Implement the notification service for LG WebOS TV."""
38 def __init__(self, client: WebOsClient) ->
None:
39 """Initialize the service."""
43 """Send a message to the tv."""
46 await self.
_client_client.connect()
48 data = kwargs[ATTR_DATA]
49 icon_path = data.get(ATTR_ICON)
if data
else None
50 await self.
_client_client.send_message(message, icon_path=icon_path)
51 except WebOsTvPairError:
52 _LOGGER.error(
"Pairing with TV failed")
53 except FileNotFoundError:
54 _LOGGER.error(
"Icon %s not found", icon_path)
55 except WEBOSTV_EXCEPTIONS:
56 _LOGGER.error(
"TV unreachable")
None async_send_message(self, str message="", **Any kwargs)
None __init__(self, WebOsClient client)
BaseNotificationService|None async_get_service(HomeAssistant hass, ConfigType config, DiscoveryInfoType|None discovery_info=None)