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

Commit

Permalink
Merge pull request #3 from andersonshatch/icon-with-notification
Browse files Browse the repository at this point in the history
Allow sending an icon with a notification
  • Loading branch information
TheRealLink authored Mar 2, 2017
2 parents babf7b6 + ab2365e commit 080d4e9
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

0 comments on commit 080d4e9

Please sign in to comment.