Allow multiple push servers
This commit is contained in:
parent
a51d5f7ff2
commit
ccd78f4c48
13
garage.py
13
garage.py
|
@ -14,9 +14,7 @@ config = ConfigParser()
|
||||||
config.read('garage.cfg')
|
config.read('garage.cfg')
|
||||||
eastPin = config['garage'].getint('east-pin')
|
eastPin = config['garage'].getint('east-pin')
|
||||||
westPin = config['garage'].getint('west-pin')
|
westPin = config['garage'].getint('west-pin')
|
||||||
ntfy = config['push'].get('ntfy')
|
ntfyList = json.loads(config['push'].get('ntfy'))
|
||||||
topic = config['push'].get('topic')
|
|
||||||
auth = config['push'].get('auth')
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -70,10 +68,11 @@ def persistState():
|
||||||
|
|
||||||
|
|
||||||
def sendNotification():
|
def sendNotification():
|
||||||
requests.post(
|
for ntfy in ntfyList:
|
||||||
url=f'https://{ntfy}/{topic}?auth={auth}',
|
requests.post(
|
||||||
data='update'.encode(encoding='utf-8')
|
url=f'https://{ntfy["host"]}/{ntfy["topic"]}?auth={ntfy["auth"]}',
|
||||||
)
|
data='update'.encode(encoding='utf-8')
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -3,6 +3,7 @@ east-pin=1
|
||||||
west-pin=2
|
west-pin=2
|
||||||
|
|
||||||
[push]
|
[push]
|
||||||
ntfy=ntfy.sh
|
ntfy=[
|
||||||
topic=topic
|
{"host": "localhost", "topic": "topic", "auth": "auth"},
|
||||||
auth=auth
|
{"host": "ntfy.sh", "topic": "topic", "auth": "auth"}
|
||||||
|
]
|
||||||
|
|
Loading…
Reference in New Issue