From cb917fbd9f9d5264c694d19e2c04ac606a451d0b Mon Sep 17 00:00:00 2001 From: firstof9 Date: Thu, 17 Jun 2021 07:34:53 -0700 Subject: [PATCH] fix: fix nomail image in get_mails function --- custom_components/mail_and_packages/helpers.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/custom_components/mail_and_packages/helpers.py b/custom_components/mail_and_packages/helpers.py index e96f18c5..091031e3 100644 --- a/custom_components/mail_and_packages/helpers.py +++ b/custom_components/mail_and_packages/helpers.py @@ -286,6 +286,11 @@ def fetch( image_name = data[const.ATTR_IMAGE_NAME] amazon_image_name = data[const.ATTR_AMAZON_IMAGE] + if config.get(const.CONF_CUSTOM_IMG): + nomail = config.get(const.CONF_CUSTOM_IMG_FILE) + else: + nomail = None + if sensor in data: return data[sensor] @@ -298,6 +303,7 @@ def fetch( gif_duration, image_name, generate_mp4, + nomail, ) elif sensor == const.AMAZON_PACKAGES: count[sensor] = get_items(account, const.ATTR_COUNT, amazon_fwds) @@ -472,6 +478,7 @@ def get_mails( gif_duration: int, image_name: str, gen_mp4: bool = False, + custom_img: str = None, ) -> int: """Creates GIF image based on the attachments in the inbox""" image_count = 0 @@ -595,10 +602,11 @@ def get_mails( try: _LOGGER.debug("Copying nomail gif") - copyfile( - os.path.dirname(__file__) + "/mail_none.gif", - image_output_path + image_name, - ) + if custom_img is not None: + nomail = custom_img + else: + nomail = os.path.dirname(__file__) + "/mail_none.gif" + copyfile(nomail, image_output_path + image_name) except Exception as err: _LOGGER.error("Error attempting to copy image: %s", str(err))