Skip to content

Add stale device removal to Ghost integration#165134

Merged
joostlek merged 6 commits intohome-assistant:devfrom
JohnONolan:ghost-stale-devices
Mar 9, 2026
Merged

Add stale device removal to Ghost integration#165134
joostlek merged 6 commits intohome-assistant:devfrom
JohnONolan:ghost-stale-devices

Conversation

@JohnONolan
Copy link
Contributor

@JohnONolan JohnONolan commented Mar 8, 2026

Proposed change

Added stale device removal to Ghost integration to automatically add/remove newsletter sensors when they are created/archive in Ghost. Has been tested against production Ghost instances during dev, following a full reconfiguration, as well as adding and archiving Ghost newsletters to verify that the entities automatically appear / are removed.

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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

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
  • 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.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

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 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:

Copy link
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

Adds stale device/entity cleanup to the Ghost integration so newsletter subscriber sensors are automatically removed when the corresponding Ghost newsletter is archived or deleted, keeping the entity registry in sync with upstream.

Changes:

  • Remove stale newsletter sensor entities from the entity registry during setup and during coordinator updates.
  • Update newsletter sensor availability/removal behavior to prefer entity removal over STATE_UNAVAILABLE for missing newsletters.
  • Extend Ghost sensor tests to cover stale newsletter removal both on periodic refresh and on integration reload.

Reviewed changes

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

File Description
homeassistant/components/ghost/sensor.py Implements stale newsletter entity removal on startup and during coordinator updates.
tests/components/ghost/test_sensor.py Updates/extends tests to assert newsletter entities are removed from the registry when stale.
homeassistant/components/ghost/quality_scale.yaml Marks stale-devices rule as done to reflect the new behavior.

Copilot AI review requested due to automatic review settings March 9, 2026 11:07
Copy link
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 3 out of 3 changed files in this pull request and generated 2 comments.

Copilot AI review requested due to automatic review settings March 9, 2026 11:56
Copy link
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 3 out of 3 changed files in this pull request and generated no new comments.

@joostlek joostlek merged commit 1660d3b into home-assistant:dev Mar 9, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants