Closed alexdewar closed 7 months ago
Yeah, in my PR I change the time to query from time.time()
to time.time() - DECADES_POLL_INTERVAL
.
It actually queries data in the time interval frm=epoch_time&to=epoch_time
, where epoch_time=time.time()
on main
vs epoch_time=time.time()-DECADES_POLL_INTERVAL
on my branch.
In both cases, the "frm" and "to" times are the same, so only one value should be returned, but if DECADES's update time is out of sync with our poll interval, there is no new data since the "frm" time, so nothing is returned. If we always check since the latest poll time, we should always have new data to obtain.
Maybe we should actually be doing something like
start_time = time.time() - DECADES_POLL_INTERVAL
end_time = time.time()
and querying frm=start_time&to=end_time
, and making sure to just select the last data point, in case multiple values are available from that interval.
In an ideal world, DECADES would have an interface to return the most recent values. Maybe something to request for DECADES v2.
Incidentally, time.time()
should be replaced by hardware.plugins.time.get_time()
. I'll do it in #535.
I tried running the code for reading sensor values from DECADES that's in
main
and found that it tended to fall over at random. I printed the raw JSON to see what was happening:It seems that the server sometimes sends empty arrays for values, which triggers an error condition in
get_decades_data
. I'm not sure what the expected behaviour is for DECADES (I see one of the Daves sent through a manual, but I haven't read it). Whatever it is supposed to do though, in practice it does seem to send empty arrays semi-regularly so we need to handle this somehow (e.g. by retrying). Any thoughts @jamesturner246?I've tried @dc2917 's draft PR (#527), which seems to change the DECADES core code among other things. I dunno whether that was done in order to fix this issue or if it's just a happy accident. (It might be that the problem is still there though -- I didn't run that code for long.)