Skip to content

Commit

Permalink
Added logging
Browse files Browse the repository at this point in the history
  • Loading branch information
yozik04 committed Aug 26, 2024
1 parent 1cd2964 commit 18f3de9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion paradox/interfaces/text/homeassistant_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def send_message(self, message: str, level: EventLevel):

res = requests.post(url, json=payload, headers=headers)
if res.status_code == 200:
logger.debug(f"Notification sent: {message}, level={level}")
logger.info(f"Notification sent: {message}, level={level}")
else:
logger.error(
f"Failed to send notification: code={res.status_code}, text: {res.text}"
Expand Down
14 changes: 8 additions & 6 deletions paradox/interfaces/text/pushover.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

import logging
import re

Expand Down Expand Up @@ -37,7 +35,7 @@ def __init__(self, alarm):
self.users = {}

def _run(self):
super(PushoverTextInterface, self)._run()
super()._run()

self.app = chump.Application(cfg.PUSHOVER_KEY)
if not self.app.is_authenticated:
Expand All @@ -50,7 +48,7 @@ def send_message(self, message: str, level: EventLevel):
user_key = settings["user_key"]
devices_raw = settings["devices"]

user = self.users.get(user_key) # type: chump.User
user = self.users.get(user_key)

if user is None:
user = self.users[user_key] = self.app.get_user(user_key)
Expand All @@ -68,7 +66,8 @@ def send_message(self, message: str, level: EventLevel):
title="Alarm",
priority=_level_2_priority.get(level, chump.NORMAL),
)
except:
logger.info(f"Notification sent: {message}, level={level}")
except Exception:
logger.exception("Pushover send message")

else:
Expand All @@ -88,7 +87,10 @@ def send_message(self, message: str, level: EventLevel):
device=device,
priority=_level_2_priority.get(level, chump.NORMAL),
)
except:
logger.info(
f"Notification sent: {message}, level={level}, device={device}"
)
except Exception:
logger.exception("Pushover send message")

# TODO: Missing the message reception

0 comments on commit 18f3de9

Please sign in to comment.