Send a logo with webostv notifications (#6380)
* Update to pylgtv 0.1.4 * Send icon with webostv notifications Default to the homeassistant logo, but allow customizing it on the component and for individual notifications
This commit is contained in:
parent
9522fe3a92
commit
5fb7aa212b
3 changed files with 22 additions and 11 deletions
|
@ -25,8 +25,8 @@ from homeassistant.loader import get_component
|
|||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
REQUIREMENTS = ['https://github.com/TheRealLink/pylgtv'
|
||||
'/archive/v0.1.3.zip'
|
||||
'#pylgtv==0.1.3',
|
||||
'/archive/v0.1.4.zip'
|
||||
'#pylgtv==0.1.4',
|
||||
'websockets==3.2',
|
||||
'wakeonlan==0.2.2']
|
||||
|
||||
|
|
|
@ -5,24 +5,29 @@ For more details about this platform, please refer to the documentation at
|
|||
https://home-assistant.io/components/notify.webostv/
|
||||
"""
|
||||
import logging
|
||||
import os
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.components.notify import (
|
||||
BaseNotificationService, PLATFORM_SCHEMA)
|
||||
from homeassistant.const import (CONF_FILENAME, CONF_HOST)
|
||||
ATTR_DATA, BaseNotificationService, PLATFORM_SCHEMA)
|
||||
from homeassistant.const import (CONF_FILENAME, CONF_HOST, CONF_ICON)
|
||||
|
||||
REQUIREMENTS = ['https://github.com/TheRealLink/pylgtv/archive/v0.1.3.zip'
|
||||
'#pylgtv==0.1.3']
|
||||
REQUIREMENTS = ['https://github.com/TheRealLink/pylgtv/archive/v0.1.4.zip'
|
||||
'#pylgtv==0.1.4']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
WEBOSTV_CONFIG_FILE = 'webostv.conf'
|
||||
HOME_ASSISTANT_ICON_PATH = os.path.join(os.path.dirname(__file__), '..',
|
||||
'frontend', 'www_static', 'icons',
|
||||
'favicon-1024x1024.png')
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_HOST): cv.string,
|
||||
vol.Optional(CONF_FILENAME, default=WEBOSTV_CONFIG_FILE): cv.string
|
||||
vol.Optional(CONF_FILENAME, default=WEBOSTV_CONFIG_FILE): cv.string,
|
||||
vol.Optional(CONF_ICON, default=HOME_ASSISTANT_ICON_PATH): cv.string
|
||||
})
|
||||
|
||||
|
||||
|
@ -44,23 +49,29 @@ def get_service(hass, config, discovery_info=None):
|
|||
_LOGGER.error("TV unreachable")
|
||||
return None
|
||||
|
||||
return LgWebOSNotificationService(client)
|
||||
return LgWebOSNotificationService(client, config.get(CONF_ICON))
|
||||
|
||||
|
||||
class LgWebOSNotificationService(BaseNotificationService):
|
||||
"""Implement the notification service for LG WebOS TV."""
|
||||
|
||||
def __init__(self, client):
|
||||
def __init__(self, client, icon_path):
|
||||
"""Initialize the service."""
|
||||
self._client = client
|
||||
self._icon_path = icon_path
|
||||
|
||||
def send_message(self, message="", **kwargs):
|
||||
"""Send a message to the tv."""
|
||||
from pylgtv import PyLGTVPairException
|
||||
|
||||
try:
|
||||
self._client.send_message(message)
|
||||
data = kwargs.get(ATTR_DATA)
|
||||
icon_path = data.get(CONF_ICON, self._icon_path) if data else \
|
||||
self._icon_path
|
||||
self._client.send_message(message, icon_path=icon_path)
|
||||
except PyLGTVPairException:
|
||||
_LOGGER.error("Pairing with TV failed")
|
||||
except FileNotFoundError:
|
||||
_LOGGER.error("Icon %s not found", icon_path)
|
||||
except OSError:
|
||||
_LOGGER.error("TV unreachable")
|
||||
|
|
|
@ -217,7 +217,7 @@ https://github.com/LinuxChristian/pyW215/archive/v0.4.zip#pyW215==0.4
|
|||
|
||||
# homeassistant.components.media_player.webostv
|
||||
# homeassistant.components.notify.webostv
|
||||
https://github.com/TheRealLink/pylgtv/archive/v0.1.3.zip#pylgtv==0.1.3
|
||||
https://github.com/TheRealLink/pylgtv/archive/v0.1.4.zip#pylgtv==0.1.4
|
||||
|
||||
# homeassistant.components.sensor.thinkingcleaner
|
||||
# homeassistant.components.switch.thinkingcleaner
|
||||
|
|
Loading…
Add table
Reference in a new issue