<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/python3

import requests
import requests.auth
import pprint
import hashlib
import json
import sys
import re
import time
import ExceptionHandler
from sense_hat import SenseHat

pp = pprint.PrettyPrinter()

user = "admin"
pwd = "Easypost12"
monitorIP = "192.168.1.192"

sense = SenseHat()
sense.low_light = True
sense.set_rotation(180)
sense.clear()

while True:
	try:
		monitorSession = requests.Session()
		#monitorSession.auth = requests.auth.HTTPDigestAuth("admin", "Easypost12")
		monitorSession.auth = requests.auth.HTTPBasicAuth("admin", "Easypost12")
		
		pwrUrl = "http://" + monitorIP + "/emeter/0"
		while True:
			response = monitorSession.get(pwrUrl)
			jsonResp = response.json()
			print("Power: " + str(jsonResp['power']))
			power = jsonResp['power']
			
			y = 0
			while y &lt; 8:
				x = 0
				while x &lt; 8:
					if(power &lt; 0):
						if(y &lt; 4):
							col = [0, 0, 0]
						else:
							if((((y - 4) * 8) + x) * -100 &gt; power):
								col = [0, 255, 0]
							else:
								col = [0, 0, 0]
					else:
						if(y &lt; 4):
							if((((3 - y) * 8) + x) * 100 &gt; power):
								col = [0, 0, 0]
							else:
								col = [255, 0, 0]
						else:
							col = [0, 0, 0]
					#print("x: %d    y: %d   col: %s" % (x, y, col))
					sense.set_pixel(x, 7 - y, col);
					x += 1
				y += 1
			
			time.sleep(1)
	except Exception as exc:
		print(ExceptionHandler.FullStack(sys.exc_info()))
		monitorSession.close()

sys.exit()


</pre></body></html>