From caa5c088cc09a69de632aeb8b29ff54465cd8459 Mon Sep 17 00:00:00 2001 From: William Moore Date: Sat, 9 Apr 2022 04:07:09 -0500 Subject: [PATCH] Major overhaul --- .env.template | 6 ++++++ requirements.txt | 6 ++++++ systemd/temperato-host.service | 14 ++++++++++++++ systemd/temperato.service | 4 ---- temperato.py | 8 +++++--- 5 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 .env.template create mode 100644 requirements.txt create mode 100644 systemd/temperato-host.service diff --git a/.env.template b/.env.template new file mode 100644 index 0000000..8ccb054 --- /dev/null +++ b/.env.template @@ -0,0 +1,6 @@ +XMPP_RECEIVER= +XMPP_SENDER= +XMPP_SENDER_PASSWORD= +SET_POINT=82.22 +MESSAGE="The water is too damn hot! :tea:" + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..d64c09e --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +Adafruit_Blinka==6.16.0 +adafruit_circuitpython_max31865==2.2.10 +Flask==1.1.2 +python-dotenv==0.20.0 +requests==2.25.1 +xmpppy==0.7.0 diff --git a/systemd/temperato-host.service b/systemd/temperato-host.service new file mode 100644 index 0000000..b94beac --- /dev/null +++ b/systemd/temperato-host.service @@ -0,0 +1,14 @@ +[Unit] +Description=Temperato Host Service + +[Service] +Environment=FLASK_APP=web +ExecStart=flask run +ExecReload=flask run +KillMode=process +Restart=on-failure +Type=simple +WorkingDirectory= + +[Install] +WantedBy=multi-user.target diff --git a/systemd/temperato.service b/systemd/temperato.service index 40c5c89..719ce13 100644 --- a/systemd/temperato.service +++ b/systemd/temperato.service @@ -2,10 +2,6 @@ Description=Temperato Service [Service] -Environment=NOTIF_URL= -Environment=CHANNEL_ID= -Environment=ACCESS_TOKEN= -Environment=MESSAGE= ExecStart=python3 temperato.py ExecReload=python3 temperato.py KillMode=process diff --git a/temperato.py b/temperato.py index d785538..f8bbf42 100644 --- a/temperato.py +++ b/temperato.py @@ -23,13 +23,15 @@ import time import os import json import xmpp +from dotenv import load_dotenv -set_point = 82.22 +load_dotenv() + +set_point = float(os.environ.get('SET_POINT')) sleep_timer = 1 tick_threshold = 5 - spi = board.SPI() -cs = digitalio.DigitalInOut(board.D26) +cs = digitalio.DigitalInOut(getattr(board,os.environ.get('INPUT_PIN'))) sensor = adafruit_max31865.MAX31865(spi, cs, wires=3) jid = xmpp.protocol.JID(os.environ.get('XMPP_SENDER')) conn = xmpp.Client(server=jid.getDomain(), debug=False)