|
|
|
@@ -26,6 +26,9 @@ picdir = os.path.realpath("/home/firestone/pi-zero-tank/pic") |
|
|
|
libdir = os.path.realpath("/home/firestone/pi-zero-tank/lib") |
|
|
|
if os.path.exists(libdir): |
|
|
|
sys.path.append(libdir) |
|
|
|
else: |
|
|
|
print("Invalid path: " + libdir) |
|
|
|
sys.exit(0) |
|
|
|
|
|
|
|
print(f"Pfad zu Grafik: {picdir}") |
|
|
|
print(f"Pfad zu e-Paper-Bibliothek: {libdir}") |
|
|
|
@@ -39,7 +42,7 @@ logging.basicConfig(level=logging.DEBUG) |
|
|
|
|
|
|
|
NUM_SAMPLES = 100 |
|
|
|
AVG_WINDOWSIZE = 20 |
|
|
|
FILE = Path("config.ini") |
|
|
|
FILE = Path(os.path.dirname(os.path.realpath(__file__)), "config.ini") |
|
|
|
ALARM_LEVEL_CM = 5.0 |
|
|
|
|
|
|
|
smtp_port = 587 |
|
|
|
@@ -203,9 +206,11 @@ def get_percent(leer, voll, val): |
|
|
|
return abs(leer - val) / abs(leer - voll) * 100 |
|
|
|
|
|
|
|
def send_email(meas, val): |
|
|
|
with open("password.txt", "r") as f: |
|
|
|
smtp_password = f.readline() |
|
|
|
message = """\ |
|
|
|
try: |
|
|
|
pwpath = Path(os.path.dirname(os.path.realpath(__file__)), "password.txt") |
|
|
|
with open(pwpath, "r") as f: |
|
|
|
smtp_password = f.readline() |
|
|
|
message = """\ |
|
|
|
FROM: {1} |
|
|
|
TO: {2} |
|
|
|
Subject: {0}-Tank fast leer! |
|
|
|
@@ -217,13 +222,16 @@ Die Fuellhoehe des {0}-Tanks ist zu niedrig. Bitte pruefen! |
|
|
|
Die aktuelle Hoehe betraegt {3:.0f} cm. |
|
|
|
|
|
|
|
Gruesse vom Tank-Computer""".format(meas, sender_email, receiver_email, val) |
|
|
|
context = ssl.create_default_context() |
|
|
|
with smtplib.SMTP(smtp_server, smtp_port) as server: |
|
|
|
#server.set_debuglevel(1) |
|
|
|
server.ehlo() |
|
|
|
server.starttls(context=context) |
|
|
|
server.login(sender_email, smtp_password.strip()) |
|
|
|
server.sendmail(sender_email, receiver_email, message) |
|
|
|
context = ssl.create_default_context() |
|
|
|
with smtplib.SMTP(smtp_server, smtp_port) as server: |
|
|
|
#server.set_debuglevel(1) |
|
|
|
server.ehlo() |
|
|
|
server.starttls(context=context) |
|
|
|
server.login(sender_email, smtp_password.strip()) |
|
|
|
server.sendmail(sender_email, receiver_email, message) |
|
|
|
except Exception as e: |
|
|
|
print("Could not send E-mail") |
|
|
|
print(e) |
|
|
|
|
|
|
|
def display_site_measure(epd, titel, titel_pos, val): |
|
|
|
dp = Image.new('1', (epd.height, epd.width), 255) |
|
|
|
|