From aa57907c1878b5d7bdaf258e0b135c189abb8f27 Mon Sep 17 00:00:00 2001 From: d6e Date: Wed, 16 Mar 2022 13:16:38 -0700 Subject: [PATCH] Improve logging for Discord integration (#68160) --- homeassistant/components/discord/notify.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/discord/notify.py b/homeassistant/components/discord/notify.py index 2e13b68225c..7c4b10f5662 100644 --- a/homeassistant/components/discord/notify.py +++ b/homeassistant/components/discord/notify.py @@ -49,8 +49,12 @@ class DiscordNotificationService(BaseNotificationService): def file_exists(self, filename): """Check if a file exists on disk and is in authorized path.""" if not self.hass.config.is_allowed_path(filename): + _LOGGER.warning("Path not allowed: %s", filename) return False - return os.path.isfile(filename) + if not os.path.isfile(filename): + _LOGGER.warning("Not a file: %s", filename) + return False + return True async def async_send_message(self, message, **kwargs): """Login to Discord, send message to channel(s) and log out.""" @@ -98,8 +102,6 @@ class DiscordNotificationService(BaseNotificationService): if image_exists: images.append(image) - else: - _LOGGER.warning("Image not found: %s", image) await discord_bot.login(self.token)