Wrong values returned by REST API? - explained

I couldn’t access the log, and the unit came back online only after I power cycled it.

Of course there are ways to do differently to achieve the same results; I could use explicit dates, starting from the last known successful requests.

I still think it would be much better/elegant of the iotawatt had an option for queries so that there’s no calculation to run on the receiver side :slight_smile:

You did give me another idea though :slight_smile:

02_05_11.
I actually thought it had disconnected because it was doing a firmware upgrade.

A firmware upgrade usually takes about 20 seconds.

There is no auto-update class that is currently set to 02_05_11. What is your auto-update setting? (setup->device)

Was set to none. I’ve changed it to major

Is there a way to retrieve the time used for the end of the interval queried?
time.iso as described in the documentation “Returns the time of the beginning of the reporting group.”

I would like to exactly queried from where we last stop so I don’t have to worry about inaccurate timers or time differences between the iotawatt time and whomever is querying it (the iotawatt only supports UTC and local time in its ISO 8601 support)
And for this I need the end of the reporting group.

thank you

Yes. If you specify json output, there is a json array called range:
image

These are the begin and end in UNIXtime.

You may also be able to structure your query so that the end time is always implied. For instance, if you specify begin=d&end=m the query will end on the even minute after the last datapoint.

great thank you.

I ended up setting the ISO time in UTC timezone (as I can’t guarantee the TZ one the machine performing the query is the same as the iotawatt).

Something you may want to look into, I’ve managed to make my iota completely unresponsive and requiring a reboot performing some queries.

http://192.168.10.3/query?select=[time.iso,Total_Solar.d5,Total_Solar.wh.d9]&begin=2021-08-29T10:07:00Z&end=2021-08-29T10:07:30Z&group=all

So I was playing with that url, and I changed the various precision value on both end between 3 and 9 and from time to time, in my haste I would cause the URL to be incorrect, typically because I incorrectly deleted the , before Total_Solar
like so:
http://192.168.10.3/query?select=[time.iso,Total_Solar.d5Total_Solar.wh.d9]&begin=2021-08-29T10:07:00Z&end=2021-08-29T10:07:30Z&group=all

I continued writing rubbish URL by specifying .d without a number behind etc.

When I pressed enter I didn’t get an error, the iotawatt no longer responded.
I managed to reproduce it twice in under 5 minutes. A 3rd time it stopped responding to ping but came back only about 1 minute later.

Now it is possible that it just happened that the wifi went down twice exactly at those time, but seeing it’s been rock solid all day it would be a weird coincidence.

This is the log after the first occurence:

** Restart **

SD initialized.
8/26/21 23:34:17z Real Time Clock is running. Unix time 1630020857 
8/26/21 23:34:17z Power failure detected.
8/26/21 23:34:17z Reset reason: Power on
8/26/21 23:34:17z ESP8266 ChipID: 6308362
8/26/21 23:34:17z IoTaWatt 5.0, Firmware version 02_05_11
8/26/21 23:34:17z SPIFFS mounted.
8/27/21 09:34:17 Local time zone: +10:00
8/27/21 09:34:17 Using Daylight Saving Time (BST) when in effect.
8/27/21 09:34:17 device name: IotaWatt
8/27/21 09:34:20 Connecting with WiFiManager.
8/27/21 09:37:20 Did not connect after power-fail. Restarting to reset WiFi.

** Restart **

SD initialized.
8/26/21 23:37:22z Real Time Clock is running. Unix time 1630021042 
8/26/21 23:37:22z Reset reason: Software/System restart
8/26/21 23:37:22z Trace:  0:0, 0:0, 0:0, 0:0, 0:0, 0:0, 0:0, 0:0, 0:0, 0:0, 0:0, 0:0, 0:0, 0:0, 0:0, 0:0, 0:0, 0:0, 0:0, 11:0, 11:4, 11:5, 11:5, 11:6, 11:7, 11:8, 11:9, 16:0, 11:10, 11:11, 11:12, 11:12
8/26/21 23:37:22z ESP8266 ChipID: 6308362
8/26/21 23:37:22z IoTaWatt 5.0, Firmware version 02_05_11
8/26/21 23:37:22z SPIFFS mounted.
8/27/21 09:37:22 Local time zone: +10:00
8/27/21 09:37:22 Using Daylight Saving Time (BST) when in effect.
8/27/21 09:37:22 device name: IotaWatt
8/27/21 09:37:22 HTTP server started
8/27/21 09:37:22 timeSync: service started.
8/27/21 09:37:22 statService: started.
8/27/21 09:37:23 dataLog: service started.
8/27/21 09:37:26 dataLog: Last log entry 08/27/21 09:34:00
8/27/21 09:37:34 WiFi connected. SSID=HOME-WLAN, IP=192.168.10.3, channel=11, RSSI -59db
8/27/21 09:37:34 MDNS responder started for hostname IotaWatt
8/27/21 09:37:34 LLMNR responder started for hostname IotaWatt
8/27/21 09:37:34 Updater: service started. Auto-update class is NONE
8/27/21 09:38:22 historyLog: service started.
8/27/21 09:38:23 historyLog: Last log entry 08/27/21 09:34:00
8/28/21 16:11:53 Updater: Auto-update class changed to MINOR
8/28/21 16:11:58 Updater: Update from 02_05_11 to 02_06_05
8/28/21 16:11:58 Updater: download 02_06_05
8/28/21 16:12:04 Updater: Download failed HTTPcode -11
8/28/21 16:23:03 Restart command received.

** Restart **

SD initialized.
8/28/21 06:23:05z Real Time Clock is running. Unix time 1630131785 
8/28/21 06:23:05z Reset reason: Software/System restart
8/28/21 06:23:05z Trace:  1:4, 1:1[10], 1:2[11], 9:0[11], 9:0, 9:1, 8:4, 8:6, 8:8, 8:9, 9:3, 9:5, 9:9, 1:2, 1:3, 1:4, 1:1[11], 1:2[12], 9:0[12], 9:0, 9:1, 8:4, 8:6, 8:8, 8:9, 9:3, 9:5, 9:9, 1:2, 1:3, 10:2, 10:3
8/28/21 06:23:05z ESP8266 ChipID: 6308362
8/28/21 06:23:05z IoTaWatt 5.0, Firmware version 02_05_11
8/28/21 06:23:05z SPIFFS mounted.
8/28/21 16:23:05 Local time zone: +10:00
8/28/21 16:23:05 Using Daylight Saving Time (BST) when in effect.
8/28/21 16:23:05 device name: IotaWatt
8/28/21 16:23:05 HTTP server started
8/28/21 16:23:05 timeSync: service started.
8/28/21 16:23:05 statService: started.
8/28/21 16:23:06 dataLog: service started.
8/28/21 16:23:10 dataLog: Last log entry 08/28/21 16:23:00
8/28/21 16:24:06 historyLog: service started.
8/28/21 16:24:07 historyLog: Last log entry 08/28/21 16:23:00
8/28/21 16:27:40 WiFi connected. SSID=HOME-WLAN, IP=192.168.10.3, channel=8, RSSI -55db
8/28/21 16:27:40 MDNS responder started for hostname IotaWatt
8/28/21 16:27:40 LLMNR responder started for hostname IotaWatt
8/28/21 16:27:40 Updater: service started. Auto-update class is MINOR
8/28/21 16:27:41 Updater: Update from 02_05_11 to 02_06_05
8/28/21 16:27:41 Updater: download 02_06_05
8/28/21 16:27:46 Updater: Release downloaded 5616ms, size 834296
8/28/21 16:27:54 Updater: signature verified
8/28/21 16:28:03 Updater: firmware upgraded to version 02_06_05
8/28/21 16:28:03 Updater: Firmware updated, restarting.

** Restart **

SD initialized.
8/28/21 06:28:12z Real Time Clock is running. Unix time 1630132092 
8/28/21 06:28:12z Reset reason: Software/System restart
8/28/21 06:28:12z Trace:  9:0, 9:1, 8:4, 8:6, 8:8, 8:9, 9:3, 9:5, 9:9, 1:2, 1:3, 1:4, 1:5[19], 1:6, 1:1[12], 1:2[13], 9:0[13], 9:0, 9:1, 8:4, 8:6, 8:8, 8:9, 9:3, 9:5, 9:9, 1:2, 1:3, 1:4, 1:5[5], 5:0, 5:7
8/28/21 06:28:12z ESP8266 ChipID: 6308362
8/28/21 06:28:12z IoTaWatt 5.0, Firmware version 02_06_05
8/28/21 06:28:12z Updater: Installing update files for version 02_06_05
8/28/21 06:28:12z Updater: Installing GRAPH.HTM
8/28/21 06:28:12z Updater: Installing GRAPH.JS
8/28/21 06:28:12z Updater: Installing GRAPH2.HTM
8/28/21 06:28:12z Updater: Installing GRAPH2.JS
8/28/21 06:28:13z Updater: Installing INDEX.HTM
8/28/21 06:28:13z Updater: Installing TABLES.TXT
8/28/21 06:28:13z Updater: Installing CNFSTYLE.CSS
8/28/21 06:28:13z Updater: Installing EDIT.HTM
8/28/21 06:28:13z Updater: Installation complete.
8/28/21 06:28:13z SPIFFS mounted.
8/28/21 16:28:14 Local time zone: +10:00
8/28/21 16:28:14 Using Daylight Saving Time (BST) when in effect.
8/28/21 16:28:14 device name: IotaWatt
8/28/21 16:28:14 HTTP server started
8/28/21 16:28:14 timeSync: service started.
8/28/21 16:28:14 statService: started.
8/28/21 16:28:14 dataLog: service started.
8/28/21 16:28:16 dataLog: Last log entry 08/28/21 16:27:45
8/28/21 16:28:19 historyLog: service started.
8/28/21 16:28:19 historyLog: Last log entry 08/28/21 16:27:00
8/28/21 16:28:19 WiFi connected. SSID=HOME-WLAN, IP=192.168.10.3, channel=8, RSSI -53db
8/28/21 16:28:19 MDNS responder started for hostname IotaWatt
8/28/21 16:28:19 LLMNR responder started for hostname IotaWatt
8/28/21 16:28:19 Updater: service started. Auto-update class is MINOR
8/28/21 16:28:20 Updater: Auto-update is current for class MINOR.
8/28/21 22:29:12 Updater: Invalid response from server. HTTPcode: -11
8/29/21 03:29:51 Updater: Invalid response from server. HTTPcode: -4

** Restart **

SD initialized.
8/29/21 02:45:01z Real Time Clock is running. Unix time 1630205101 
8/29/21 02:45:01z Power failure detected.
8/29/21 02:45:01z Reset reason: Power On
8/29/21 02:45:01z ESP8266 ChipID: 6308362
8/29/21 02:45:01z IoTaWatt 5.0, Firmware version 02_06_05
8/29/21 02:45:01z SPIFFS mounted.
8/29/21 12:45:01 Local time zone: +10:00
8/29/21 12:45:01 Using Daylight Saving Time (BST) when in effect.
8/29/21 12:45:01 device name: IotaWatt
8/29/21 12:45:04 Connecting with WiFiManager.
8/29/21 12:48:04 Did not connect after power-fail. Restarting to reset WiFi.

** Restart **

SD initialized.
8/29/21 02:48:05z Real Time Clock is running. Unix time 1630205285 
8/29/21 02:48:05z Reset reason: Software/System restart
8/29/21 02:48:05z Trace:  0:0, 0:0, 11:0, 11:4, 11:5, 11:5, 11:10, 11:15, 11:20, 11:20[1], 11:20[2], 11:20[3], 11:21, 11:22, 11:21, 11:22, 11:21, 11:22, 11:21, 11:22, 11:20[4], 11:20[5], 11:20[6], 11:20[7], 11:25, 11:30, 11:31, 11:30, 11:35, 11:40, 11:45, 11:70
8/29/21 02:48:05z ESP8266 ChipID: 6308362
8/29/21 02:48:05z IoTaWatt 5.0, Firmware version 02_06_05
8/29/21 02:48:05z SPIFFS mounted.
8/29/21 12:48:05 Local time zone: +10:00
8/29/21 12:48:05 Using Daylight Saving Time (BST) when in effect.
8/29/21 12:48:05 device name: IotaWatt
8/29/21 12:48:05 HTTP server started
8/29/21 12:48:05 timeSync: service started.
8/29/21 12:48:05 statService: started.
8/29/21 12:48:05 dataLog: service started.
8/29/21 12:48:07 dataLog: Last log entry 08/29/21 12:44:40
8/29/21 12:48:10 historyLog: service started.
8/29/21 12:48:10 historyLog: Last log entry 08/29/21 12:44:00
8/29/21 12:52:16 WiFi connected. SSID=HOME-WLAN, IP=169.254.11.66, channel=8, RSSI -48db
8/29/21 12:52:16 MDNS responder started for hostname IotaWatt
8/29/21 12:52:16 LLMNR responder started for hostname IotaWatt
8/29/21 12:52:16 Updater: service started. Auto-update class is MINOR
8/29/21 12:58:00 WiFi disconnected.
8/29/21 12:58:38 WiFi connected. SSID=HOME-WLAN, IP=192.168.10.3, channel=7, RSSI -51db
8/29/21 12:58:39 Updater: Auto-update is current for class MINOR.
8/29/21 13:58:56 Updater: Invalid response from server. HTTPcode: -11

** Restart **

SD initialized.
8/29/21 09:44:47z Real Time Clock is running. Unix time 1630230287 
8/29/21 09:44:47z Power failure detected.
8/29/21 09:44:47z Reset reason: Power On
8/29/21 09:44:47z ESP8266 ChipID: 6308362
8/29/21 09:44:47z IoTaWatt 5.0, Firmware version 02_06_05
8/29/21 09:44:47z SPIFFS mounted.
8/29/21 19:44:47 Local time zone: +10:00
8/29/21 19:44:47 Using Daylight Saving Time (BST) when in effect.
8/29/21 19:44:47 device name: IotaWatt
8/29/21 19:44:50 Connecting with WiFiManager.
8/29/21 19:47:50 Did not connect after power-fail. Restarting to reset WiFi.

** Restart **

SD initialized.
8/29/21 09:47:51z Real Time Clock is running. Unix time 1630230471 
8/29/21 09:47:51z Reset reason: Software/System restart
8/29/21 09:47:51z Trace:  0:0, 0:0, 11:0, 11:4, 11:5, 11:5, 11:10, 11:15, 11:20, 11:20[1], 11:20[2], 11:20[3], 11:21, 11:22, 11:21, 11:22, 11:21, 11:22, 11:21, 11:22, 11:20[4], 11:20[5], 11:20[6], 11:20[7], 11:25, 11:30, 11:31, 11:30, 11:35, 11:40, 11:45, 11:70
8/29/21 09:47:51z ESP8266 ChipID: 6308362
8/29/21 09:47:51z IoTaWatt 5.0, Firmware version 02_06_05
8/29/21 09:47:51z SPIFFS mounted.
8/29/21 19:47:51 Local time zone: +10:00
8/29/21 19:47:51 Using Daylight Saving Time (BST) when in effect.
8/29/21 19:47:51 device name: IotaWatt
8/29/21 19:47:51 HTTP server started
8/29/21 19:47:51 timeSync: service started.
8/29/21 19:47:51 statService: started.
8/29/21 19:47:51 dataLog: service started.
8/29/21 19:47:53 dataLog: Last log entry 08/29/21 19:44:30
8/29/21 19:47:56 historyLog: service started.
8/29/21 19:47:56 historyLog: Last log entry 08/29/21 19:44:00
8/29/21 19:47:56 WiFi connected. SSID=HOME-WLAN, IP=192.168.10.3, channel=10, RSSI -48db
8/29/21 19:47:56 MDNS responder started for hostname IotaWatt
8/29/21 19:47:56 LLMNR responder started for hostname IotaWatt
8/29/21 19:47:56 Updater: service started. Auto-update class is MINOR
8/29/21 19:47:58 Updater: Auto-update is current for class MINOR.

I tried queries with:

  • comma missing between select entries
  • .d with no following integer
  • .d with no following integer and no following comma
  • various integer values for .d from 1 to 10

In all cases where the query was invalid I received an error response. Not saying you did’t have a problem, just that the things you say may have caused it do not seem to be reproduceable.

As an aside, the IoTaWatt ADCs return 4 significant digits, so to request Wh to more than 3 or 4 decimal places is meaningless. Sure we can take some integers and do some double precision divisions on them and get a lot of decimal places in the result. That doesn’t mean those extended decimal digits have any significance.

I use three. When queried for the last wh energy value for the last 30s to add to to the previous tally, I always got 0 as it’s rounded to the nearest digit.
Unlike Wattage which is a decimal number.

If you couldn’t reproduce, then maybe it was just a wifi connection issue.

Something I’ve noticed which is rather frustrating, after power-cycling the iotawatt, I must reboot my router for the iota to connect.

That sounds like a problem I would have many reports on if it were something in the IoTaWatt. Can you reproduce using a different router?