Query API sometimes returns null values in data

I’m using the query API function in a Hubitat driver. The query I was using is below:


The driver was making queries every 30 seconds. I occasionally would see all null values in the response like this:

[range:[1591027160, 1591027165], labels:[L1_Vrms, L1_Main, L2_Main, GarageOT_2, Dryer_5_7, AC_Cond_6_8, Oven_10_12, AirHandler_15, Washer_20, Dishwasher_23, PcRm_KitLT_24, KitIsCntrOT_25, Mcrwv_Rng_33, Fridge_36, MBdrmLT_OT_40, I_L1, I_L2, L1_Misc, L2_Misc], data:[[null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null]]]

It wouldn’t happen very often, maybe once an hour or so. Since I was asking for the most recent 5 seconds of data, it would appear that if the query was made at just the right time, the requested data wouldn’t be available. I put the query in my browser, just to make sure it wasn’t something to do with the Hubitat driver, and I still got the null responses occasionally.

When I asked for the previous 5 seconds of data by changing the last part of my query to the following:


I never got any null values. That works fine for me. Just thought I’d document this behavior in case someone else is also seeing it. I’ve been using my IoTaWatt for over a year now and it works great!

Hi @bdh79,

I’ll look into that. It probably has to do with the query beating out the posting to the datalog.

If you have the opportunity to use grafana with influxDB, you will see that there is a parameter to delay the query - essentially what you are doing with your solution, so it’s not a unique problem when dealing with pulling real-time data.

Without getting into a lot of the technical details, I think the ESP32 version that I am working on will not have this problem.

Thanks for documenting this.