From ccd78f4c4872be63f03f102fcfd5acd6a884a361 Mon Sep 17 00:00:00 2001 From: Mike Cifelli Date: Wed, 3 Apr 2024 14:09:11 -0400 Subject: [PATCH] Allow multiple push servers --- garage.py | 13 ++++++------- garage.sample.cfg | 7 ++++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/garage.py b/garage.py index 9589388..9cff6a9 100644 --- a/garage.py +++ b/garage.py @@ -14,9 +14,7 @@ config = ConfigParser() config.read('garage.cfg') eastPin = config['garage'].getint('east-pin') westPin = config['garage'].getint('west-pin') -ntfy = config['push'].get('ntfy') -topic = config['push'].get('topic') -auth = config['push'].get('auth') +ntfyList = json.loads(config['push'].get('ntfy')) def main(): @@ -70,10 +68,11 @@ def persistState(): def sendNotification(): - requests.post( - url=f'https://{ntfy}/{topic}?auth={auth}', - data='update'.encode(encoding='utf-8') - ) + for ntfy in ntfyList: + requests.post( + url=f'https://{ntfy["host"]}/{ntfy["topic"]}?auth={ntfy["auth"]}', + data='update'.encode(encoding='utf-8') + ) if __name__ == '__main__': diff --git a/garage.sample.cfg b/garage.sample.cfg index 487d15c..a95df89 100644 --- a/garage.sample.cfg +++ b/garage.sample.cfg @@ -3,6 +3,7 @@ east-pin=1 west-pin=2 [push] -ntfy=ntfy.sh -topic=topic -auth=auth +ntfy=[ + {"host": "localhost", "topic": "topic", "auth": "auth"}, + {"host": "ntfy.sh", "topic": "topic", "auth": "auth"} + ]