home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.14k stars 29.81k forks source link

Logbook entries sometimes missing in live logbook #73554

Closed pimw1 closed 2 years ago

pimw1 commented 2 years ago

The problem

Hi,

For most of my devices, the new live logbook are displaying everything that i expect. I see one exception: events for zigbee buttons (Hue, Ikea, etc.), such as the Tradfri shortcut button (Zigbee), connected via Conbee II + Deconz.

image

The event is showing in the traditional logbook. image

Zigbee sensors are displaying state changes as expected (so the issue seems limited to events from zigbee devices that are stateless?).

image

What version of Home Assistant Core has the issue?

core-2022.6.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

logbook

Link to integration documentation on our website

https://www.home-assistant.io/integrations/logbook/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

It seems not related to https://github.com/home-assistant/core/pull/73419 , since the issue is persistent and not solved by a restart of Home Assistant.

probot-home-assistant[bot] commented 2 years ago

logbook documentation logbook source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

Hey there @home-assistant/core, @bdraco, mind taking a look at this issue as it has been labeled with an integration (logbook) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

probot-home-assistant[bot] commented 2 years ago

deconz documentation deconz source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

Hey there @kane610, mind taking a look at this issue as it has been labeled with an integration (deconz) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

bdraco commented 2 years ago

It's likely the event is missing the device_id so it can't be linked to the device. Can you find the row in the events table that is missing?

bdraco commented 2 years ago

https://data.home-assistant.io/docs/events

pimw1 commented 2 years ago

Sure, here is the row: image

bdraco commented 2 years ago

Sure, here is the row:

image

Can you post the row with data_id 504 from the event_data table as well?

pimw1 commented 2 years ago

Sure, it returns 13 rows:

image

bdraco commented 2 years ago

The content of the event is in another table called event_data. The data_id in the events table links to the row in the event_data table that has the actual event data for that event.

In your case it looks like the same event data happened 13 times so we only store the contents of the event data once.

We need to look at the contents of that data to see if the device_id is missing or there is some other reason we can't automatically find it in the database

pimw1 commented 2 years ago

It shows the following in event_data for data_id 504: image

bdraco commented 2 years ago

So we have the device_id, thats good.

Can you post the full url path (without the hostname) from this image?

image

pimw1 commented 2 years ago

The url is as follows: http://192.168.178.2:8123/config/devices/device/dc95c6af56c3b3643c4872c42d29371e

This is the same device_id as retrieved from the event_data table for data_id 504 (dc95c6af56c3b3643c4872c42d29371e)

bdraco commented 2 years ago

That all looks good.

I'm not sure why its not displaying. I'll try to add some tests for deconz events late this week and see if I can find the problem

pimw1 commented 2 years ago

Great, thank you for helping out.

pimw1 commented 2 years ago

If it helps, we can share screens and have a conference call in Discord as well.

bdraco commented 2 years ago

If it helps, we can share screens and have a conference call in Discord as well.

If I can't find it with the tests, I may take you up on that. I'm traveling this week so I won't have a stable enough connection until this weekend.

bdraco commented 2 years ago

As soon as https://github.com/home-assistant/core/pull/73918 merges I can look at this one.

bdraco commented 2 years ago

https://github.com/home-assistant/core/pull/73918 will fix the historical ones assuming you are using MySQL or PostgreSQL

bdraco commented 2 years ago

No luck replicating this one in testing so I ordered one of those buttons for testing Delivery by parcel to Houston, TX 77007 Estimated Delivery Date June 28, 2022 09:00 AM - 05:00 PM

pimw1 commented 2 years ago

Haha nice! Good to know is that i see this behaviour for Philips Hue switches too. My best guess is that this happens for any stateless zigbee switch in Deconz.

bdraco commented 2 years ago

Do you see it with a Hue Remote ?

pimw1 commented 2 years ago

Yes indeed :)

I see one exception: events for zigbee buttons (Hue, Ikea, etc.), such as the Tradfri shortcut button (Zigbee),

bdraco commented 2 years ago

Ok good. My hue remote works fine so I think this is deconz only.

pimw1 commented 2 years ago

Yeah it has to be. You're using another solution than Deconz?

bdraco commented 2 years ago

I did testing with the hue bridge and zha

bdraco commented 2 years ago

Good news. The button came in and it shows up in the live logbook but not the device page so I have a place to start debugging

Screen Shot 2022-06-27 at 15 03 22 Screen Shot 2022-06-27 at 15 04 02
bdraco commented 2 years ago

Found the bug. If we exclude all entities because they have a UOM we don't check for devices as well

Screen Shot 2022-06-27 at 15 17 53
pimw1 commented 2 years ago

Great that you found the root cause! Thank you very much for helping out.