Skip to content

Deprecate min_max and migrate to group sensor#167718

Draft
gjohansson-ST wants to merge 33 commits into
devfrom
gj-20260408-02
Draft

Deprecate min_max and migrate to group sensor#167718
gjohansson-ST wants to merge 33 commits into
devfrom
gj-20260408-02

Conversation

@gjohansson-ST
Copy link
Copy Markdown
Member

@gjohansson-ST gjohansson-ST commented Apr 8, 2026

Breaking change

Proposed change

Deprecate the min_max integration

  • YAML config is raised as repair showing a copy/paste replacement (yaml config continues to work, user needs to actively replace it in config.yaml)
  • Config entry is raised as a repair, the user needs to fix the issue to migrate to group sensor
  • It's not possible to create new min/max sensors
  • It's possible to reconfigure the min/max sensors options

Needs: #171773

Config entry repair:
Untitled

YAML config repair:
Untitled 2

Start new min/max helper:
Untitled 3

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the [development checklist][dev-checklist]
  • I have followed the [perfect PR recommendations][perfect-pr]
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

  • Documentation added/updated for [www.home-assistant.io][docs-repository]

If the code communicates with devices, web services, or third-party tools:

  • The [manifest file][manifest-docs] has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

  • I have reviewed two other [open pull requests][prs] in this repository.

Copilot AI review requested due to automatic review settings April 8, 2026 20:24
@home-assistant home-assistant Bot added cla-signed deprecation Indicates a breaking change to happen in the future integration: min_max Top 100 Integration is ranked within the top 100 by usage Top 200 Integration is ranked within the top 200 by usage by-code-owner Quality Scale: internal labels Apr 8, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to deprecate the min_max integration by warning on YAML usage via Repairs and migrating existing config entries to the group sensor helper instead.

Changes:

  • Adds a Repairs issue for YAML-configured min_max sensors with a suggested converted group sensor YAML snippet.
  • Updates the min_max config flow to immediately abort and direct users to use group instead.
  • Introduces a config entry migration path intended to move min_max entries to group sensor entries.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
homeassistant/components/min_max/yaml.yaml Adds an example YAML conversion snippet (appears to be a temporary/scratch file).
homeassistant/components/min_max/strings.json Adds abort reason text and a Repairs issue translation for YAML deprecation messaging.
homeassistant/components/min_max/sensor.py Creates a Repairs issue for YAML configs and attempts to generate a replacement group sensor YAML snippet.
homeassistant/components/min_max/config_flow.py Replaces the previous config flow/options flow with an abort-only flow directing users to group.
homeassistant/components/min_max/init.py Adds async_migrate_entry intended to migrate config entries.
Comments suppressed due to low confidence (1)

homeassistant/components/min_max/sensor.py:125

  • Restore config-entry support (or ensure entries are migrated/removed before setup) because the sensor platform no longer defines async_setup_entry, but min_max still forwards config entries to the sensor platform in async_setup_entry.
async def async_setup_platform(
    hass: HomeAssistant,
    config: ConfigType,
    async_add_entities: AddEntitiesCallback,
    discovery_info: DiscoveryInfoType | None = None,
) -> None:
    """Set up the min/max/mean sensor."""
    entity_ids: list[str] = config[CONF_ENTITY_IDS]
    name: str | None = config.get(CONF_NAME)
    sensor_type: str = config[CONF_TYPE]
    round_digits: int = config[CONF_ROUND_DIGITS]
    unique_id = config.get(CONF_UNIQUE_ID)

    await async_setup_reload_service(hass, DOMAIN, PLATFORMS)
    await yaml_deprecation_notice(hass, config)

    async_add_entities(
        [MinMaxSensor(entity_ids, name, sensor_type, round_digits, unique_id)]
    )

Comment thread homeassistant/components/min_max/__init__.py Outdated
Comment thread homeassistant/components/min_max/config_flow.py Outdated
Comment thread homeassistant/components/min_max/sensor.py Outdated
Comment thread homeassistant/components/min_max/yaml.yaml Outdated
Comment thread homeassistant/components/min_max/sensor.py
Comment thread homeassistant/components/min_max/sensor.py Outdated
Comment thread homeassistant/components/min_max/__init__.py Outdated
Comment thread homeassistant/components/min_max/strings.json Outdated
Copilot AI review requested due to automatic review settings April 14, 2026 16:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

homeassistant/components/group/init.py:56

  • Drop the unused CONF_IGNORE_NON_NUMERIC import to avoid failing linting for an unused symbol.
    ATTR_ORDER,
    ATTR_REMOVE_ENTITIES,
    CONF_HIDE_MEMBERS,
    CONF_IGNORE_NON_NUMERIC,
    DATA_COMPONENT,
    DOMAIN,
    GROUP_ORDER,
    REG_KEY,
)

Comment thread homeassistant/components/min_max/__init__.py Outdated
Comment thread homeassistant/components/min_max/__init__.py Outdated
Comment thread homeassistant/components/min_max/__init__.py Outdated
Comment thread homeassistant/components/min_max/config.json Outdated
Copilot AI review requested due to automatic review settings April 14, 2026 19:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.

Comment thread homeassistant/components/min_max/__init__.py Outdated
Comment thread homeassistant/components/min_max/sensor.py
Comment thread homeassistant/components/group/config_flow.py Outdated
Comment thread homeassistant/components/min_max/yaml.yaml Outdated
Comment thread homeassistant/components/min_max/config.json Outdated
Comment thread homeassistant/components/min_max/sensor.py
Comment thread homeassistant/components/min_max/__init__.py Outdated
Copilot AI review requested due to automatic review settings April 14, 2026 20:03
@gjohansson-ST gjohansson-ST marked this pull request as ready for review May 13, 2026 21:20
@gjohansson-ST gjohansson-ST requested a review from a team as a code owner May 13, 2026 21:20
Copilot AI review requested due to automatic review settings May 13, 2026 21:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Comment thread homeassistant/components/min_max/sensor.py Outdated
Comment on lines 1933 to 1936
if (
state := self.hass.states.get(entity_id)
) is not None and state.state != STATE_UNKNOWN:
) is not None and state.state not in (STATE_UNKNOWN, STATE_UNAVAILABLE):
raise ValueError("Only entities that haven't been loaded can be migrated")
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should fix this in that case in a separate PR since unknown also does not mean it's not loaded.

Comment thread tests/components/min_max/test_config_flow.py
config[CONF_IGNORE_NON_NUMERIC] = False
config[CONF_GROUP_TYPE] = SENSOR_DOMAIN

new_config_entry = ConfigEntry(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we use a normal config flow on the group domain to create the new entry, instead of adding it directly?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be a bit difficult as we need to unload min_max and change the entity before it starts to ensure we keep history etc.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sort of thing would normally be in the group integration's config flow with a custom initial step for the min_max adoption, but considering we'll be removing the code after 6 months, this is maybe OK.

Comment thread homeassistant/components/min_max/repairs.py Outdated
Comment thread homeassistant/components/min_max/repairs.py Outdated
Comment thread homeassistant/components/min_max/repairs.py Outdated
Comment thread homeassistant/components/min_max/repairs.py Outdated
Comment thread homeassistant/components/min_max/sensor.py Outdated
Comment thread homeassistant/components/min_max/strings.json Outdated
@home-assistant
Copy link
Copy Markdown
Contributor

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant Bot marked this pull request as draft May 13, 2026 21:53
Copilot AI review requested due to automatic review settings May 14, 2026 13:58
@gjohansson-ST gjohansson-ST marked this pull request as ready for review May 14, 2026 13:59
@home-assistant home-assistant Bot requested a review from abmantis May 14, 2026 13:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Comment on lines 1933 to 1936
if (
state := self.hass.states.get(entity_id)
) is not None and state.state != STATE_UNKNOWN:
) is not None and state.state not in (STATE_UNKNOWN, STATE_UNAVAILABLE):
raise ValueError("Only entities that haven't been loaded can be migrated")
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already commented on this above, but I think another PR needs to fix that and look on the integration rather than an entity state (as unknown isn't always meaning an integration isn't loaded)

config.pop(CONF_ROUND_DIGITS)
# Set group sensor defaults
config[CONF_HIDE_MEMBERS] = False
config[CONF_IGNORE_NON_NUMERIC] = False
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd think we should migrate to group default (False), the user can always change that if they want.

Comment on lines +117 to +125
platform_config = config.copy()
platform_config[CONF_ENTITIES] = platform_config.pop(CONF_ENTITY_IDS)
platform_config.pop(CONF_ROUND_DIGITS)
platform_config.pop(CONF_PLATFORM)
if CONF_NAME not in platform_config:
platform_config[CONF_NAME] = f"{platform_config[CONF_TYPE]} sensor".capitalize()
yaml_config = yaml_util.dump(platform_config)
yaml_config = yaml_config.replace("\n", "\n ")
yaml_config = "```yaml\nsensor:\n - platform: group\n " + yaml_config + "\n```"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above

Comment thread tests/components/min_max/test_sensor.py Outdated
async def test_deprecation_warning(
hass: HomeAssistant, issue_registry: ir.IssueRegistry
) -> None:
"""Test the min sensor with a default name."""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should address this

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I'll leave that for now until we have a second opinion as there could potentially come up more things.

Copy link
Copy Markdown
Member

@abmantis abmantis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is ok, but would like another pair of eyes since I am not familiar with the migration as done here.

Comment thread tests/components/min_max/test_sensor.py Outdated
async def test_deprecation_warning(
hass: HomeAssistant, issue_registry: ir.IssueRegistry
) -> None:
"""Test the min sensor with a default name."""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should address this

@abmantis abmantis added the second-opinion-wanted Add this label when a reviewer needs a second opinion from another member. label May 14, 2026
Copy link
Copy Markdown
Contributor

@emontnemery emontnemery May 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the entity registry changes to a separate PR with a clear motivation for the change as well as updated tests.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #171773

@home-assistant home-assistant Bot marked this pull request as draft May 19, 2026 12:13
"round_digits": "Controls the number of decimal digits in the output when the statistics characteristic is mean, median or sum."
},
"description": "Create a sensor that calculates a min, max, mean, median or sum from a list of input sensors.",
"description": "Min/Max helper has been deprecated, please use the Group helper instead.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this visible considering we immediately abort the flow?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I will remove it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have to keep it as the translation script requires it. It will anyhow be removed in 6 months

Comment thread homeassistant/components/min_max/sensor.py
Comment thread homeassistant/components/min_max/repairs.py Outdated
Comment thread homeassistant/components/min_max/strings.json Outdated
Comment thread homeassistant/components/min_max/__init__.py
Copilot AI review requested due to automatic review settings May 21, 2026 20:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Comment on lines 1933 to 1936
if (
state := self.hass.states.get(entity_id)
) is not None and state.state != STATE_UNKNOWN:
) is not None and state.state not in (STATE_UNKNOWN, STATE_UNAVAILABLE):
raise ValueError("Only entities that haven't been loaded can be migrated")
Comment on lines +108 to +117
) -> RepairsFlow:
"""Create flow."""
if data and (entry_id := data.get("entry_id")):
entry_id = cast(str, entry_id)
entry = hass.config_entries.async_get_entry(entry_id)
if TYPE_CHECKING:
assert entry
return MigrateToGroupSensorFlow(entry)

return ConfirmRepairFlow()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

by-code-owner cla-signed deprecation Indicates a breaking change to happen in the future integration: min_max Quality Scale: internal second-opinion-wanted Add this label when a reviewer needs a second opinion from another member. Top 100 Integration is ranked within the top 100 by usage Top 200 Integration is ranked within the top 200 by usage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants