New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
logbook card show no automation trigger after update #55724
Comments
Probably same issue here: custom entries created with logbook.log service are no longer shown in logbook card. They are still shown in the logbook menu, so only the lovelace card was affected, I think. |
My experience is the same as pratesbh ... the problem is only with custom logbook entries created with the logbook.log service. If I configure the logbook card to display entries for an entry that is automatically created by HASS, the card will display those entries, as before. Just tested and this issue is still present in 2021.8.6 |
I have the same problem. I have this dummy sensor:
When I create a log entry (by developer tools, Node-Red, etc...) on this sensor, it is visible in logbook on the sidebar. But it is NOT visible in the lovelace logbook card. |
Same issue here, I use the logbook.log service and it’s visible in the logbooks but not the card. |
+1 |
I've been debugging against 2021.9.1 ExpectationsI believe we should be able to call the Since 2021.8, these messages show on the panel, but not the card. Why are the logger panel and the logger card returning different results?The logbook page does a request to:
The logbook panel does a request to
For the same timespan, this additional query parameter causes two changes in my environment:
What does
|
def _get_events( | |
hass, | |
start_day, | |
end_day, | |
entity_ids=None, | |
filters=None, | |
entities_filter=None, | |
entity_matches_only=False, | |
context_id=None, | |
): |
Nov 2020
The Logbook card was introduced by home-assistant/frontend#6976.
Since its introduction, it has set entity_matches_only
to true
in the underlying data request:
This hasn't changed since.
Jul 2021
A database optimisation was introduced by #53364. This optimisation changes the JSON encoding of the JSON blobs in the events
table to use less whitespace, aiming for storage savings.
It was noted that this PR as initially implemented would break some current logbook related queries: #53364 (comment)
A fix for this was implemented as ad5d90d and included in the PR before it landed.
The timing of this change lines up with when this issue was reported, and it touches the template used in this branch of the query.
Where to?
@bdraco - You introduced the entity_matches_only
path. Can you see a reason why the Logbook card should explicitly set this to true
, where the Logbook panel does not?
@zsarnett - You built the card. Can you remember an explicit intent for setting entity_matches_only
to true in the query for the card?
This is a flakey code path overall because of the string matching, but I think the bug particularly came to life in https://github.com/home-assistant/core/pull/53364/files#diff-1c6068d2025d7d23111929ff066852fba3a7ebc285d8c9c3f05563ee257fa6f2R51-R54, landed with #53364 These four lines were updated to be 'whitespace-flexible', so they could work with the compact JSON optimisation: ENTITY_ID_JSON_TEMPLATE = '"entity_id": "{}"'
ENTITY_ID_JSON_EXTRACT = re.compile('"entity_id": "([^"]+)"')
DOMAIN_JSON_EXTRACT = re.compile('"domain": "([^"]+)"')
ICON_JSON_EXTRACT = re.compile('"icon": "([^"]+)"') They were updated to: ENTITY_ID_JSON_TEMPLATE = '"entity_id": ?"{}"'
ENTITY_ID_JSON_EXTRACT = re.compile('"entity_id": ?"([^"]+)"')
DOMAIN_JSON_EXTRACT = re.compile('"domain": ?"([^"]+)"')
ICON_JSON_EXTRACT = re.compile('"icon": ?"([^"]+)"') A The target-state change would have been to remove the whitespace instead: ENTITY_ID_JSON_TEMPLATE = '"entity_id":"{}"' But thanks to the mixed whitespace now in everyone's databases, that would only match new records. So I think there are four light-touch options:
This is my first time really trawling through the HA code, so I'm hoping for guidance on what approach would be considered preferable. |
Oops. I obviously missed that. Looks like we need another test to prevent this from breaking in the future as its a bit brittle. The goal of the template matcher is to have the database code do the matching so we can reject the row in the must faster C code and avoid de-serializing the data. The cost of de-serializing the json can be multiple orders of magnitude higher than any other operation in the logbook since we can potentially be rejecting the majority of the rows that don't match the entity id. When the logbook card first came out we hard a large number of reports of system instability (the query couldn't finish in time before the next one started which lead to a cascading failure and executor overload) due to the duration and cpu cost of the queries which lead to this compromise. Ideally we would have more normalized data in the database and could do cleaner solution, but thats outside the scope of this discussion as it would be too large of a change and require data migration.
I think it is ok to change tathamoddie: Nice work on analyzing the root cause. |
This is likely needs to be solved in |
logbook documentation |
I've proposed a fix, and a test to prevent future regression, in #55761. Now pending review. |
Checklist
Describe the issue you are experiencing
i have a problem , after update to the latest update, i can not see the trigged automation info , in my lovelance logbook card in the system logbook i see it but not in the card... before update no problem any one have an solution<? bug in automation.trigger? when i set on/off i see it in log card , not when it trigged :(
Describe the behavior you expected
automation.trigger not showing in the logbook card ... 2021.7 no problem
Steps to reproduce the issue
...
What version of Home Assistant Core has the issue?
2021.8.2
What was the last working version of Home Assistant Core?
2021.7
In which browser are you experiencing the issue with?
all
Which operating system are you using to run this browser?
Big Sur
State of relevant entities
No response
Problem-relevant frontend configuration
No response
Javascript errors shown in your browser console/inspector
No response
Additional information
The text was updated successfully, but these errors were encountered: