Skip to content

Instantly share code, notes, and snippets.

@spynappels
Last active November 28, 2017 21:57
Show Gist options
  • Save spynappels/2365c5eaadef1494c33508bb1c502838 to your computer and use it in GitHub Desktop.
Save spynappels/2365c5eaadef1494c33508bb1c502838 to your computer and use it in GitHub Desktop.
Simple and dirty monitoring script for repeaters connected to a Brandmeister Master server, written in Python3 and using the Pi Hut Status Board (https://thepihut.com/products/status-board-pro)
#!/usr/bin/python3
from gpiozero import StatusBoard
import requests
import time
# instantiate a StatusBoard instance
status = StatusBoard('gb7ny', 'gb7hi', 'gb7mw','gb7ah','gb7ni')
# define the check function
def bmcheck():
# This URL is for the Brandmeister UK Master, substitute your own
r = requests.get('http://91.121.101.163/status/list.php')
data = r.json()
status.gb7ny.lights.green.off()
status.gb7hi.lights.green.off()
status.gb7mw.lights.green.off()
status.gb7ah.lights.green.off()
status.gb7ni.lights.green.off()
status.gb7ny.lights.red.on()
status.gb7hi.lights.red.on()
status.gb7mw.lights.red.on()
status.gb7ah.lights.red.on()
status.gb7ni.lights.red.on()
# check for each repeater in turn
for i in range(len(data)):
if data[i]['number'] == 235510:
status.gb7ny.lights.green.on()
status.gb7ny.lights.red.off()
for i in range(len(data)):
if data[i]['number'] == 235526:
status.gb7hi.lights.green.on()
status.gb7hi.lights.red.off()
for i in range(len(data)):
if data[i]['number'] == 235506:
status.gb7mw.lights.green.on()
status.gb7mw.lights.red.off()
for i in range(len(data)):
if data[i]['number'] == 235507:
status.gb7ah.lights.green.on()
status.gb7ah.lights.red.off()
for i in range(len(data)):
if data[i]['number'] == 235516:
status.gb7ni.lights.green.on()
status.gb7ni.lights.red.off()
time.sleep(60)
# Run the function forever
while True:
bmcheck()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment