last_entry_id

1 visualizzazione (ultimi 30 giorni)
Jaye Hicks
Jaye Hicks il 12 Ott 2020
Commentato: Craig Larson il 19 Dic 2021
ThingSpeak auto assigns an unique identifier to each new inbound record for a given channel. Within the record the identifier is named 'last_entry_id.' Each auto assigned id is auto increment by one over the previous id. What is the largest numeric value that last_entry_id will reach? If there is an upper bound, what will happen when it is reached? Will a roll over occur such that last_entry_id is reset to 0 or 1?
Thanks in advance for the information.
  1 Commento
Craig Larson
Craig Larson il 19 Dic 2021
@Jay Hicks: May I ask how you obtain the 'last_entry_id' in your code? I have a need for this data element also. My sensor is writing data and estimated time to Thingspeak in a bulk-uploading of 20 data records inorder to save on battery life of the ESP8266 transmitter. Sometimes there are timestamp overlaps, and sometimes there are gaps due to the estimated time. When there are overlaps the data is no longer in order of the 'entry_id'. I can see the 'entry_id' values in worksheets exported from Thingspeak. But I'm trying to use Matlab code to sort this out from inside Thingspeak using a custom App only I don't know how to access 'entry_id'. Thanks in advance.

Accedi per commentare.

Risposte (2)

Christopher Stapels
Christopher Stapels il 14 Ott 2020
Can you describe why you need the last_entry_id?
It is not recommended to be used for the reasons you mention (rollover, finite upper bound.)
  1 Commento
Jaye Hicks
Jaye Hicks il 14 Ott 2020
I have developed custom code to process incoming sensor data. The data is pulled by my code from a thingspeak endpoint. In my design I thought to leverage last_entry_id in three different ways.
First, I read a block of data going back in time slightly further than I need to and then cycle through the data, starting with the oldest, ignoring records until the incoming last_entry_id is larger than the largest last_entry_id that I stored off, in a database, from the last time that I pulled a block of sensor data. Are you suggesting that this is not advised or is some how not viable?
The second and the third ways that my design uses last_entry_id involves detecting gaps. I raise warning / error log messages if I detect a numeric gap either across data pulls or within a block of data from a single pull. Specifically, as I process a new block of pulled sensor data does the first last_entry_id begin at a value that is one more than the value that I stored off (from the previous data pull)? And during the processing of individual records within a single data pull, are there any numbers skipped in the 'increment by one' progression of last_entry_id? Are you suggesting that this is not advised or is some how not viable?

Accedi per commentare.


Christopher Stapels
Christopher Stapels il 21 Ott 2020
I suggest that this is not the most viable method. There could be unexpected ways that last_entry_id does not always behave as you would like. I would reccomend that you use timestamp comparisons to detect missing data and to cycle through the recently read data. They may be slightly harder to write, but I think they will be more robust. In MATLAB, you can convert timestamps into numeric representations for fast comparison. You can use datenum() on a timestamp to get a number of days since a set time, or compare datetimes to get durations.

Community

Più risposte nel  ThingSpeak Community

Categorie

Scopri di più su ThingSpeak in Help Center e File Exchange

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by