Skip to content

Batch history requests over WebSocket - #638

Open
rosenrot00 wants to merge 2 commits into
dbuezas:masterfrom
rosenrot00:batch-history-requests
Open

Batch history requests over WebSocket#638
rosenrot00 wants to merge 2 commits into
dbuezas:masterfrom
rosenrot00:batch-history-requests

Conversation

@rosenrot00

@rosenrot00 rosenrot00 commented Jul 30, 2026

Copy link
Copy Markdown
  • fetch regular Home Assistant history through history/history_during_period instead of the REST API
  • batch compatible entities that share a time range and response mode into one WebSocket request
  • normalize Home Assistant’s compressed WebSocket states while preserving expanded-state compatibility
  • retain attributes for attribute histories and keep differing time offsets in separate groups
  • avoid refetching ranges already covered by the cache

The REST path uses hass.callApi(), which sends Home Assistant’s bearer token in the HTTP Authorization header. This conflicts with reverse proxies that require HTTP Basic authentication in the same header and causes repeated authentication prompts.

Using Home Assistant’s existing authenticated WebSocket avoids that header conflict. It also removes the per-request HTTP overhead and reduces a card with four compatible history entities from four requests to one.

Fixes #606

@rosenrot00 rosenrot00 changed the title Batch compatible history requests Batch history requests over WebSocket Jul 30, 2026
@dbuezas

dbuezas commented Jul 30, 2026

Copy link
Copy Markdown
Owner

This is great work, those APIs weren't there when i first created the card.

I can't test it thoroughly at the moment, but if you do and confirm everything is great I'll review from my phone and merge. Just let me know when it is ready

@rosenrot00

rosenrot00 commented Jul 30, 2026

Copy link
Copy Markdown
Author

Thank you! I can confirm that all the tests created worked and that my ten plots in homeassistant work.

In case someone reports an issue I will act fast, this is what I can promise :)

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.

Failed authentication behind a reverse proxy

2 participants