Use a major version bump for the History Stats "additional_settings" rename (#175137)

This commit is contained in:
Ariel Ebersberger
2026-07-02 19:30:52 +02:00
committed by GitHub
parent 63de17fd45
commit a6620bbcee
4 changed files with 11 additions and 12 deletions
@@ -121,12 +121,11 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
hass.config_entries.async_update_entry(
config_entry, options=options, minor_version=3
)
if config_entry.minor_version < 4:
# The "advanced_settings" section was renamed to "additional_settings"
if (additional := options.pop("advanced_settings", None)) is not None:
options[SECTION_ADDITIONAL_SETTINGS] = additional
# The "advanced_settings" section was renamed to "additional_settings"
if (additional := options.pop("advanced_settings", None)) is not None:
options[SECTION_ADDITIONAL_SETTINGS] = additional
hass.config_entries.async_update_entry(
config_entry, options=options, minor_version=4
config_entry, options=options, version=2, minor_version=1
)
_LOGGER.debug(
@@ -189,7 +189,7 @@ OPTIONS_FLOW = {
class HistoryStatsConfigFlowHandler(SchemaConfigFlowHandler, domain=DOMAIN):
"""Handle a config flow for History stats."""
MINOR_VERSION = 4
VERSION = 2
config_flow = CONFIG_FLOW
options_flow = OPTIONS_FLOW
@@ -62,7 +62,7 @@ async def test_form(
await hass.async_block_till_done()
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["version"] == 1
assert result["version"] == 2
assert result["options"] == {
CONF_NAME: DEFAULT_NAME,
CONF_ENTITY_ID: "binary_sensor.test_monitored",
@@ -174,7 +174,7 @@ async def test_validation_options(
await hass.async_block_till_done()
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["version"] == 1
assert result["version"] == 2
assert result["options"] == {
CONF_NAME: DEFAULT_NAME,
CONF_ENTITY_ID: "binary_sensor.test_monitored",
+4 -4
View File
@@ -423,7 +423,7 @@ async def test_migration_1_1(
history_stats_entity_entry = entity_registry.async_get("sensor.my_history_stats")
assert history_stats_entity_entry.device_id == sensor_entity_entry.device_id
assert history_stats_config_entry.version == 1
assert history_stats_config_entry.version == 2
assert (
history_stats_config_entry.minor_version
== HistoryStatsConfigFlowHandler.MINOR_VERSION
@@ -465,7 +465,7 @@ async def test_migration_1_2(
history_stats_config_entry.options.get(CONF_STATE_CLASS)
== SensorStateClass.MEASUREMENT
)
assert history_stats_config_entry.version == 1
assert history_stats_config_entry.version == 2
assert (
history_stats_config_entry.minor_version
== HistoryStatsConfigFlowHandler.MINOR_VERSION
@@ -511,7 +511,7 @@ async def test_migration_1_3(
assert history_stats_config_entry.options[SECTION_ADDITIONAL_SETTINGS] == {
CONF_MIN_STATE_DURATION: {"seconds": 30}
}
assert history_stats_config_entry.version == 1
assert history_stats_config_entry.version == 2
assert (
history_stats_config_entry.minor_version
== HistoryStatsConfigFlowHandler.MINOR_VERSION
@@ -535,7 +535,7 @@ async def test_migration_from_future_version(
CONF_END: "{{ utcnow() }}",
},
title="My history stats",
version=2,
version=3,
minor_version=1,
)
config_entry.add_to_hass(hass)