Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
Hi,
I want to discuss something, lets say I have a sensor that sends me readings and also the time stamp of this readings, this timestamp is not the same as the timestamp of the machine that runs thingworx and the database, so i want thingworx to use this timestamp that came with the sensor data to store it in the database as the timestamp of the readings, so that when i try to query these readings and say i want it from timestamp 1 to timestamp 2 they will be stored in the database with timestamp 1 & 2 that has been set using a timestamp originally from the sensor data not the machine or server timestamp,
when looked into it i found that i have to use this function in my subscribers and cancel the need to the log checkbox in the properties UI .
// Log multiple properties in a single ValueStream entry
Things["ValueStreamThingName"].AddStreamEntry({
source: me.name,
tags: undefined,
timestamp: timestamp,
values: {
Temperature: me.Temperature,
Humidity: me.Humidity,
Pressure: me.Pressure
}
});
Am I correct ? or there is a better or more generic way to do it, like put the function as something general for anything to use so that it can log its own data
thank you,
update 1 :
it works only if the property already has the "log" option checked ,
ok it seems like this code is not right or maybe old one , I am using this one now but i get an error
let timestamp = new Date("2024-12-28T07:30:00");
Things["WaterQuality.VS"].AddIntegerValueStreamEntry({
propertyName: me.name /* STRING */,
value: me.flag3 /* INTEGER */,
timestamp: timestamp /* DATETIME */,
quality: undefined /* STRING {"defaultValue":"GOOD"} */
});
Log Messages
Error in: test.Eastern.Dammam2.WaterQuality.1.manual_log javascript service. Message ::No value stream found for effective value stream name for Thing [WaterQuality.VS].
so, I have a thing shape that has the above script above as a subscription, I have a thing template that has the same thing shape in it and also the value stream thing , and finally i have a sensor thing that has this thing template , in the same thing there are other properties that has the log checkbox marked and works fine so i believe the value stream is working and connected and everything, i can check the data in the database and the other proprties are fine but the one i try to log with the code is not logged
so, any help