Skip to content

Conversation

emontnemery
Copy link
Contributor

@emontnemery emontnemery commented Jul 31, 2025

Proposed change

Deprecate DeviceEntry.suggested_area.

Note:
Setting suggested_area in DeviceInfo, and passing suggested_area to DeviceRegistry.async_get_or_create is still supported and influences the area of craeted devices, although that may change in the future.

Rationale:
DeviceEntry.suggested_area was not stored, meaning its behavior was unpredictable. Moreover, was used almost only in tests, the one exception being device analytics dump.

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

  • 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
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

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

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

  • The manifest file 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 link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@home-assistant home-assistant bot added cla-signed core new-feature small-pr PRs with less than 30 lines. labels Jul 31, 2025
@emontnemery
Copy link
Contributor Author

emontnemery commented Jul 31, 2025

A github code search for /(?-i)\.suggested_area/ path:custom_components suggests DeviceEntry.suggested_area is not widely used by custom integrations.

The search query above, filtered for false positives, suggests it's used by:

@emontnemery emontnemery changed the title Remove DeviceEntry.suggested_area Deprecate DeviceEntry.suggested_area Aug 1, 2025
@emontnemery emontnemery marked this pull request as ready for review August 1, 2025 07:53
@Copilot Copilot AI review requested due to automatic review settings August 1, 2025 07:53
Copy link
Contributor

@Copilot 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 deprecates the DeviceEntry.suggested_area property in Home Assistant. The property was not stored persistently, making its behavior unpredictable and unreliable. It was primarily used in tests with only one exception being device analytics dump functionality.

Key changes:

  • Deprecates the suggested_area property with a deprecation warning
  • Updates all tests to use area_id instead of suggested_area
  • Removes suggested_area from snapshot test outputs

Reviewed Changes

Copilot reviewed 128 out of 128 changed files in this pull request and generated no comments.

File Description
tests/syrupy.py Adds removal of _suggested_area from serialization for snapshots
tests/helpers/test_device_registry.py Adds deprecation test and updates existing tests to use area_id
Multiple test snapshot files Removes suggested_area from expected device output
Various integration test files Updates tests to use area_id and area registry instead of suggested_area
Comments suppressed due to low confidence (1)

tests/helpers/test_device_registry.py:2512

  • There is a typo in the variable name: 'witout' should be 'without'.
    orig_kitchen_light_without_suggested_area = device_registry.async_update_device(

@jbouwh
Copy link
Contributor

jbouwh commented Aug 1, 2025

I think we should have a breaking change for MQTT in advance of this one. Marking the YAML options as deprecated, and explaining this no longer works. This will prevent unexpected results. I think the deprecation deadline is okay BTW.

@bdraco
Copy link
Member

bdraco commented Aug 1, 2025

It should probably be more clear that this is only deprecating reading the property not actually suggesting an area

@emontnemery
Copy link
Contributor Author

I think we should have a breaking change for MQTT in advance of this one. Marking the YAML options as deprecated, and explaining this no longer works. This will prevent unexpected results. I think the deprecation deadline is okay BTW.

This PR does not deprecate the suggested_area functionality, it just removed the suggested_area attribute from the DeviceEntry object.

@jbouwh
Copy link
Contributor

jbouwh commented Aug 1, 2025

It should probably be more clear that this is only deprecating reading the property not actually suggesting an area

Ah, I misunderstood. I'll discuss with @emontnemery about the MQTT feature in this.

@emontnemery emontnemery merged commit 0d7608f into dev Aug 1, 2025
48 checks passed
@emontnemery emontnemery deleted the remove_device_entry_suggested_area branch August 1, 2025 08:34
@emontnemery emontnemery added this to the 2025.8.0 milestone Aug 1, 2025
@emontnemery
Copy link
Contributor Author

Tagged for 2025.8.0 to prevent merge conflicts with #149758

@github-actions github-actions bot locked and limited conversation to collaborators Aug 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants