Skip to content
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

[Bug]: localtuya is flooding the DB of events #517

Open
3 tasks
m4r1k opened this issue Jan 27, 2025 · 4 comments
Open
3 tasks

[Bug]: localtuya is flooding the DB of events #517

m4r1k opened this issue Jan 27, 2025 · 4 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@m4r1k
Copy link

m4r1k commented Jan 27, 2025

LocalTuya Version

2025.1.1

Home Assistant Version

2025.1.4 Docker

Environment

  • Does the device work using the Home Assistant Tuya Cloud component?
  • Is this device connected to another local integration, including Home Assistant and any other tools?
  • The devices are within the same HA subnet, and they get discovered automatically when I add them

What happened?

Hello there,

I just reported on the HA community how LocalTuya is flooding the DB of events.
https://community.home-assistant.io/t/how-to-keep-your-recorder-database-size-under-control/295795/303?u=m4r1k

42970497|47|localtuya_device_triggered
41694080|45|localtuya_device_dp_triggered
6170957|6|localtuya_states_update

The events are described here: https://github.com/xZetsubou/hass-localtuya/blob/master/documentation/docs/ha_events.md?plain=1

But I think there should be a config on a per-device basis to record all this many events.
Also, I've seen an increase in the number of events from the 2025.1 version.

Steps to reproduce.

unclear

Relevant log output

Diagnostics information.

No response

@m4r1k m4r1k added the bug Something isn't working label Jan 27, 2025
@xZetsubou
Copy link
Owner

The is an old issue #372 tho I haven't give it much attention yet so yes I would recommended to exclude it from recorder for now, this could happen if you have a sensors that update every seconds.

@xZetsubou xZetsubou added the enhancement New feature or request label Jan 27, 2025
@Cook23
Copy link

Cook23 commented Feb 19, 2025

For every new version I make the same modification:

to remove it locally you can comment out a line in localtuya module. from home assistant directory. config/custom_components/localtuya/coordinator.py open the file and search for this line

self._handle_event(self._status, status)

then comment it out or remove you can comment it out by adding "#" at the beginning of the text # self.....

If not "event" and "event_data" table of database grow by several gigabytes every day.

This recording of events by "self._handle_event(self._status, status)" should definitively be an option disabled by default.

@xZetsubou
Copy link
Owner

this method handle the whole device not only one entity, Now the issue even If I give the user the option to turn it on it's still an issue it's still an issue and If HA doesn't give an option to filter it hard coded, then I'll need to create filter my self it's fine it's not big deal I'll look into it soon.

@Cook23
Copy link

Cook23 commented Feb 19, 2025

Yes but I don't know the reason of these writes in "event" tables of database for every entities. In fact I don't know the use of "event" tables.

For me it's completely useless. The only data I use come from the "state" and "statistics" tables of database. If I truncate these "event" tables nothing change, home assistant still running flawlessly without any difference. I imagine "event" tables have some use but I didn't see it.

It's possible to choose what is recorded in "state" tables from recorder settings but these settings have no effect on event tables.

So I only see "event" tables as a major flaw that cause my home assistant eat my memory and became unfunctionnal in just few weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants