v0.4.0 — async API upgrade, nursing rename, required device_id, calendar entity#20
v0.4.0 — async API upgrade, nursing rename, required device_id, calendar entity#20
Conversation
… use ISO 8601 format for datetime and duration in attributes
… simplified entities (v0.4.0) Co-authored-by: Woyken <13166802+Woyken@users.noreply.github.com>
…on dispatch, fix services.yaml required fields Co-authored-by: Woyken <13166802+Woyken@users.noreply.github.com>
| "log_diaper_pee": ("log_diaper_pee", {}), | ||
| "log_diaper_poo": ("log_diaper_poo", {}), | ||
| "log_diaper_both": ("log_diaper_both", {}), | ||
| "log_diaper_dry": ("log_diaper_dry", {}), |
There was a problem hiding this comment.
remove all these custom device actions, we'll use actions/services instead
There was a problem hiding this comment.
Done in 7ddf1ed — device_action.py and its test file have been deleted. HA services registered in __init__.py are directly usable in automations.
…ns directly Co-authored-by: Woyken <13166802+Woyken@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR merges the wip branch updates to move the Huckleberry integration onto huckleberry-api v0.2.2’s native async API, refactors the integration around typed models + feature modules, and applies the breaking rename from “feeding” to “nursing” across entities/services.
Changes:
- Upgrade to
huckleberry-api==0.2.2, remove executor wrappers, and use HA’s shared aiohttp session (incl. config flow). - Refactor entities into feature modules with typed
HuckleberryChildProfile/HuckleberryChildStateand centralized timestamp helpers. - Introduce breaking renames (feeding→nursing, sleep switch naming, sensor ID changes) and prune orphaned child devices/entities on reload.
Reviewed changes
Copilot reviewed 38 out of 39 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_timestamps.py | Adds unit tests for ISO8601 duration formatting helper. |
| tests/test_switch.py | Updates switch tests for new sleep timer + nursing switches and typed Firebase models. |
| tests/test_sleep_feed_sensors.py | Updates tests for renamed sleep/nursing sensors and new attributes. |
| tests/test_services.py | Updates service tests for nursing rename and bottle API rename. |
| tests/test_sensor.py | Updates sensors tests for typed models, timestamp formatting, and new entity IDs. |
| tests/test_multiple_children.py | Updates multi-child tests for renamed entities and adds orphan pruning test. |
| tests/test_live_integration.py | Ensures live test setup uses a loop-bound aiohttp session via patching. |
| tests/test_history_sensors.py | Moves “previous/last” history assertions onto current sleep/nursing sensors’ attributes. |
| tests/test_device_action.py | Removes device action tests (device_action support removed). |
| tests/test_config_flow.py | Updates config flow tests from requests exceptions to aiohttp exceptions. |
| tests/test_calendar.py | Updates calendar tests to typed child profile + typed interval builders. |
| tests/conftest.py | Rebuilds API mocks as async-first and uses typed Firebase user/child documents. |
| pyproject.toml | Bumps project version/deps, adds ruff/ty config, updates Python target. |
| custom_components/huckleberry/timestamps.py | Adds timestamp/duration normalization helpers (sec/ms handling + ISO8601 formatting). |
| custom_components/huckleberry/switch.py | Makes switch platform a thin entrypoint assembling feature switches. |
| custom_components/huckleberry/services.yaml | Renames feeding services→nursing, updates fields (device_id optional, resume side exposed). |
| custom_components/huckleberry/sensor.py | Makes sensor platform a thin entrypoint assembling feature sensors. |
| custom_components/huckleberry/models.py | Introduces typed child profile/state dataclasses and children sensor attribute builder. |
| custom_components/huckleberry/manifest.json | Updates integration version + huckleberry-api requirement to 0.2.2. |
| custom_components/huckleberry/features/init.py | Adds package marker for feature modules. |
| custom_components/huckleberry/features/sleep.py | New sleep sensor + sleep timer switch implementation. |
| custom_components/huckleberry/features/nursing.py | New nursing sensor + left/right nursing switches implementation. |
| custom_components/huckleberry/features/growth.py | New growth timestamp sensor using typed health document data. |
| custom_components/huckleberry/features/diaper.py | New diaper timestamp sensor using typed diaper document data. |
| custom_components/huckleberry/features/child.py | New children aggregate sensor + per-child profile sensor using typed profiles. |
| custom_components/huckleberry/features/bottle.py | New bottle timestamp sensor using typed feed prefs data. |
| custom_components/huckleberry/entity.py | Refactors base entity to typed child profile and validates configuration_url. |
| custom_components/huckleberry/device_action.py | Removes device action implementation. |
| custom_components/huckleberry/config_flow.py | Migrates config flow to aiohttp + native-async API usage. |
| custom_components/huckleberry/calendar.py | Refactors calendar to native-async API interval listing and typed interval->event builders. |
| custom_components/huckleberry/init.py | Refactors setup/coordinator/services to async API, adds orphan pruning, closes Firestore transports on unload. |
| custom_components/huckleberry/README.md | Updates documented sleep switch entity ID. |
| README.md | Partially updates entity list, adds dev commands section. |
| AGENTS.md | Updates architecture docs (feature modules, nursing naming, removes device_action guidance). |
| .python-version | Updates local Python version pin. |
| .github/workflows/pr-validation.yml | Adds PR validation workflow running ruff + ty. |
| .devcontainer/devcontainer.json | Updates container lifecycle command and adds ruff/ty extensions. |
| .devcontainer/Dockerfile | Updates devcontainer base image Python version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…n service calls Co-authored-by: Woyken <13166802+Woyken@users.noreply.github.com>
Co-authored-by: Woyken <13166802+Woyken@users.noreply.github.com>
…lidation) Co-authored-by: Woyken <13166802+Woyken@users.noreply.github.com>
homeassistant key from manifest.json, move HA min version to hacs.json
Co-authored-by: Woyken <13166802+Woyken@users.noreply.github.com>
homeassistant key from manifest.json, move HA min version to hacs.jsonCo-authored-by: Woyken <13166802+Woyken@users.noreply.github.com>
Woyken
left a comment
There was a problem hiding this comment.
Update PR description with actual all changes in this PR.
Update PR description Add migration details, what has changed, and where to find it now.
Update PR description List all breaking changes
Create migration guide markdown file, that will guide user through updating process and migrating their automations and sensors
Co-authored-by: Woyken <13166802+Woyken@users.noreply.github.com>
Done in 63477ef. Added |
Co-authored-by: Woyken <13166802+Woyken@users.noreply.github.com>
|
What is the status of merging the changes to work with the latest api? Is there anything I can help with to get this moved across. The HA integration of Huckleberry is better than the app in my opinion. |
I'm really struggling to find time to test the changes (sleep regression and other life stuff). I remember there was an issue with refreshing token, last time I checked. |
Major rewrite upgrading to
huckleberry-apiv0.2.3 with a full async architecture, breaking renames, and a stricter service API. SeeMIGRATION.mdfor a step-by-step upgrade guide.Breaking Changes
Services:
child_uidremoved,device_idnow requiredchild_uidis no longer accepted. Every service call must providedevice_id(the HA device for the child). The first-child fallback is also gone.Services renamed: feeding → nursing
huckleberry.start_feedinghuckleberry.start_nursinghuckleberry.pause_feedinghuckleberry.pause_nursinghuckleberry.resume_feedinghuckleberry.resume_nursinghuckleberry.switch_feeding_sidehuckleberry.switch_nursing_sidehuckleberry.cancel_feedinghuckleberry.cancel_nursinghuckleberry.complete_feedinghuckleberry.complete_nursingEntity IDs changed
switch.{child}_sleep_trackingswitch.{child}_sleep_timerswitch.{child}_feeding_left/rightswitch.{child}_nursing_left/rightsensor.{child}_sleep_statussensor.{child}_sleepsensor.{child}_feeding_statussensor.{child}_nursingsensor.{child}_last_diapersensor.{child}_diapersensor.{child}_last_bottlesensor.{child}_bottleSensors
last_feeding_side,previous_sleep_start,previous_sleep_endremoved — data is now in attributes on the main sensors.Device actions removed
All 17 device actions removed. Use HA services with the
device_idselector instead.New Features
calendar.{child}_events) — historical sleep, nursing, diaper, and growth eventsaiohttpsession throughoutfeatures/(sleep, nursing, bottle, diaper, growth, child)hacs.jsonDependency
huckleberry-apibumped0.1.19→0.2.3(native async API, typed models).Original prompt
Created from VS Code.
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.