Make the message configurable

This commit is contained in:
William Moore 2022-03-02 21:11:56 -06:00
parent ce562af54f
commit 42a5956d63
2 changed files with 2 additions and 1 deletions

View File

@ -5,6 +5,7 @@ Description=Temperato Service
Environment=NOTIF_URL=<your mattermost incoming webhook>
Environment=CHANNEL_ID=<your mattermost channel id>
Environment=ACCESS_TOKEN=<your mattermost access token>
Environment=MESSAGE=<your mattermost message>
ExecStart=python3 temperato.py
ExecReload=python3 temperato.py
KillMode=process

View File

@ -36,7 +36,7 @@ class tempThread (threading.Thread):
temp = sensor.temperature
if temp >= set_point:
print('Bearer ' + os.environ.get('ACCESS_TOKEN'))
print(requests.post(os.environ.get('NOTIF_URL'), headers={'Content-Type': 'application/json', 'Authorization': 'Bearer ' + os.environ.get('ACCESS_TOKEN')}, data=json.dumps({'message': '@all The water is too damn hot!', 'channel_id': os.environ.get('CHANNEL_ID')}), timeout=5))
print(requests.post(os.environ.get('NOTIF_URL'), headers={'Content-Type': 'application/json', 'Authorization': 'Bearer ' + os.environ.get('ACCESS_TOKEN')}, data=json.dumps({'message': '@all ' + os.environ.get('MESSAGE'), 'channel_id': os.environ.get('CHANNEL_ID')}), timeout=5))
time.sleep(sleep_timer)
T_thread = tempThread()