def timetable(): haltestelle = "Koeln Hbf" try: fplan = fpl.getFahrplan() except Exception as e: oled.oPrint("\n" + oled.center("FEHLER (Fahrplan)") + "\n" + str(e)) time.sleep(INTERVALL) else: if fplan: for i in range(0, len(fplan)): if ((fplan[i].dest == "") or (fplan[i].train == "")): #Fehlerhafte Daten nicht anzeigen continue depart = fplan[i].timeDepart if (fplan[i].delay > 0): depart = "(+" + str( fplan[i].delay) + ")" + fplan[i].timeDepart oled.oPrint( oled.concat(haltestelle, fplan[i].platform) + "\n---------------------\n" + oled.concat(fplan[i].train, depart) + "\n" + fplan[i].via + "\n" + fplan[i].dest + "\n" + fplan[i].messages) time.sleep(INTERVALL / 2) else: oled.oPrint(haltestelle + "\n---------------------\n\n" + oled.center("Keine Abfahrten") + "\n" + oled.center("gefunden!")) time.sleep(INTERVALL / 2)
def piholeStatus(): device = oled.getDevice() with canvas(device, dither=None) as draw: queries = pihole.getQueries() blocked = pihole.getBlocked() percentage = pihole.getPercentage() if pihole.getStatus(): ph_status = "(Running)" else: ph_status = "(Stopped)" if ((queries == -1) or (blocked == -1) or (percentage == -1)): oled.oPrint(oled.center("PiHole") + "\n\n" + oled.center("Fehler")) else: fnt = oled.getFont() draw.text((0, 0), font=fnt, text=oled.center("PiHole " + ph_status)) draw.text((0, 20), font=fnt, text=oled.concat("Queries:", queries)) draw.text((0, 30), font=fnt, text=oled.concat("Blocking:", blocked)) draw.text((0, 40), font=fnt, text=oled.concat("Percent:", str(percentage) + "%")) pct_bar = 127 * (percentage / 100) draw.rectangle((pct_bar, 63, 0, 50), fill="white") draw.rectangle((127, 63, 0, 50), outline="grey") time.sleep(INTERVALL)
def piholeStatus(): if (DEBUG): print('piHole Status') device = oled.getDevice() try: piholeip = cfg['pihole']['ip'] except Exception as e: oled.scPrint(oled.center('Error [PiHole]'), '', oled.center('Could not'), oled.center('find config!')) time.sleep(INTERVALL) return for i in range(0, INTERVALL): #refresh every second for INTERVALL times with canvas(device, dither=None) as draw: queries = pihole.getQueries(piholeip) blocked = pihole.getBlocked(piholeip) percentage = pihole.getPercentage(piholeip) if pihole.getStatus(piholeip): ph_status = "(Active)" else: ph_status = "(STOPPED)" if ((queries == -1) or (blocked == -1) or (percentage == -1)): oled.oPrint( oled.center("PiHole") + "\n\n" + oled.center("Fehler")) else: fnt = oled.getFont() draw.text((0, 0), font=fnt, text=oled.center("PiHole " + ph_status)) draw.text((0, 20), font=fnt, text=oled.concat("Queries:", queries)) draw.text((0, 30), font=fnt, text=oled.concat("Blocking:", blocked)) draw.text((0, 40), font=fnt, text=oled.concat("Percentage:", str(percentage) + "%")) pct_bar = 127 * (percentage / 100) draw.rectangle((pct_bar, 63, 0, 50), fill="white") draw.rectangle((127, 63, 0, 50), outline="grey") time.sleep(1)
def pistatus(): temp = os.popen('vcgencmd measure_temp').read() tempprint = temp[(temp.rfind("=") + 1):] tempprint = tempprint[:4] try: ip = url.urlopen('http://api.ipify.org').read() except: ip = "Offline" temp = os.popen('vcgencmd measure_volts').read() voltprint = temp[(temp.rfind("=") + 1):] voltprint = voltprint[:7] oled.oPrint( oled.center("Pi Status") + "\n\n" + oled.concat("CPU-Temp: ", str(tempprint + degreeSymbol)) + "\n" + oled.concat("CPU-Volt: ", str(voltprint)) + "\n" + oled.concat("IP: ", str(ip))) time.sleep(INTERVALL)
def __oldPiholeStatus(): queries = pihole.getQueries() blocked = pihole.getBlocked() percentage = pihole.getPercentage() if pihole.getStatus(): ph_status = "(Running)" else: ph_status = "(Stopped)" if ((queries == -1) or (blocked == -1) or (percentage == -1)): oled.oPrint( oled.center("PiHole " + chr(4)) + "\n\n" + oled.center("Fehler")) else: oled.oPrint( oled.center("PiHole " + ph_status) + "\n" + oled.concat("Queries: ", str(queries)) + "\n" + oled.concat("Blocked: ", str(blocked)) + "\n" + oled.concat("Percentage: ", str(percentage) + "%")) time.sleep(INTERVALL)
def timetable(): if (DEBUG): print('Timetable') try: station = cfg['timetable']['station'] except Exception as e: oled.scPrint(oled.center('Error [Timetable]'), '', oled.center('Could not'), oled.center('find config!')) time.sleep(INTERVALL) return try: fplan = ttb.getFahrplan(station) except Exception as e: oled.scPrint(oled.center('Error [Timetable]', '', str(e))) time.sleep(INTERVALL) else: if fplan: for i in range(0, len(fplan)): if ((fplan[i].dest == "") or (fplan[i].train == "")): #Fehlerhafte Daten nicht anzeigen continue depart = fplan[i].timeDepart if (fplan[i].delay > 0): depart = "(+" + str( fplan[i].delay) + ")" + fplan[i].timeDepart oled.scPrint(oled.concat(station, fplan[i].platform), "---------------------", oled.concat(fplan[i].train, depart), umlaute(fplan[i].via), umlaute(fplan[i].dest), umlaute(fplan[i].messages)) time.sleep(INTERVALL / 2) else: oled.scPrint(station, "---------------------", "", oled.center("No departures"), oled.center("found!")) time.sleep(INTERVALL / 2)
def pistatus(): if (DEBUG): print('PiStatus') temp = os.popen('vcgencmd measure_temp').read() tempprint = temp[(temp.rfind("=") + 1):] tempprint = tempprint[:4] try: ip = url.urlopen('https://api.ipify.org').read() #ip = "-" except: ip = "Offline" temp = os.popen('vcgencmd measure_volts').read() voltprint = temp[(temp.rfind("=") + 1):] voltprint = voltprint[:7] oled.oPrint( oled.center("Pi Status") + "\n\n" + oled.concat("CPU-Temp: ", str(tempprint + '°C')) + "\n" + oled.concat("CPU-Volt: ", str(voltprint)) + "\n" + oled.concat("IP: ", str(ip.decode('utf-8')))) time.sleep(INTERVALL)
def storm(): if (DEBUG): print('Storm') try: u_in = open("storm.wtd", "r") except Exception as e: oled.oPrint("\n" + oled.center("Fehler Unwetter") + "\n" + str(e)) u_in.close() else: #Amtliche Warnung try: w_count = u_in.readline().rstrip() except Exception as e: oled.oPrint("\n" + oled.center("Fehler Unwetter") + "\n" + oled.center(str(e))) time.sleep(INTERVALL) else: try: int(w_count) except: return if (str(w_count) == 'error'): oled.oPrint( oled.center("Unwetter") + "\n\n" + oled.center("Fehler beim Abrufen!")) time.sleep(INTERVALL / 2) return if int(w_count) > 0: try: w_region = umlaute(u_in.readline().rstrip()) for i in range(0, int(w_count)): w_headline = umlaute(u_in.readline().rstrip()) w_description = umlaute(u_in.readline().rstrip()) w_start = u_in.readline().rstrip() w_end = u_in.readline().rstrip() oled.oPrint( w_region + "\n\n" + w_headline + "\n" + w_description + "\n" + oled.concat('', w_start) + "\n" + oled.concat('(' + str(i + 1) + "|" + w_count + ")", w_end)) time.sleep(INTERVALL / 2) except Exception as e: oled.oPrint("\n" + oled.center("Fehler Unwetter") + "\n" + oled.center(str(e))) time.sleep(INTERVALL) #Vorwarnung try: v_count = u_in.readline().rstrip() except Exception as e: oled.oPrint("\n" + oled.center("Fehler Unwetter") + "\n" + oled.center(str(e))) time.sleep(INTERVALL) else: if int(v_count) > 0: try: v_region = umlaute(u_in.readline().rstrip()) for i in range(0, int(v_count)): v_headline = umlaute(u_in.readline().rstrip()) v_description = umlaute(u_in.readline().rstrip()) oled.oPrint(v_region + "\n\n" + v_headline + "\n" + v_description + "\n\n(" + str(i + 1) + "|" + v_count + ")") time.sleep(INTERVALL / 2) except Exception as e: oled.oPrint("\n" + oled.center("Fehler Unwetter") + "\n" + oled.center(str(e))) time.sleep(INTERVALL)