otaviojr / node-red-contrib-smartthings

Allows you to control your devices and get their status using NodeRed
MIT License
32 stars 16 forks source link

Timestamp in payload #76

Open sdalu opened 2 years ago

sdalu commented 2 years ago

Returned data in the payload doesn't contains the timestamp of the measurement, which information by looking at the raw data (of the status node) seems to be available.

It would be useful to have it available in standard node, so data can be collected and stored in a database with the timestamp of the measurement instead of the timestamp of the database insertion time.

I guess new payload would looks like:

{
  "topic": "update",
  "payload": {
    "deviceId": "85272aa2-78db-4e80-8585-849469710190",
    "deviceType": "contact",
    "name": "Door watcher",
    "timestamp": "2022-06-08T22:42:02.606Z",
    "value": 0
  },
  "_msgid": "e6809b7c800f5a87"
}
sdalu commented 2 years ago

@otaviojr I see that you have started to add some timestamp. But it seems you are generating it using new Date().toISOString(). As a timestamp appear in the status node (as for example: status.components.main.contactSensor.contact.timestamp) I thought it was provided by the smartthing callback. That's the one provided by smartthing that would be useful. If none are provided by smartthings, I'm sorry to have open this issue.

otaviojr commented 2 years ago

Yep, for now, my problem is that only the status appears to have the timestamp. The event Smartthings send to us via webhook doesn't. I will get a better look into it.

Regards