empierre / MyDomoAtHome

MyDomoAtHome - REST interface for ImperoHome with Domoticz (ISS)
http://domoticz.com/wiki/ImperiHome
GNU General Public License v3.0
31 stars 22 forks source link

Error when trying to get Week device history #172

Open jonferreira opened 5 years ago

jonferreira commented 5 years ago

According to https://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s there's no support for week ranges any more (pretty sure there was before so presumably that was removed recently) so requests will fail with an error.

That said /json.htm?type=graph&sensor=temp&idx=IDX&range=day will return week results (yeah go figure why) so the fix is pretty simple in my opinion, just change to

 if (duration <= 172800) {
        range = "day";
    } else if (duration < 1209600) {
        range = "day";
    } else if (duration < 5270400) {
        range = "month";
    } else {
        range = "year";
    }

for now.