Page 1 of 1

How to extend tempsensor logtime to 12 months

Posted: Sunday 18 June 2017 9:38
by Klas
I am a new user (with some reasonable programmer experience) and like to extend display of my tempsensors history from 7 day to 12 months.
Has anyone looked into this issue while still keeping the sqlite database AND the Domoticz graphics display.
I am well aware of that som changes probably have to be made in the Domoticz source to achive this.

Re: How to extend tempsensor logtime to 12 months

Posted: Monday 19 June 2017 20:24
by Amsterdam020
You can save the data in a mysql database outside domoticz but running on the same pi.
Perhaps not the solution you are looking for but still an option.

http://www.domoticz.com/forum/viewtopic ... it=Youless
If you want I can adjust the script to temp sensors.

Re: How to extend tempsensor logtime to 12 months

Posted: Monday 19 June 2017 22:42
by K3rryBlue
I would go with Amsterdam020.
Create a new database for your templogging.
I prefer PHP and call it via a bash script. this script can be attached to a changed temperature sensor. So you only extract data when the sensor has changed. If you want to extract the data on regular base, you can call the PHP script via a cron. (crontab -e)

Code: Select all

<?php
# Standard url
$ip  = "http://xxx.xxx.xxx.xxx:xxxx";
# idx of tempsensor
$idx = 44
# Get Device information
$urlA = "/json.htm?type=devices&rid=";

function getJson($idx,$url,$val){
    $json_string_LRM = file_get_contents("$url" . "$idx");
    $parsed_json_LRM = json_decode($json_string_LRM, true);
    $parsed_json_LRM = $parsed_json_LRM['result'][0];
    $temp = $parsed_json_LRM[$val];
    return $temp;
}

$newval	 = getJson( $idx, $ip . $urlA, 'Data');  
 
//Open the SQLite database temperature.db
$db = new SQLite3('/home/pi/domoticz/temperature.db');
//insert row
$db->exec("INSERT INTO temp_log (DATE, TIME, LIVINGROOM_TEMP)   VALUES ($date,$time,$newval)");
?> 

Re: How to extend tempsensor logtime to 12 months

Posted: Tuesday 20 June 2017 7:17
by Klas
Thanks guys for your suggestions,
in fact I am already running a similar solution myself.
I still fail to understand why the user are not free to select raw data looging periode as an option.
SQLite can handle TB-data and user knows his disc space
I will have to look further in the source to see what is possible. 8-)

Re: How to extend tempsensor logtime to 12 months

Posted: Tuesday 20 June 2017 8:08
by Egregius
The short log setting handles the cleanup of the detailed information.
I still believe that that should be a per device setting as from most of the devices I don't want to keep the details.
That's directly the reason my short log is set to 1 and I store the data I want in a MySQL database.
Another reason is to have full control over it. Like I store the data of different temp sensors in 1 record each minute. That makes it very easy to create graphs with lines of multiple temps.
A good reason not to set the shortlog to long is the database size on the fragile SD memory.

Re: How to extend tempsensor logtime to 12 months

Posted: Tuesday 13 March 2018 7:34
by digdilem
Worth mentioning that not everyone uses a pi to run domoticz, so things like disk space and fragility of SD storage aren't always an issue.