diff --git a/custom_components/mail_and_packages/__init__.py b/custom_components/mail_and_packages/__init__.py index 00bbd727..36fb5e20 100644 --- a/custom_components/mail_and_packages/__init__.py +++ b/custom_components/mail_and_packages/__init__.py @@ -19,6 +19,7 @@ CONF_IMAP_TIMEOUT, CONF_PATH, CONF_SCAN_INTERVAL, + CONF_STORAGE, CONF_VERIFY_SSL, CONFIG_VER, COORDINATOR, @@ -162,6 +163,11 @@ async def async_migrate_entry(hass, config_entry): if CONF_AMAZON_DOMAIN not in updated_config: updated_config[CONF_AMAZON_DOMAIN] = "amazon.com" + if version < 10: + # Add default for image storage config + if CONF_STORAGE not in updated_config: + updated_config[CONF_STORAGE] = "custom_components/mail_and_packages/images/" + if CONF_PATH not in updated_config: updated_config[CONF_PATH] = "custom_components/mail_and_packages/images/" diff --git a/custom_components/mail_and_packages/const.py b/custom_components/mail_and_packages/const.py index 459aa113..d970464e 100644 --- a/custom_components/mail_and_packages/const.py +++ b/custom_components/mail_and_packages/const.py @@ -22,7 +22,7 @@ OVERLAY = ["overlay.png", "vignette.png", "white.png"] SERVICE_UPDATE_FILE_PATH = "update_file_path" CAMERA = "cameras" -CONFIG_VER = 9 +CONFIG_VER = 10 # Attributes ATTR_AMAZON_IMAGE = "amazon_image" diff --git a/tests/conftest.py b/tests/conftest.py index 3fcefbcf..4ffdc98a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -111,7 +111,7 @@ async def integration_fixture_4(hass, caplog): await hass.async_block_till_done() assert "Migrating from version 3" in caplog.text - assert "Migration complete to version 9" in caplog.text + assert "Migration complete to version 10" in caplog.text assert CONF_AMAZON_DOMAIN in entry.data diff --git a/tests/const.py b/tests/const.py index ace20f47..ec95079f 100644 --- a/tests/const.py +++ b/tests/const.py @@ -249,6 +249,7 @@ "zpackages_transit", ], "scan_interval": 20, + "storage": "custom_components/mail_and_packages/images/", "username": "user@fake.email", "verify_ssl": False, } @@ -922,5 +923,4 @@ "scan_interval": 20, "username": "user@fake.email", "verify_ssl": False, - "storage": "custom_components/mail_and_packages/images/", } diff --git a/tests/test_binary_sensor.py b/tests/test_binary_sensor.py index 70064bee..dc1578c3 100644 --- a/tests/test_binary_sensor.py +++ b/tests/test_binary_sensor.py @@ -64,6 +64,7 @@ async def test_binary_sensor_mail_delivered( domain=DOMAIN, title="imap.test.email", data=FAKE_CONFIG_DATA_USPS_DELIVERED, + version=9, ) entry.add_to_hass(hass)