Add sensor for todo entities#1116
Conversation
📝 WalkthroughWalkthroughAdds a new Home Assistant sensor descriptor that counts Changes
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
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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.
|
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
|
There was a problem hiding this comment.
🧹 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.todosusesPlatform.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
📒 Files selected for processing (3)
custom_components/spook/ectoplasms/homeassistant/sensor.pycustom_components/spook/translations/en.jsondocumentation/devices_entities.md
🚧 Files skipped from review as they are similar to previous changes (1)
- documentation/devices_entities.md
There was a problem hiding this comment.
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.todosbacked byPlatform.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.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|



Description
Added count sensor for
todoentities.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
Checklist