Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

Updating a data point value at a specific timestamp


  • Good Morning!

    I was hoping to get a little help with something I am currently struggling with. Is it possible to limit data points to one value per timestamp? For example, say I had a data point, "Electricity Consumed", and it had a point value of 1500 for the time stamp, 1595822400000. If I add a new point value for the exact same timestamp, I want the new value to be logged and the previous value to be deleted. Essentially updating the value at a specific timestamp. At the moment, whenever I add a new point value for the same timestamp I add the new value but the previous value also remains in the system.

    Thanks,
    Gord


  • To add further context. I am using the "When Point Timestamp Changes" logging property. When I add a new point with the same timestamp it still logs to the database (checked this using the sql console).


  • Hi Gord

    How are you adding the new value, in the scripting environment?


  • Hi Craig,

    I think I need to clarify my issue a little further. I am hoping to be able to upload data as either a csv file with many values/timestamps or a single value/value and have it update in the database only if the value at that timestamp has changed. I've tried both the "When Point Timestamp Changes" and "When Point Value Changes" logging properties with no luck.

    With regards to the methods I am adding the value:
    I'm currently using a couple of methods to get data in via a "Data File" datasource but all return the same issue of duplicate data for a specific timestamp. The first method is by placing a csv in the filestore and having the data source configured to look for any csv files in the filestore directory. What happens here is the first csv file is uploaded, then if I place the same file back in the folder all the values are logged to the database again despite the time stamps being identical. What I am expecting is none of the values to be logged because the timestamp hasn't changed. Ideally, if I were to adjust one of those values and reuploaded the file with the single adjustment, only the adjustment would be logged. The second method is setting a single value via the /point-values end point in the API. When I hardcode an identical time stamp to an existing one it is logged to the database and the previous value remains. I have a solution in mind for setting a single value which would involve an sql update via the sql-console update/query end points but that feels like a bit of a hack. I'm sure I'm misunderstanding how the logging is supposed to work so any help pointing me in the right direction would be greatly appreciated.

    Thanks,

    Gord


  • Hi Gord

    The logging configuration will compare the value it just polled to the previous value in the cache. It will not do a historical search of the point to decide whether to log or not. You will probably need to code that logic into your data file runtime.


  • @Gord-Bond If I’m understanding this correctly the only way to overwrite data at a time stamp is to use the Mango NoSQL database module. It only allows one value for a data point at a specific time stamp. If you are using the default H2 or MySQL tables to store the values you will get duplicates.


  • Ah ok, thank you guys. This helps quite a bit. I am currently using the free license at the moment to investigate whether or not Mango is the right for our project. So far it seems really great and I'm glad there is a solution for my duplicates problem. I appreciate all the help here in the forums.