gchenuet / nest-datagraph

Nest thermostat dashboard and graph charts
MIT License
36 stars 17 forks source link

Heating time showing wrong data #26

Closed shaman79 closed 3 years ago

shaman79 commented 6 years ago

Heating time chart seems to be showing wrong data or Y label should not be in hours. There is no way I could be heating 80 hours per day. The same issue seems to be with Away chart.

gchenuet commented 6 years ago

Hi @shaman79,

I'll check this issue and keep you in touch. Thanks,

Guillaume

shaman79 commented 6 years ago

Hi @gchenuet, can it be that the problem is caused by different sampling period? I am polling every 5 minutes, not every hour as suggested in install procedure. Thanks.

fusenuk commented 6 years ago

This is due to the 24 hour polling period being assumed in the PHP files such as getHeat.php and getPresence.php

Example line of code is

$sql_array["rows"][] = array("c" => array(array("v" => $date_array), array("v" => intval($row["auto_away"])), array("v" => (24 - $row["auto_away"]))));

which if you are polling every 5 minutes like myself and @shaman79 shaman79 are then you need to divide $row["auto_away"] by 12 so it turns into

$sql_array["rows"][] = array("c" => array(array("v" => $date_array), array("v" => round($row["auto_away"] / 12, 2)), array("v" => (24 - round($row["nest_heat_state"] / 12, 2)))));

A proper way would be to have the polling period set in the config file and then do a calculation for how many polling intervals go into 24 hours then divide the value by that calculated number.

gchenuet commented 5 years ago

I haven't time (and Nest Thermostat) to maintain this project. Feel free to open a PR to fix it :)

Thanks.