From 74232ef4a2c20132a9b3837980ccefd79139ce9d Mon Sep 17 00:00:00 2001 From: William Moore Date: Sun, 27 Feb 2022 02:54:02 -0600 Subject: [PATCH] Upgrade to Mattermost incoming hooks integration. --- temperato.py | 5 +++-- temperato.service | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/temperato.py b/temperato.py index b92bc91..7e29022 100644 --- a/temperato.py +++ b/temperato.py @@ -21,6 +21,7 @@ import requests import threading import time import os +import json set_point = 95.0 @@ -32,9 +33,9 @@ class tempThread (threading.Thread): def run(self): while True: temp = sensor.temperature - print(temp) if temp > set_point: - requests.post(os.environ.get('NOTIF_URL'), data={'message': 'The water is too damn hot!', 'title': 'Water temperature', 'priority': 9}, timeout=5) + print({'text': '@all The water is too damn hot!', 'channel': os.environ.get('CHANNEL_ID')}) + print(requests.post(os.environ.get('NOTIF_URL'), headers={'Content-Type': 'application/json'}, data=json.dumps({'text': '@all The water is too damn hot!', 'channel': os.environ.get('CHANNEL_ID')}))) time.sleep(5) T_thread = tempThread() diff --git a/temperato.service b/temperato.service index 96e8f41..e0553ca 100644 --- a/temperato.service +++ b/temperato.service @@ -2,7 +2,8 @@ Description=Temperato Service [Service] -Environment=NOTIF_URL= +Environment=NOTIF_URL= +Environment=CHANNEL_ID= ExecStart=python3 temperato.py ExecReload=python3 temperato.py KillMode=process