From 3327636da5644e705b124c59e4ef5f2623268718 Mon Sep 17 00:00:00 2001 From: Cyril SAINT-YVES Date: Sat, 18 May 2019 12:03:26 +0200 Subject: [PATCH] Make Discord payload data key not required --- homeassistant/components/discord/notify.py | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/discord/notify.py b/homeassistant/components/discord/notify.py index 5a9cb77877dc03..2e3d2eee9e910c 100644 --- a/homeassistant/components/discord/notify.py +++ b/homeassistant/components/discord/notify.py @@ -53,21 +53,20 @@ async def async_send_message(self, message, **kwargs): _LOGGER.error("No target specified") return None - if ATTR_DATA in kwargs: - data = kwargs.get(ATTR_DATA) + data = kwargs.get(ATTR_DATA) or {} - if ATTR_IMAGES in data: - images = list() + if ATTR_IMAGES in data: + images = list() - for image in data.get(ATTR_IMAGES): - image_exists = await self.hass.async_add_executor_job( - self.file_exists, - image) + for image in data.get(ATTR_IMAGES): + image_exists = await self.hass.async_add_executor_job( + self.file_exists, + image) - if image_exists: - images.append(image) - else: - _LOGGER.warning("Image not found: %s", image) + if image_exists: + images.append(image) + else: + _LOGGER.warning("Image not found: %s", image) # pylint: disable=unused-variable @discord_bot.event