I have a power plug which records the power consummation. This works fine. The problem is, that this plug displays every 5 seconds a new value. I tried to reduce, but it seams not to work. So at the end I have about 50’000 values a day. This is too much to display as a chart.
So I created a sql sensor which runs every 5 minutes:
- platform: sql
scan_interval: 600
queries:
- name: Power History Total
query: "SELECT * FROM states WHERE entity_id = 'sensor.power_total' ORDER BY state_id DESC LIMIT 1;"
column: 'state'
This works very well. I see my chart and I am happy. But now how can I delete after this 5 minutes the values?
At the moment I am storing values for 2 days. I want to increase to maybe a week. So I need to delete all this garbage/source values.
You will still get the same amount of data, but it won’t fill your db if you purge often. you could set a statistics sensor to help reduce the data to be displayed on your chart