Time of use per day in statics

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.

Moderators: leecollings, remb0

Post Reply
ayasystems
Posts: 66
Joined: Tuesday 19 April 2016 23:37
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Time of use per day in statics

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

Re: Time of use per day in statics

Post 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>&nbsp;'.$status.'&nbsp;</td><td>&nbsp;'.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.
ayasystems
Posts: 66
Joined: Tuesday 19 April 2016 23:37
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Time of use per day in statics

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

Re: Time of use per day in statics

Post by Egregius »

That's true, the best way to have things exactly as you want it.
ayasystems
Posts: 66
Joined: Tuesday 19 April 2016 23:37
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Time of use per day in statics

Post by ayasystems »

Where must be put your code??

Regards
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Time of use per day in statics

Post by Egregius »

It's PHP code so you need a php enabled web server like Apache2 or nginx.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest