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

Delete all data before import #106

Closed
3 tasks done
daniele-athome opened this issue Feb 11, 2025 · 2 comments
Closed
3 tasks done

Delete all data before import #106

daniele-athome opened this issue Feb 11, 2025 · 2 comments

Comments

@daniele-athome
Copy link

Checklist

  • I have filled out the template to the best of my ability.
  • This only contains 1 feature request (if you have multiple feature requests, open one feature request for each feature request).
  • This issue is not a duplicate feature request of previous feature requests.

Is your feature request related to a problem? Please describe.

I don't have smart meters to register power consuptiom from, so I import statistics regularly from a centralized repository where I can get power consumption values. This means that only a few days are covered by statistics - and always in the past.

The first import is ok (the system was clean before, no data present). However, subsequent imports will produce negative values in recent periods. To fix that I have to:

  • delete all sensors data from states, statistics, statistics_short_term
  • remove entity state from .storage/core.restore_state

Is there a way to do that from this integration? I'm willing to implement that myself, but first I'd like to know what you think about it and maybe if you think there is a easier workaround.

Thanks!

Describe the solution you'd like

I'd like to delete all sensors data before doing an import - or an alternate way to have accumulated statistics by HA not interfere with imported past data.

Describe alternatives you've considered

Maybe artificially filling the CSV data to provide every hours of every day (repeating the previous value) so there are no gaps in the data?

Additional context

None that I think of.

@klausj1
Copy link
Owner

klausj1 commented Feb 12, 2025

I do not think that deleting all data is a good approach. Probably there is an issue with wrong values for sum and/or state, there are already many posts in the HA forum and/or issues here. When importing new values, you have to make sure that you start from the last existing value, and the values always increase monotonic. To automate this would be a valuable feature, if you can contribute this, that would be great.

@daniele-athome
Copy link
Author

When importing new values, you have to make sure that you start from the last existing value, and the values always increase monotonic.

Thanks, I was afraid of that.

To automate this would be a valuable feature, if you can contribute this, that would be great.

I will think of something :-)

@daniele-athome daniele-athome closed this as not planned Won't fix, can't repro, duplicate, stale Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants