Skip to content

v0.4.0 — async API upgrade, nursing rename, required device_id, calendar entity#20

Open
Copilot wants to merge 21 commits intomainfrom
copilot/review-wip-changes
Open

v0.4.0 — async API upgrade, nursing rename, required device_id, calendar entity#20
Copilot wants to merge 21 commits intomainfrom
copilot/review-wip-changes

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 10, 2026

Major rewrite upgrading to huckleberry-api v0.2.3 with a full async architecture, breaking renames, and a stricter service API. See MIGRATION.md for a step-by-step upgrade guide.

Breaking Changes

Services: child_uid removed, device_id now required

child_uid is no longer accepted. Every service call must provide device_id (the HA device for the child). The first-child fallback is also gone.

# Before — child_uid override accepted, device_id optional
action: huckleberry.start_sleep
data:
  child_uid: VZiSnxmU3KawWzsSLTqyuPTlsuX2

# After — device_id required, resolved via device registry
action: huckleberry.start_sleep
data:
  device_id: <child_device_id>

Services renamed: feeding → nursing

Old New
huckleberry.start_feeding huckleberry.start_nursing
huckleberry.pause_feeding huckleberry.pause_nursing
huckleberry.resume_feeding huckleberry.resume_nursing
huckleberry.switch_feeding_side huckleberry.switch_nursing_side
huckleberry.cancel_feeding huckleberry.cancel_nursing
huckleberry.complete_feeding huckleberry.complete_nursing

Entity IDs changed

Old New
switch.{child}_sleep_tracking switch.{child}_sleep_timer
switch.{child}_feeding_left/right switch.{child}_nursing_left/right
sensor.{child}_sleep_status sensor.{child}_sleep
sensor.{child}_feeding_status sensor.{child}_nursing
sensor.{child}_last_diaper sensor.{child}_diaper
sensor.{child}_last_bottle sensor.{child}_bottle

Sensors last_feeding_side, previous_sleep_start, previous_sleep_end removed — data is now in attributes on the main sensors.

Device actions removed

All 17 device actions removed. Use HA services with the device_id selector instead.

New Features

  • Calendar entity (calendar.{child}_events) — historical sleep, nursing, diaper, and growth events
  • Fully async — no executor wrappers; uses HA's shared aiohttp session throughout
  • Feature modules — entities refactored into features/ (sleep, nursing, bottle, diaper, growth, child)
  • Orphan cleanup — devices/entities for removed children are pruned on reload
  • Minimum HA 2026.3 (Python 3.14) declared in hacs.json

Dependency

huckleberry-api bumped 0.1.190.2.3 (native async API, typed models).

Original prompt

review changes on wip branch,
you need to make a pr with those changes
make sure to go through all the changes and look for any possible changes to improve/simplify this integration.
in pr description add full list of changes from user perspective, what entities changed in what way, notice any breaking changes. make sure to write clear migration instructions

The user has attached the following file paths as relevant context:

  • AGENTS.md

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.

Copilot AI and others added 2 commits March 10, 2026 21:31
… simplified entities (v0.4.0)

Co-authored-by: Woyken <13166802+Woyken@users.noreply.github.com>
Copilot AI changed the title [WIP] Review integration changes from wip branch feat: huckleberry-api v0.2.2, full async, simplified entity model (v0.4.0) Mar 10, 2026
…on dispatch, fix services.yaml required fields

Co-authored-by: Woyken <13166802+Woyken@users.noreply.github.com>
Copilot AI changed the title feat: huckleberry-api v0.2.2, full async, simplified entity model (v0.4.0) feat: wip branch merge — async API v0.2.2, simplified entities, consistent nursing naming (v0.4.0) Mar 10, 2026
"log_diaper_pee": ("log_diaper_pee", {}),
"log_diaper_poo": ("log_diaper_poo", {}),
"log_diaper_both": ("log_diaper_both", {}),
"log_diaper_dry": ("log_diaper_dry", {}),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

remove all these custom device actions, we'll use actions/services instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 7ddf1eddevice_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>
@Woyken Woyken marked this pull request as ready for review March 11, 2026 21:55
@Woyken Woyken requested a review from Copilot March 11, 2026 21:55
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

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 / HuckleberryChildState and 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.

Comment thread custom_components/huckleberry/__init__.py
Comment thread README.md Outdated
Comment thread pyproject.toml Outdated
Woyken and others added 2 commits March 12, 2026 00:04
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…n service calls

Co-authored-by: Woyken <13166802+Woyken@users.noreply.github.com>
Repository owner deleted a comment from Copilot AI Mar 12, 2026
Co-authored-by: Woyken <13166802+Woyken@users.noreply.github.com>
…lidation)

Co-authored-by: Woyken <13166802+Woyken@users.noreply.github.com>
Copilot AI changed the title feat: wip branch merge — async API v0.2.2, simplified entities, consistent nursing naming (v0.4.0) fix: remove invalid homeassistant key from manifest.json, move HA min version to hacs.json Mar 12, 2026
Co-authored-by: Woyken <13166802+Woyken@users.noreply.github.com>
Copilot AI changed the title fix: remove invalid homeassistant key from manifest.json, move HA min version to hacs.json chore: update huckleberry-api to 0.2.3 Mar 12, 2026
Co-authored-by: Woyken <13166802+Woyken@users.noreply.github.com>
Copilot AI changed the title chore: update huckleberry-api to 0.2.3 Bump huckleberry-api to 0.2.3 Mar 12, 2026
Copy link
Copy Markdown
Owner

@Woyken Woyken left a comment

Choose a reason for hiding this comment

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

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>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 12, 2026

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

Done in 63477ef. Added MIGRATION.md with a full breakdown of all breaking changes (service renames, entity ID changes, removed sensors, removed device actions, and the new mandatory target requirement). Updated README.md to correct all stale entity IDs, service names, and the requirements section, and added a migration callout in the Features section.

Copilot AI changed the title Bump huckleberry-api to 0.2.3 v0.4.0 — async API upgrade, nursing rename, calendar entity, and breaking changes Mar 12, 2026
Co-authored-by: Woyken <13166802+Woyken@users.noreply.github.com>
Copilot AI changed the title v0.4.0 — async API upgrade, nursing rename, calendar entity, and breaking changes v0.4.0 — async API upgrade, nursing rename, required device_id, calendar entity Mar 12, 2026
@pbegg
Copy link
Copy Markdown

pbegg commented Apr 21, 2026

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.

@Woyken
Copy link
Copy Markdown
Owner

Woyken commented Apr 22, 2026

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants