Page 1 of 1
Time of use per day in statics
Posted: Friday 02 September 2016 14:16
by ayasystems
Hi,
I want monitor the used time of my heating. There are any dummy device to do it?
I speak about see in log details the total time used per day like you can do with total Watts per day...
Best regards!
Re: Time of use per day in statics
Posted: Friday 02 September 2016 16:02
by Egregius
Some example code:
Code: Select all
echo '<table>';
$datas = json_decode(file_get_contents($domoticzurl.'json.htm?type=lightlog&idx=131',true,$ctx),true);
$status = '';$tijdprev = $time;$totalon = 0;
if(!empty($datas['result'])) {
foreach($datas['result'] as $data) {
if($status!=$data['Status']) {
$status=$data['Status'];
$level=$data['Level'];
$tijd = strtotime($data['Date']);
if($tijd<$eendag) break;
$period = ($tijdprev - $tijd);
if($status=='On') $totalon = $totalon + $period;
$tijdprev = $tijd;
echo '<tr align="right"><td>'.$data['Date'].'</td><td> '.$status.' </td><td> '.convertToHoursMins($period/60).'</td></tr>';
}
}
}
echo '</table>';
function convertToHoursMins($time, $format = '%01d u %02d min') {if ($time < 1) return;$hours = floor($time / 60);$minutes = ($time % 60);return sprintf($format, $hours, $minutes);}
It grabs the history of idx 131 (my gas burner) and loops thru the result to calculate the total hours on in the last day.
Re: Time of use per day in statics
Posted: Saturday 03 September 2016 11:27
by ayasystems
Thanks for your script
But your script is to generate a table out of domoticz web interface.
Add these feature into domoticz will be fantastic!
Re: Time of use per day in statics
Posted: Saturday 03 September 2016 11:40
by Egregius
That's true, the best way to have things exactly as you want it.
Re: Time of use per day in statics
Posted: Saturday 03 September 2016 11:53
by ayasystems
Where must be put your code??
Regards
Re: Time of use per day in statics
Posted: Saturday 03 September 2016 12:06
by Egregius
It's PHP code so you need a php enabled web server like Apache2 or nginx.