Page 1 of 1

Clear future history

Posted: Tuesday 31 August 2021 8:28
by xayide
I have had an accident where the date was wrong by a few years and domoticz logged history in the future so to speak. This renders all graphs to simple flatline. How can I remove all history logs for all devices from current time (+ 1minute) and forwards?

I have a few hundred devices so it will be timeconsuming to do this manually and preferable a SQL would help. I found an API that could do this on a per device manner, but it's very time consuming.

Re: Clear future history

Posted: Tuesday 31 August 2021 13:28
by erem
install sqlitebrowser (https://sqlitebrowser.org)

Code: Select all

sudo apt-get install sqlitebrowser
stop domoticz
backup database
open database with sqlitebrowser
from the execute sql tab:

delete the future records from the *_calendar tables
with this statement for each *_calendar table that has future dates

Code: Select all

delete from <tablename>_Calendar
where date > '2021-08-31'
example

Code: Select all

delete from MultiMeter_Calendar
where date > '2021-08-31'
don't forget to write changes
start domoticz

Re: Clear future history

Posted: Tuesday 31 August 2021 21:23
by xayide
Wow thank you. So it is an ordinary sqlite-db. I was thinking along the lines of using the webapi but felt on the number devices…

/json.htm?type=command&param=deletedaterange&idx=IDX&fromdate=FROMDATE&todate=TODATE