Skip to content

Name a blueprint update after the blueprint - #1561

Merged
frenck merged 2 commits into
mainfrom
frenck/blueprint-update-names
Aug 31, 2026
Merged

frenck merged 2 commits into
mainfrom
frenck/blueprint-update-names

Conversation

@frenck

@frenck frenck commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Description

The blueprint update entities hung off a single device called "Blueprints", and the updates page reads a row by the device it belongs to. So somebody with twenty blueprints saw twenty rows saying "Blueprints", with nothing to say which one each row was about.

Measured before and after, on the same blueprint:

with a device    : friendly_name='Blueprints Sensor Light'
without a device : friendly_name='Sensor Light'

The device is gone rather than split up. One device per blueprint would have read correctly and filled the device list with twenty entries that are not devices: a blueprint is a file, with no firmware and nothing to connect to. Without a device the entity's own name stands on its own, and that name is the blueprint's.

Motivation and Context

Spotted on a screenshot in #1548, where the rows were indistinguishable.

Two consequences worth stating plainly, because neither is free.

The entity ID loses its prefix on a fresh install. update.<name> where it used to be update.blueprints_<name>. Anybody who already has these keeps the old ID, because the entity is taken off the device before the device is removed, so the registration is never dropped. Two installations therefore differ depending on when they first ran this, which is not tidy. Bringing them into line is a decision of its own and not this PR: it would rename an entity somebody may reference.

The old device is now empty, so it is removed at setup. A device that is not a device and holds nothing is only something to wonder about later.

Removing a device is not free, which review was right to raise. Home Assistant deletes the registration of every entity on a device when the device goes, and both belong to Spook here, so it reached for exactly that. It also hands the whole registration back the moment the same unique ID turns up again, which is later in the same setup, with the entity ID, name, icon, area, aliases, labels and hidden state all still on it. So nothing was being lost, but a dozen repairs re-inspect on any entity registry change and an entity that goes and comes back gives every one of them nothing to find. Taking the entity off the device first avoids the round trip entirely.

One deprecation went with it. Looking a device up by its identifiers alone is deprecated, since identifiers are no longer unique across config entries, and it warns with a request to open a bug report against Spook. The replacement wants to know whose device it is, so the cleanup now runs from async_start, where the config entry already was, once at setup rather than on every round.

How has this been tested?

Three new tests: the name and title are the blueprint's, no device is created at all, and a device left over from an earlier version gets cleared away without taking anything with it.

That last one seeds the registration the way v5.3.0 left it, renamed and with an icon set by hand, and asserts that no entity is dropped at all. It hands its own config entry to the setup rather than making up a second one: under two entries Home Assistant never compares the two as equal, never reaches the removal, and the test would pass while proving nothing. It did exactly that on the first attempt.

Five entity IDs in the existing tests moved with the change, which is the same rename users will see on a fresh install.

Every part is mutation tested:

Mutation Result
Put the device back 40 failed
Skip the cleanup of the old device 1 failed
Leave the entity on the device 1 failed
Look the device up under the wrong config entry 1 failed

The forty is the existing suite noticing the entity IDs shift back, which is a fair way to find out the device is what drives them.

Full suite is 1537 passing. Ruff, pylint and prettier clean.

One documentation line was quietly broken before this and is fixed here: the default entity ID line read \_Default ... rather than italics, because the old ID contained an underscore that prettier had to escape. With the prefix gone the escape goes too.

Screenshots (if appropriate):

None from me. The change shows up on Settings > Updates, where each row now names its blueprint.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

These hung off a single device called "Blueprints", and the updates page reads
a row by the device it belongs to. So somebody with twenty blueprints saw
twenty rows saying "Blueprints", with nothing to say which was which. Frenck
spotted it on a screenshot in #1548.

The device is gone rather than split. One device per blueprint would have read
correctly and filled the device list with twenty entries that are not devices;
a blueprint is a file, with no firmware and nothing to connect to. Without a
device the entity's own name stands on its own, which is the blueprint's name.

Two things follow from it.

The entity ID loses its prefix: `update.<name>` where it used to be
`update.blueprints_<name>`. Anybody who already has these keeps the old ID,
because the registry pins that to the unique ID and the unique ID has not
moved. So installations differ depending on when they started, which is not
tidy, and renaming them for everybody would break automations that reference
one.

And the old device is now empty, so it gets removed on the first round. A
device that is not a device and holds nothing is only something to wonder
about later.

Five entity IDs in the tests moved with it. Both changes are mutation tested:
putting the device back fails forty tests, skipping the cleanup fails one.
Copilot AI balanced review requested due to automatic review settings August 31, 2026 16:03
@frenck frenck added documentation Solely about the documentation of the project. bugfix Inconsistencies or issues which will cause a problem for users or implementors. labels Aug 31, 2026
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 94284bee-c6ce-415d-b37d-4f3188aef45b

📥 Commits

Reviewing files that changed from the base of the PR and between 65716a0 and 05857d1.

📒 Files selected for processing (3)
  • custom_components/spook/ectoplasms/blueprint/update.py
  • tests/ectoplasms/blueprint/conftest.py
  • tests/ectoplasms/blueprint/test_update.py

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

Blueprint update entities no longer attach to a shared device. Startup removes the legacy “Blueprints” device. Entity IDs, names, documentation, and tests now reflect the standalone entity model.

Changes

Blueprint update entities

Layer / File(s) Summary
Standalone entity lifecycle
custom_components/spook/ectoplasms/blueprint/update.py, tests/ectoplasms/blueprint/conftest.py
Update entities no longer assign DeviceInfo. Startup detaches entities and removes the legacy device identified by (DOMAIN, blueprint.DOMAIN) and the config entry ID.
Entity contract and validation
documentation/integrations/blueprint.md, tests/ectoplasms/blueprint/test_update.py
Documentation and tests use the new entity IDs. Tests verify blueprint names, the absence of devices, and removal of the legacy device without entity removal events.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 05857

This change removes the misleading shared device and gives blueprint update entities names that identify their blueprint while preserving existing registrations during migration. No actionable merge-blocking risk remains after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant BlueprintUpdate
  participant EntityRegistry
  participant DeviceRegistry
  BlueprintUpdate->>DeviceRegistry: Find legacy device
  BlueprintUpdate->>EntityRegistry: Detach registered entities
  BlueprintUpdate->>DeviceRegistry: Remove legacy device
Loading

Poem

A rabbit sees updates roam free,
No shared device beneath the tree.
Old “Blueprints” leaves the view,
Names and IDs are fresh and new,
Tests confirm the cleanup too.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: blueprint update entities are named after their blueprints. It is concise and directly related to the pull request.
Description check ✅ Passed The description directly explains the removal of the shared device, blueprint-based entity naming, legacy-device cleanup, compatibility behavior, tests, and documentation updates.
Docstring Coverage ✅ Passed Docstring coverage is 93.75% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 3 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch frenck/blueprint-update-names

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

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.

🟡 Changes recommended

Legacy device removal currently deletes existing entity-registry entries, breaking preserved IDs and customizations.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Names blueprint update entities after their blueprints by removing the shared device association.

Changes:

  • Removes the shared “Blueprints” device.
  • Adds legacy-device cleanup and migration tests.
  • Updates entity IDs and documentation.
File summaries
File Description
custom_components/spook/ectoplasms/blueprint/update.py Removes device association and cleans up the legacy device.
tests/ectoplasms/blueprint/test_update.py Updates IDs and adds naming/device tests.
documentation/integrations/blueprint.md Documents device-less entities and new default IDs.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/ectoplasms/blueprint/test_update.py Outdated
Comment thread custom_components/spook/ectoplasms/blueprint/update.py Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 31, 2026
Review pointed out that removing a device takes the entity registrations on it
with it, which is true: Home Assistant deletes every entity entry that belongs
to the same config entry as the device. Both are ours here, so it reached for
that.

What it does not do is cost anything. The registration goes into the registry's
deleted list and comes straight back out when the same unique ID turns up
again, which is later in the same setup, with the entity ID, the name, the icon,
the area, the aliases, the labels and whether it was hidden all still on it.
Verified rather than assumed, because the claim was that a user's own naming
would be lost.

The churn is the reason to avoid it anyway. A dozen repairs re-inspect on any
entity registry change, and an entity going and coming back for no reason gives
all of them nothing to find. So the entity is taken off the device first, and
the device is then removed holding nothing.

The lookup moved with it. Finding a device by its identifiers alone is
deprecated, because identifiers are no longer unique across config entries, and
it warns with a request to open a bug report. The replacement wants to know
whose device it is, so the whole thing now runs from where the config entry
already was: once, at setup, rather than on every round.

Three mutations, each one failing the test on its own: keeping the entity on the
device, leaving the device behind, and looking it up under the wrong entry. The
test seeds a registration the way the released version left it, and asserts
nothing is dropped at all. It also hands its config entry to the setup instead
of making up a second one, without which Home Assistant never compares the two
as equal, never reaches the removal, and the test passes while proving nothing.
Copilot AI review requested due to automatic review settings August 31, 2026 17:36
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

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.

🟡 Changes recommended

Legacy registrations for blueprints removed while offline can remain orphaned after migration.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread custom_components/spook/ectoplasms/blueprint/update.py
@frenck
frenck merged commit 5c98c23 into main Aug 31, 2026
21 checks passed
@frenck
frenck deleted the frenck/blueprint-update-names branch August 31, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Inconsistencies or issues which will cause a problem for users or implementors. documentation Solely about the documentation of the project.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants