Fix Notifications for Android TV (#10798)
* Fixed icon path, added dynamic icon * Addressing requested changes * Using DEFAULT_ICON * Using CONF_ICON from const * Getting hass_frontend path via import * Lint * Using embedded 1px transparent icon * woof -.- * Lint
This commit is contained in:
parent
b1855f1d1d
commit
b815898ddb
1 changed files with 8 additions and 7 deletions
|
@ -4,8 +4,9 @@ Notifications for Android TV notification service.
|
|||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/notify.nfandroidtv/
|
||||
"""
|
||||
import os
|
||||
import logging
|
||||
import io
|
||||
import base64
|
||||
|
||||
import requests
|
||||
import voluptuous as vol
|
||||
|
@ -31,6 +32,9 @@ DEFAULT_TRANSPARENCY = 'default'
|
|||
DEFAULT_COLOR = 'grey'
|
||||
DEFAULT_INTERRUPT = False
|
||||
DEFAULT_TIMEOUT = 5
|
||||
DEFAULT_ICON = (
|
||||
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGP6zwAAAgcBApo'
|
||||
'cMXEAAAAASUVORK5CYII=')
|
||||
|
||||
ATTR_DURATION = 'duration'
|
||||
ATTR_POSITION = 'position'
|
||||
|
@ -110,16 +114,13 @@ class NFAndroidTVNotificationService(BaseNotificationService):
|
|||
self._default_color = color
|
||||
self._default_interrupt = interrupt
|
||||
self._timeout = timeout
|
||||
self._icon_file = os.path.join(
|
||||
os.path.dirname(__file__), '..', 'frontend', 'www_static', 'icons',
|
||||
'favicon-192x192.png')
|
||||
self._icon_file = io.BytesIO(base64.b64decode(DEFAULT_ICON))
|
||||
|
||||
def send_message(self, message="", **kwargs):
|
||||
"""Send a message to a Android TV device."""
|
||||
_LOGGER.debug("Sending notification to: %s", self._target)
|
||||
|
||||
payload = dict(filename=('icon.png',
|
||||
open(self._icon_file, 'rb'),
|
||||
payload = dict(filename=('icon.png', self._icon_file,
|
||||
'application/octet-stream',
|
||||
{'Expires': '0'}), type='0',
|
||||
title=kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT),
|
||||
|
@ -129,7 +130,7 @@ class NFAndroidTVNotificationService(BaseNotificationService):
|
|||
transparency='%i' % TRANSPARENCIES.get(
|
||||
self._default_transparency),
|
||||
offset='0', app=ATTR_TITLE_DEFAULT, force='true',
|
||||
interrupt='%i' % self._default_interrupt)
|
||||
interrupt='%i' % self._default_interrupt,)
|
||||
|
||||
data = kwargs.get(ATTR_DATA)
|
||||
if data:
|
||||
|
|
Loading…
Add table
Reference in a new issue