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
69.79k stars 28.93k forks source link

Recorder Many State Attributes for Changing Light Attributes #118670

Open DracoC77 opened 1 month ago

DracoC77 commented 1 month ago

The problem

My sqlite DB file was getting un-expectedly large so I did some deep diving into why the file size was so large and found something unusual... state_attributes was taking up a huge amount of the total filesize for some reason:

* Page counts for all tables with their indices *** STATE_ATTRIBUTES.................................. 383395 45.2% STATES............................................ 324599 38.3% STATISTICS_SHORT_TERM............................. 23208 2.7% STATISTICS........................................ 12366 1.5% EVENTS............................................ 492 0.058% EVENT_DATA........................................ 178 0.021% STATISTICS_RUNS................................... 30 0.004% STATES_META....................................... 27 0.003% STATISTICS_META................................... 13 0.002% SQLITE_SCHEMA..................................... 3 0.0% EVENT_TYPES....................................... 2 0.0% MIGRATION_CHANGES................................. 2 0.0% RECORDER_RUNS..................................... 2 0.0% SCHEMA_CHANGES.................................... 1 0.0% SQLITE_STAT1...................................... 1 0.0%

Looking at the actual database file a bit more closely, I noticed that I had a TON of entries for my lights: state_attributes

It looks like whenever an attribute on my smart light was being changed, it created a NEW entry in the sqlite database under state_attributes for that specific combination of settings. Because I'm running the Adaptive Lighting custom integration, all of my lights get a lot of different light color and brightness commands throughout the day, which seems to be blowing up the size of my sqlite db file.

Is there a way to exclude just specific attribute changes in recorder or make it such that recorder is not writing a whole new state_attributes for each combination of attributes on lights?

What version of Home Assistant Core has the issue?

core-2024.5.3

What was the last working version of Home Assistant Core?

core-2024.5.3

What type of installation are you running?

Home Assistant Container

Integration causing the issue

recorder + any smartlight with different attributes

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 month ago

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

Code owner commands Code owners of `recorder` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign recorder` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


recorder documentation recorder source (message by IssueLinks)