Skip to content
This repository has been archived by the owner on Dec 2, 2019. It is now read-only.

Commit

Permalink
Allow sending an icon with a notification
Browse files Browse the repository at this point in the history
  • Loading branch information
andersonshatch committed Mar 2, 2017
1 parent babf7b6 commit ab2365e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pylgtv/webos_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import base64
import codecs
import json
import os
Expand Down Expand Up @@ -167,10 +168,20 @@ def request(self, uri, payload=None):
"""Send a request."""
self.command('request', uri, payload)

def send_message(self, message):
def send_message(self, message, icon_path=None):
"""Show a floating message."""
icon_encoded_string = ''
icon_extension = ''

if icon_path is not None:
icon_extension = os.path.splitext(icon_path)[1][1:]
with open(icon_path, 'rb') as icon_file:
icon_encoded_string = base64.b64encode(icon_file.read()).decode('ascii')

self.request(EP_SHOW_MESSAGE, {
'message': message
'message': message,
'iconData': icon_encoded_string,
'iconExtension': icon_extension
})

# Apps
Expand Down

1 comment on commit ab2365e

@nickperry
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know the specifications of icon file that will work? Dimensions, colour depth, file size, etc.

Please sign in to comment.