Skip to content

Add sensor for todo entities#1116

Merged
frenck merged 5 commits into
frenck:mainfrom
josephabbey:patch-1
May 28, 2026
Merged

Add sensor for todo entities#1116
frenck merged 5 commits into
frenck:mainfrom
josephabbey:patch-1

Conversation

@josephabbey
Copy link
Copy Markdown
Contributor

Description

Added count sensor for todo entities.

Motivation and Context

There wasn't one, now there is.

How has this been tested?

Need to dust off the testing environment, will test in due course but small enough that it should work.

Screenshots (if appropriate):

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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 27, 2025

📝 Walkthrough

Walkthrough

Adds a new Home Assistant sensor descriptor that counts todo entities (sensor.todos), a translation entry for that sensor, and a documentation line describing the new sensor.

Changes

Cohort / File(s) Summary
Sensor descriptor
custom_components/spook/ectoplasms/homeassistant/sensor.py
Added HomeAssistantSpookSensorEntityDescription for Platform.TODO with translation_key: "homeassistant_todo", entity_id: "sensor.todos", icon: "mdi:clipboard-list", entity_category: EntityCategory.DIAGNOSTIC, state_class: SensorStateClass.TOTAL, update_events: {EVENT_COMPONENT_LOADED, er.EVENT_ENTITY_REGISTRY_UPDATED}, and value_fn returning len(hass.states.async_entity_ids(Platform.TODO)).
Translations
custom_components/spook/translations/en.json
Added "sensor" -> "homeassistant_todo": { "name": "To-do lists" }.
Documentation
documentation/devices_entities.md
Documented new public sensor: "Number of todo entities (sensor.todos)".

Sequence Diagram(s)

(omitted — change is a descriptor/translation/documentation addition; no new multi-component runtime control flow)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

maintenance

Poem

🐇📋 I nibble notes and count each row,
Tiny todos in soft moon's glow.
A sensor hums, the totals show,
Lists neatly lined where carrots grow.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add sensor for todo entities' clearly and concisely summarizes the main change: introducing a new sensor that counts todo entities.
Description check ✅ Passed The description is directly related to the changeset, explaining that a count sensor for todo entities was added and providing context about motivation and testing plans.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fb06925 and c518668.

📒 Files selected for processing (3)
  • custom_components/spook/ectoplasms/homeassistant/sensor.py (1 hunks)
  • custom_components/spook/translations/en.json (1 hunks)
  • documentation/devices_entities.md (1 hunks)
🔇 Additional comments (2)
documentation/devices_entities.md (1)

73-73: Documentation entry looks good.

The new todo entity counter is correctly documented and follows the established format.

custom_components/spook/translations/en.json (1)

183-185: Translation entry is correct.

The translation key matches the sensor descriptor and the name "To-do lists" is user-friendly.

Comment thread custom_components/spook/ectoplasms/homeassistant/sensor.py
@sonarqubecloud
Copy link
Copy Markdown

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
custom_components/spook/ectoplasms/homeassistant/sensor.py (1)

506-515: Add a small regression test for the TODO descriptor.

This table is repetitive, so this kind of addition is easy to break with copy/paste edits. A focused test that asserts sensor.todos uses Platform.TODO, translation_key="homeassistant_todo", and counts TODO states would make this safer to merge given the lack of test coverage in this PR.

If helpful, I can sketch a minimal test around SENSORS / HomeAssistantSpookSensorEntity.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@custom_components/spook/ectoplasms/homeassistant/sensor.py` around lines 506
- 515, Add a regression test that locates the
HomeAssistantSpookSensorEntityDescription for the TODO sensor (search SENSORS
for key=Platform.TODO or entity_id "sensor.todos"), then assert its
translation_key equals "homeassistant_todo" and its key equals Platform.TODO;
also exercise its value_fn by creating a few fake TODO states in the test hass
(use hass.states.async_set with Platform.TODO entity_ids) and assert
value_fn(hass) returns the expected count (len of TODO entity ids). Keep the
test focused and small so it fails if the descriptor is renamed, its
translation_key changes, or the counting logic in value_fn is broken.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@custom_components/spook/ectoplasms/homeassistant/sensor.py`:
- Around line 506-515: Add a regression test that locates the
HomeAssistantSpookSensorEntityDescription for the TODO sensor (search SENSORS
for key=Platform.TODO or entity_id "sensor.todos"), then assert its
translation_key equals "homeassistant_todo" and its key equals Platform.TODO;
also exercise its value_fn by creating a few fake TODO states in the test hass
(use hass.states.async_set with Platform.TODO entity_ids) and assert
value_fn(hass) returns the expected count (len of TODO entity ids). Keep the
test focused and small so it fails if the descriptor is renamed, its
translation_key changes, or the counting logic in value_fn is broken.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b8a1e47c-229f-472f-9d02-ce6b61e4e5f5

📥 Commits

Reviewing files that changed from the base of the PR and between a0c6812 and 04e54b2.

📒 Files selected for processing (3)
  • custom_components/spook/ectoplasms/homeassistant/sensor.py
  • custom_components/spook/translations/en.json
  • documentation/devices_entities.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • documentation/devices_entities.md

@frenckatron frenckatron added the new-feature New features or options. label May 28, 2026
@frenck frenck requested a review from Copilot May 28, 2026 08:54
Copy link
Copy Markdown

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 a Home Assistant diagnostic counter sensor for todo entities, aligning it with the existing per-domain entity count sensors in Spook.

Changes:

  • Adds sensor.todos backed by Platform.TODO.
  • Adds English translation for the new sensor name.
  • Updates device/entity documentation to list the new todo counter.

Reviewed changes

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

File Description
custom_components/spook/ectoplasms/homeassistant/sensor.py Adds the todo entity count sensor definition.
custom_components/spook/translations/en.json Adds the display name for the new todo sensor.
documentation/devices_entities.md Documents the default entity ID for the todo counter.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sonarqubecloud
Copy link
Copy Markdown

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.32%. Comparing base (0f5fba8) to head (f49f5da).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1116      +/-   ##
==========================================
+ Coverage   60.29%   60.32%   +0.03%     
==========================================
  Files         119      119              
  Lines        3035     3035              
  Branches      390      390              
==========================================
+ Hits         1830     1831       +1     
+ Misses       1166     1165       -1     
  Partials       39       39              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Owner

@frenck frenck left a comment

Choose a reason for hiding this comment

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

Thanks, @josephabbey 👍

../Frenck

                       

Blogging my personal ramblings at frenck.dev

@frenck frenck merged commit 8267f51 into frenck:main May 28, 2026
10 checks passed
@josephabbey josephabbey deleted the patch-1 branch May 28, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-feature New features or options.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants