Refactor logbook data fetch logic into reusable class#12701
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
|
Also when I create 3 logbook cards its calling |
|
Here is the yaml I'm using for the logbook card testing - theme: Backend-selected
title: Logbook Card Test
path: logbook-card-test
badges: []
cards:
- type: logbook
entities:
- light.master_hall_lights_g
- light.kitchen_recessed_lights_g
- light.upstairs_hall_large_lights_g
- automation.elk_system_has_motion
- type: logbook
entities:
- cover.driveway_gate_local
- cover.large_garage_door_local
- cover.small_garage_door_local
- type: logbook
entities:
- cover.entry_front_door_shade
- automation.front_door_doorbell |
|
console error was caused by bad testing on my part - the cache not being fully cleared. The duplicate |
This comment was marked as outdated.
This comment was marked as outdated.
|
The users being fetched every time isn't a bug, its just polling because there is no listener for to know when the users change. We can't add one because we need to know when they are updated as well. |
|
Getting that same trace on the related logbook entries under traces. Tried a different browser as well to make sure it wasn't a cache issue |
|
The traces just needed |
|
Selecting a single entity isn't working. |
|
Refreshing isn't working. I think it needs I guess it never makes sense to allow refresh if the previous call's endRange was less than 60s before |
|
I wonder if it would reduce the latency by any perceptible amount if the |
|
Thanks for testng. Pushed a bunch of bug fixes. I have not added caching of requests for users/contexts yet when multiple cards are visible. I did add a 60s throttle so they are only checked every 60 seconds on a per-card basis. I tried creating the get_events promise first before refreshing users/context, but fetching events does a bunch of extra work checking for caching so it wasn't firing it prior to the others, so reverted that change. This is only the first pass. I think that we can spend future PRs in optimizing the fetching of data, including using https://github.com/home-assistant/frontend/blob/refactor-logbook/src/common/util/time-cache-function-promise.ts#L12 |
|
Pulling and doing another test cycle |
|
Not sure if its just perception but the data parsing on the frontend seems snappier 👍 |
|
Existing issue: the drop down will let me select entities that will never have logbook history such as sensors with UOM or entities with a state class |
|
I beat it up the best I could. That was all I found |
|
Fixed more bugs:
|
|
Retesting now.. |
Confirmed
Confirmed
Agree this is better
Still haven't come up with a good answer on what to do here
Confirmed. So nice.
Confirmed |
|
Did manage to get a weird error |
|
This url repos it |
|
Oh, I think its just selecting a time window in the future |
|
Yup |
diff --git a/src/data/logbook.ts b/src/data/logbook.ts
index 9e5f2ac4a..d492d767d 100644
--- a/src/data/logbook.ts
+++ b/src/data/logbook.ts
@@ -118,7 +118,7 @@ export const getLogbookDataCache = async (
startDate,
endDate,
entityId !== ALL_ENTITIES ? entityId : undefined
- ).then((entries) => entries.reverse());
+ ).then((entries) => entries.length ? entries.reverse() : []);
return DATA_CACHE[cacheKey][entityId];
};
|
|
That issue is caused by a bug in the backend. Fix here home-assistant/core#72021 |
Good catch 👍 |






Breaking change
Proposed change
The logbook fetch data logic was spread over 3 different places (panel, more info, card). This puts it all in 1 re-usable class.
Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: