Skip to content

Add optional device_mac_address parameter to get_consumption_info#70

Open
BradKollmyer wants to merge 3 commits into
bachya:devfrom
BradKollmyer:dev
Open

Add optional device_mac_address parameter to get_consumption_info#70
BradKollmyer wants to merge 3 commits into
bachya:devfrom
BradKollmyer:dev

Conversation

@BradKollmyer

Copy link
Copy Markdown

Closes #69

What this does

The /api/v2/water/consumption endpoint accepts a macAddress query parameter to scope results to a single device, same as /water/metrics. Today get_consumption_info only sends locationId, so locations with multiple Flo devices can only get the location-wide aggregate (which shows incorrect data, e.g. in the Home Assistant integration).

This adds an optional device_mac_address parameter to get_consumption_info, sent as macAddress with : separators stripped, matching how get_metrics handles MACs. Omitting it preserves the existing behavior, so the change is backwards compatible.

location_info = await api.location.get_info(location_id)
for device in location_info["devices"]:
    consumption = await api.water.get_consumption_info(
        location_id, start, end, device_mac_address=device["macAddress"]
    )

Also included

While running the test suite I hit a latent bug in API._request: resp.json() ran before raise_for_status(), so non-JSON error bodies (plain-text or HTML error pages) escaped as raw JSONDecodeError instead of being wrapped in RequestError. Swapped the order so HTTP errors are always raised as RequestError. This also fixes test_system_modes, which was failing because of it.

Testing

  • Extended test_get_consumption_info to cover the per-device call
  • Full suite passes: 15 passed

🤖 Generated with Claude Code

BradKollmyer and others added 3 commits June 10, 2026 14:05
Allows scoping consumption queries to a single device (via the
macAddress query param) for locations with multiple Flo devices.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Non-JSON error bodies (plain-text or HTML error pages) previously
escaped as raw JSONDecodeError instead of being wrapped in
RequestError, since resp.json() ran before raise_for_status().

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

Support passing mac address in water consumtion request

1 participant