I hate python, it’s not friendly to my eyes.  That being said the compiler is super helpful.  And yes, I’m still alive despite the best efforts of …. myself.

I’m throwing together a raspberry pi zero powered uptime checker and an i2c backpack lcd display. I didn’t want to write my own library, and I wanted this to get thrown together as fast and easily as possible. Thus, I followed this guide using python. Python, ick.

But I’m not posting this to hate on anything. If I post more info on this, then I’ll share my logic for things. Anyway, one of the reasons for this display is an easy was to check the status of my DMR repeater. Here is the basic code I banged together to use the Project Halligan API that Brandmeister provides to check the status of my repeater.

Of note: Brandmeister does not provide an API call that tells you if the repeater is up or down. The website checks the last seen time and if it’s been more then 15 minutes it assumes that repeater is down. Checking against “status” or “status_text” will not tell you if the repeater is up or down merely what timeslots are linked – whether the repeater is connected or not.

import urllib.request, json
from datetime import datetime, timezone, timedelta
from email.utils import formatdate

	url = urllib.request.urlopen("https://api.brandmeister.network/v2/device/313051")
except urllib.error.URLError as e:
	ResponseData = e.reason
	print (ResponseData)
	lastSeen= (json.load(url)['last_seen'])
	print (lastSeen)
	timeOutTime = datetime.now(timezone.utc) - timedelta(minutes=15)
	timeOutString = timeOutTime.strftime("%Y-%m-%d %H:%M:%S")
	print (timeOutString)

	if timeOutString < lastSeen:
		print ("Repeater up")
		print ("Repeater Down")

This code isn't pretty but it does work, on my machine at least. The post however, is most certainly honest.