Skip to content

Instantly share code, notes, and snippets.

@JakeDEvans
Last active February 8, 2017 05:21
Show Gist options
  • Save JakeDEvans/9a22b565483742fc836f1115b8a87e68 to your computer and use it in GitHub Desktop.
Save JakeDEvans/9a22b565483742fc836f1115b8a87e68 to your computer and use it in GitHub Desktop.
from __future__ import print_function
import hid
import time
import requests
import simplejson as json
# try opening a device, then perform write and read
print("Opening the device")
h = hid.device()
h.open(0x07CA, 0x9850)
url = "http://user@pass@localhost:8080/jsonrpc"
data = {"jsonrpc":"2.0","method":"GUI.ShowNotification","params":{"title":"KODI TITLE","message":"KODI_MESSAGE"},"id":0}
headers = {'Content-type': 'application/json'}
url2 = "http://localhost:3000/hooks/ROCKET_SECRET"
data2 = {"text":"ROCKET_MESSAGE"}
try:
while True:
d = h.read(64)
if len(d) >= 2 and d[1] == 1:
r = requests.post(url, data=json.dumps(data), headers=headers)
r = requests.post(url2, data=json.dumps(data2), headers=headers)
finally:
print("Closing the device")
h.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment