Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
aneisch committed Mar 19, 2024
1 parent 663bcaa commit b9fef96
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 56 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Build Status](https://github.com/aneisch/home-assistant-config/actions/workflows/check-ha-release-compatibility.yml/badge.svg)](https://github.com/aneisch/home-assistant-config/actions)
[![GitHub last commit](https://img.shields.io/github/last-commit/aneisch/home-assistant-config)](https://github.com/aneisch/home-assistant-config/commits/master)
[![GitHub commit activity](https://img.shields.io/github/commit-activity/y/aneisch/home-assistant-config)](https://github.com/aneisch/home-assistant-config/graphs/commit-activity)
[![HA Version](https://img.shields.io/badge/Running%20Home%20Assistant-2024.3.0%20(Latest)-brightgreen)](https://github.com/home-assistant/home-assistant/releases/latest)
[![HA Version](https://img.shields.io/badge/Running%20Home%20Assistant-2024.3.1%20(Latest)-brightgreen)](https://github.com/home-assistant/home-assistant/releases/latest)
<br><a href="https://www.buymeacoffee.com/aneisch" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-black.png" width="150px" height="35px" alt="Buy Me A Coffee" style="height: 35px !important;width: 150px !important;" ></a>


Expand Down Expand Up @@ -71,7 +71,7 @@ Entities in the [`camera`](https://www.home-assistant.io/components/camera) doma
Entities in the [`climate`](https://www.home-assistant.io/components/climate) domain | 1
Entities in the [`counter`](https://www.home-assistant.io/components/counter) domain | 1
Entities in the [`cover`](https://www.home-assistant.io/components/cover) domain | 13
Entities in the [`device_tracker`](https://www.home-assistant.io/components/device_tracker) domain | 3
Entities in the [`device_tracker`](https://www.home-assistant.io/components/device_tracker) domain | 2
Entities in the [`event`](https://www.home-assistant.io/components/event) domain | 50
Entities in the [`fan`](https://www.home-assistant.io/components/fan) domain | 3
Entities in the [`group`](https://www.home-assistant.io/components/group) domain | 17
Expand All @@ -91,17 +91,17 @@ Entities in the [`remote`](https://www.home-assistant.io/components/remote) doma
Entities in the [`scene`](https://www.home-assistant.io/components/scene) domain | 2
Entities in the [`script`](https://www.home-assistant.io/components/script) domain | 56
Entities in the [`select`](https://www.home-assistant.io/components/select) domain | 3
Entities in the [`sensor`](https://www.home-assistant.io/components/sensor) domain | 446
Entities in the [`sensor`](https://www.home-assistant.io/components/sensor) domain | 441
Entities in the [`siren`](https://www.home-assistant.io/components/siren) domain | 1
Entities in the [`sun`](https://www.home-assistant.io/components/sun) domain | 1
Entities in the [`switch`](https://www.home-assistant.io/components/switch) domain | 165
Entities in the [`switch`](https://www.home-assistant.io/components/switch) domain | 160
Entities in the [`timer`](https://www.home-assistant.io/components/timer) domain | 6
Entities in the [`tts`](https://www.home-assistant.io/components/tts) domain | 1
Entities in the [`update`](https://www.home-assistant.io/components/update) domain | 35
Entities in the [`vacuum`](https://www.home-assistant.io/components/vacuum) domain | 1
Entities in the [`weather`](https://www.home-assistant.io/components/weather) domain | 2
Entities in the [`zone`](https://www.home-assistant.io/components/zone) domain | 6
**Total state objects** | **1291**
**Total state objects** | **1280**
## The HACS integrations/plugins that I use:
**Appdaemon**:<br>
[aneisch/follow_me_appdaemon](https://github.com/aneisch/follow_me_appdaemon)<br>
Expand Down
45 changes: 19 additions & 26 deletions custom_components/mail_and_packages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
CONF_SCAN_INTERVAL,
COORDINATOR,
DEFAULT_AMAZON_DAYS,
DEFAULT_AMAZON_FWDS,
DEFAULT_IMAP_TIMEOUT,
DOMAIN,
ISSUE_URL,
Expand Down Expand Up @@ -69,16 +70,6 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
# Sort the resources
updated_config[CONF_RESOURCES] = sorted(updated_config[CONF_RESOURCES])

# Make sure amazon forwarding emails are not a string
if isinstance(updated_config[CONF_AMAZON_FWDS], str):
tmp = updated_config[CONF_AMAZON_FWDS]
tmp_list = []
if "," in tmp:
tmp_list = tmp.split(",")
else:
tmp_list.append(tmp)
updated_config[CONF_AMAZON_FWDS] = tmp_list

if updated_config != config_entry.data:
hass.config_entries.async_update_entry(config_entry, data=updated_config)

Expand Down Expand Up @@ -156,6 +147,7 @@ async def update_listener(hass: HomeAssistant, config_entry: ConfigEntry) -> Non
async def async_migrate_entry(hass, config_entry):
"""Migrate an old config entry."""
version = config_entry.version
new_version = 5

# 1 -> 4: Migrate format
if version == 1:
Expand All @@ -182,11 +174,6 @@ async def async_migrate_entry(hass, config_entry):
# Add default Amazon Days configuration
updated_config[CONF_AMAZON_DAYS] = DEFAULT_AMAZON_DAYS

if updated_config != config_entry.data:
hass.config_entries.async_update_entry(
config_entry, data=updated_config, version=4
)

# 2 -> 4
if version == 2:
_LOGGER.debug("Migrating from version %s", version)
Expand All @@ -202,24 +189,26 @@ async def async_migrate_entry(hass, config_entry):
# Add default Amazon Days configuration
updated_config[CONF_AMAZON_DAYS] = DEFAULT_AMAZON_DAYS

if updated_config != config_entry.data:
hass.config_entries.async_update_entry(
config_entry, data=updated_config, version=4
)

if version == 3:
_LOGGER.debug("Migrating from version %s", version)
updated_config = config_entry.data.copy()

# Add default Amazon Days configuration
updated_config[CONF_AMAZON_DAYS] = DEFAULT_AMAZON_DAYS

if updated_config != config_entry.data:
hass.config_entries.async_update_entry(
config_entry, data=updated_config, version=4
)
if version == 4:
_LOGGER.debug("Migrating from version %s", version)
updated_config = config_entry.data.copy()

_LOGGER.debug("Migration complete")
if updated_config[CONF_AMAZON_FWDS] == ['""']:
updated_config[CONF_AMAZON_FWDS] = DEFAULT_AMAZON_FWDS

if updated_config != config_entry.data:
hass.config_entries.async_update_entry(
config_entry, data=updated_config, version=new_version
)

_LOGGER.debug("Migration complete to version %s", new_version)

return True

Expand All @@ -234,6 +223,7 @@ def __init__(self, hass, host, the_timeout, interval, config):
self.timeout = the_timeout
self.config = config
self.hass = hass
self._data = {}

_LOGGER.debug("Data will be update every %s", self.interval)

Expand All @@ -249,4 +239,7 @@ async def _async_update_data(self):
except Exception as error:
_LOGGER.error("Problem updating sensors: %s", error)
raise UpdateFailed(error) from error
return data

if data:
self._data = data
return self._data
26 changes: 15 additions & 11 deletions custom_components/mail_and_packages/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async def _check_amazon_forwards(forwards: str) -> tuple:
amazon_forwards_list = forwards.split(",")

# No forwards
elif forwards in ["", "(none)", ""]:
elif forwards in ["", "(none)", '""']:
amazon_forwards_list = []

# If only one address append it to the list
Expand Down Expand Up @@ -159,10 +159,10 @@ def _get_default(key: str, fallback_default: Any = None) -> None:

return vol.Schema(
{
vol.Required(CONF_HOST, default=_get_default(CONF_HOST)): str,
vol.Required(CONF_PORT, default=_get_default(CONF_PORT)): vol.Coerce(int),
vol.Required(CONF_USERNAME, default=_get_default(CONF_USERNAME)): str,
vol.Required(CONF_PASSWORD, default=_get_default(CONF_PASSWORD)): str,
vol.Required(CONF_HOST, default=_get_default(CONF_HOST)): cv.string,
vol.Required(CONF_PORT, default=_get_default(CONF_PORT, 993)): cv.port,
vol.Required(CONF_USERNAME, default=_get_default(CONF_USERNAME)): cv.string,
vol.Required(CONF_PASSWORD, default=_get_default(CONF_PASSWORD)): cv.string,
}
)

Expand All @@ -189,7 +189,9 @@ def _get_default(key: str, fallback_default: Any = None) -> None:
vol.Required(
CONF_RESOURCES, default=_get_default(CONF_RESOURCES)
): cv.multi_select(get_resources()),
vol.Optional(CONF_AMAZON_FWDS, default=_get_default(CONF_AMAZON_FWDS)): str,
vol.Optional(
CONF_AMAZON_FWDS, default=_get_default(CONF_AMAZON_FWDS)
): cv.string,
vol.Optional(CONF_AMAZON_DAYS, default=_get_default(CONF_AMAZON_DAYS)): int,
vol.Optional(
CONF_SCAN_INTERVAL, default=_get_default(CONF_SCAN_INTERVAL)
Expand All @@ -202,11 +204,13 @@ def _get_default(key: str, fallback_default: Any = None) -> None:
): vol.Coerce(int),
vol.Optional(
CONF_GENERATE_MP4, default=_get_default(CONF_GENERATE_MP4)
): bool,
): cv.boolean,
vol.Optional(
CONF_ALLOW_EXTERNAL, default=_get_default(CONF_ALLOW_EXTERNAL)
): bool,
vol.Optional(CONF_CUSTOM_IMG, default=_get_default(CONF_CUSTOM_IMG)): bool,
): cv.boolean,
vol.Optional(
CONF_CUSTOM_IMG, default=_get_default(CONF_CUSTOM_IMG)
): cv.boolean,
}
)

Expand All @@ -225,7 +229,7 @@ def _get_default(key: str, fallback_default: Any = None) -> None:
vol.Optional(
CONF_CUSTOM_IMG_FILE,
default=_get_default(CONF_CUSTOM_IMG_FILE, DEFAULT_CUSTOM_IMG_FILE),
): str,
): cv.string,
}
)

Expand All @@ -234,7 +238,7 @@ def _get_default(key: str, fallback_default: Any = None) -> None:
class MailAndPackagesFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
"""Config flow for Mail and Packages."""

VERSION = 4
VERSION = 5
CONNECTION_CLASS = config_entries.CONN_CLASS_CLOUD_POLL

def __init__(self):
Expand Down
16 changes: 10 additions & 6 deletions custom_components/mail_and_packages/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

DOMAIN = "mail_and_packages"
DOMAIN_DATA = f"{DOMAIN}_data"
VERSION = "0.3.22"
VERSION = "0.3.23"
ISSUE_URL = "http://github.com/moralmunky/Home-Assistant-Mail-And-Packages"
PLATFORM = "sensor"
PLATFORMS = ["binary_sensor", "camera", "sensor"]
Expand Down Expand Up @@ -62,11 +62,11 @@
DEFAULT_FOLDER = '"INBOX"'
DEFAULT_PATH = "custom_components/mail_and_packages/images/"
DEFAULT_IMAGE_SECURITY = True
DEFAULT_IMAP_TIMEOUT = 30
DEFAULT_IMAP_TIMEOUT = 60
DEFAULT_GIF_DURATION = 5
DEFAULT_SCAN_INTERVAL = 5
DEFAULT_SCAN_INTERVAL = 30
DEFAULT_GIF_FILE_NAME = "mail_today.gif"
DEFAULT_AMAZON_FWDS = "(none)"
DEFAULT_AMAZON_FWDS = []
DEFAULT_ALLOW_EXTERNAL = False
DEFAULT_CUSTOM_IMG = False
DEFAULT_CUSTOM_IMG_FILE = "custom_components/mail_and_packages/images/mail_none.gif"
Expand Down Expand Up @@ -110,9 +110,13 @@
)
AMAZON_HUB = "amazon_hub"
AMAZON_HUB_CODE = "amazon_hub_code"
AMAZON_HUB_EMAIL = ["[email protected]", "[email protected]"]
AMAZON_HUB_EMAIL = [
"[email protected]",
"[email protected]",
"[email protected]",
]
AMAZON_HUB_SUBJECT = "ready for pickup from Amazon Hub Locker"
AMAZON_HUB_SUBJECT_SEARCH = "(You have a package to pick up)(.*)(\\d{6})"
AMAZON_HUB_SUBJECT_SEARCH = "(a package to pick up)(.*)(\\d{6})"
AMAZON_HUB_BODY = "(Your pickup code is <b>)(\\d{6})"
AMAZON_TIME_PATTERN = [
"will arrive:",
Expand Down
3 changes: 2 additions & 1 deletion custom_components/mail_and_packages/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import aiohttp
import dateparser
import homeassistant.helpers.config_validation as cv
from bs4 import BeautifulSoup
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
Expand Down Expand Up @@ -332,7 +333,7 @@ def fetch(
img_out_path = f"{hass.config.path()}/{config.get(CONF_PATH)}"
gif_duration = config.get(CONF_DURATION)
generate_mp4 = config.get(CONF_GENERATE_MP4)
amazon_fwds = config.get(CONF_AMAZON_FWDS)
amazon_fwds = cv.ensure_list_csv(config.get(CONF_AMAZON_FWDS))
image_name = data[ATTR_IMAGE_NAME]
amazon_image_name = data[ATTR_AMAZON_IMAGE]
amazon_days = config.get(CONF_AMAZON_DAYS)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/mail_and_packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"Pillow>=9.0",
"dateparser"
],
"version": "0.3.22"
"version": "0.3.23"
}
4 changes: 2 additions & 2 deletions custom_components/mail_and_packages/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"allow_external": "Create image for notification apps",
"custom_img": "Use custom 'no image' image?"
},
"description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma.",
"description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.",
"title": "Mail and Packages (Step 2 of 2)"
},
"options_3": {
Expand Down Expand Up @@ -86,7 +86,7 @@
"allow_external": "Create image for notification apps",
"custom_img": "Use custom 'no image' image?"
},
"description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma.",
"description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.",
"title": "Mail and Packages (Step 2 of 2)"
},
"options_3": {
Expand Down
4 changes: 2 additions & 2 deletions custom_components/mail_and_packages/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"amazon_days": "Days back to check for Amazon emails",
"custom_img": "Use custom 'no image' image?"
},
"description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.",
"description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.",
"title": "Mail and Packages (Step 2 of 2)"
},
"options_3": {
Expand Down Expand Up @@ -87,7 +87,7 @@
"amazon_days": "Days back to check for Amazon emails",
"custom_img": "Use custom 'no image' image?"
},
"description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.",
"description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.",
"title": "Mail and Packages (Step 2 of 2)"
},
"options_3": {
Expand Down
2 changes: 1 addition & 1 deletion extras/appdaemon/apps/apps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Set Smallgroup Boolean On:
module: entity_timer
class: Timer
constrain_days: wed
time_on: "13:13:00"
time_on: "08:00:00"
entities: input_boolean.is_smallgroup

Set Smallgroup Boolean Off:
Expand Down
2 changes: 1 addition & 1 deletion www/community/lovelace-card-mod/card-mod.js

Large diffs are not rendered by default.

Binary file modified www/community/lovelace-card-mod/card-mod.js.gz
Binary file not shown.

0 comments on commit b9fef96

Please sign in to comment.