Skip to content

Instantly share code, notes, and snippets.

@128keaton
Created December 8, 2017 02:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 128keaton/519aa242fde5b1ab8e66466112b871dc to your computer and use it in GitHub Desktop.
Save 128keaton/519aa242fde5b1ab8e66466112b871dc to your computer and use it in GitHub Desktop.
DYN Coin Google Home notification
#!/usr/bin/python
import subprocess
import time
import json
import requests
EARL = 'http://10.0.0.145:5000/play/cha.m4a'
CMD = '~/dynamic-1.5.0/bin/dynamic-cli getwalletinfo'
BALANCE = -1.0
def getBalance():
output = subprocess.Popen(CMD, shell=True, stdout=subprocess.PIPE)
json_str, _ = output.communicate()
jsonObject = json.loads(json_str)
global BALANCE
BALANCE = float(jsonObject["balance"])
return BALANCE
def didChange():
global BALANCE
prevBalance = BALANCE
BALANCE = getBalance()
if prevBalance < BALANCE and prevBalance != -1.0:
return True
return False
def sendNotification():
requests.get(EARL)
while True:
if didChange() == True:
print(BALANCE)
sendNotification()
else:
print(BALANCE)
print 'Kahjit got warez if you got coin'
time.sleep(60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment