How to extend tempsensor logtime to 12 months

Moderator: leecollings

Post Reply
Klas
Posts: 2
Joined: Saturday 17 June 2017 8:31
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

How to extend tempsensor logtime to 12 months

Post 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.
Amsterdam020
Posts: 55
Joined: Saturday 05 March 2016 21:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5629
Contact:

Re: How to extend tempsensor logtime to 12 months

Post 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.
Rp3, youlesss, rfxcom, philips hue, dsb1820
User avatar
K3rryBlue
Posts: 77
Joined: Tuesday 07 February 2017 22:13
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10xx
Location: Netherlands
Contact:

Re: How to extend tempsensor logtime to 12 months

Post 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)");
?> 
Domoticz V4.10717, RPi2 -> Linux raspberrypi 4.4.47-v7+ , RFXCOM - RFXtrx433 USB 433.92MHz ,RAZBERRY2 and OpenZWave USB Version: 1.4-2363-g1f10253-dirty
Klas
Posts: 2
Joined: Saturday 17 June 2017 8:31
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: How to extend tempsensor logtime to 12 months

Post 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-)
User avatar
Egregius
Posts: 2591
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: How to extend tempsensor logtime to 12 months

Post 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.
digdilem
Posts: 5
Joined: Sunday 14 January 2018 14:31
Target OS: Linux
Domoticz version:
Contact:

Re: How to extend tempsensor logtime to 12 months

Post 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.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest