Skip to content

prusalink: expose printer location as suggested_area#170099

Merged
joostlek merged 1 commit into
home-assistant:devfrom
heikkih:fix/prusalink-location-as-suggested-area
May 8, 2026
Merged

prusalink: expose printer location as suggested_area#170099
joostlek merged 1 commit into
home-assistant:devfrom
heikkih:fix/prusalink-location-as-suggested-area

Conversation

@heikkih
Copy link
Copy Markdown
Contributor

@heikkih heikkih commented May 8, 2026

Proposed change

Per @joostlek's review feedback on #169312: the printer's location field from /api/v1/info is a physical placement hint (e.g. "Workshop", "Garage"), which maps semantically to HA's suggested_area on DeviceInfo rather than to a sensor entity.

  • Drop the location sensor entity (and its strings.json / icons.json entries)
  • Set suggested_area=info_data.get("location") on DeviceInfo in PrusaLinkEntity, so the printer's configured location is used as a hint when the device is registered

Why this is safe

  • Existing setups are unaffected. suggested_area only influences a device's area at registration time; once the device exists, HA does not re-assign the area based on this value. Users who already configured an area for their printer keep that assignment.
  • New users get a sensible default. The location string is proposed as an area on registration; HA matches an existing area by name or creates a new one.
  • Breaking impact of the sensor removal is small. The sensor was added in prusalink: add X/Y axis, location, and min extrusion temp sensors #169312 (just merged), was default-disabled, and few users will have enabled it.

Note for reviewers about suggested_area and the upcoming deprecation

DeviceEntry.suggested_area (reading from the registry) is being deprecated and will be removed in HA Core 2026.9. However, the blog post explicitly notes: "Setting suggested_area in DeviceInfo, and passing suggested_area to DeviceRegistry.async_get_or_create is still supported and influences the area of created devices, although that may change in the future." This PR uses the supported writing path; if HA introduces a different mechanism later, we'll adapt.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (non-breaking change which fixes an issue)
  • Code quality improvements to existing code or addition of tests

Checklist

  • The code change is tested and works locally
  • Local tests pass (31 passed)
  • mypy passes
  • There is no commented out code in this PR

Per @joostlek's review feedback on home-assistant#169312: the printer's `location`
field from /api/v1/info is a physical placement hint (e.g.
"Workshop", "Garage"), which maps semantically to HA's `suggested_area`
on `DeviceInfo` rather than to a sensor entity.

- Drop the `location` sensor entity (and its strings/icons entries)
- Set `suggested_area=info_data.get("location")` on `DeviceInfo` in
  the base entity, so the printer's configured location is used as a
  hint when the device is registered.

Existing setups are unaffected because `suggested_area` only
influences a device's area on registration; once the device exists,
HA does not re-assign the area. New users get the location string
proposed as an area on registration (HA matches an existing area or
creates one). The dropped sensor was just merged in home-assistant#169312, was
default-disabled, and few users will have enabled it.

Note for posterity: `DeviceEntry.suggested_area` is being deprecated
in HA 2026.9 (https://developers.home-assistant.io/blog/2025/08/01/suggested-area-removed-from-deviceentry/),
but setting `suggested_area` via `DeviceInfo` is still supported and
still influences device area on registration. Only reading it back
from `DeviceEntry` is being removed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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 updates the PrusaLink integration to treat the printer’s /api/v1/info location field as a physical placement hint by exposing it via DeviceInfo.suggested_area instead of as a sensor entity.

Changes:

  • Remove the location sensor entity (including its translation and icon entries).
  • Set suggested_area=info_data.get("location") in PrusaLinkEntity.device_info so new devices are placed into the corresponding area at registration time.
  • Update tests to stop asserting on the removed sensor and to validate area assignment behavior.

Reviewed changes

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

Show a summary per file
File Description
homeassistant/components/prusalink/entity.py Adds suggested_area derived from the printer info location field to device registration.
homeassistant/components/prusalink/sensor.py Removes the info.location sensor definition.
homeassistant/components/prusalink/strings.json Removes the location sensor translation key.
homeassistant/components/prusalink/icons.json Removes the location sensor icon entry.
tests/components/prusalink/test_sensor.py Updates sensor tests to drop coverage for the removed location sensor.
tests/components/prusalink/test_init.py Extends device info test to assert the device is assigned to the “Workshop” area via suggested_area.

@joostlek joostlek merged commit 191143d into home-assistant:dev May 8, 2026
36 of 37 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 9, 2026
@heikkih heikkih deleted the fix/prusalink-location-as-suggested-area branch May 13, 2026 10:26
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.

3 participants