I'm trying to get some data into SiteWise through IoT Core and I keep getting this result from the rule:
"details": "No requests were sent. PutAssetPropertyValueEntries was empty after performing substitution templates. Message arrived on: , Action: iotSiteWise"
I think the reason is because of this:
Note
Because an expression in a substitution template is evaluated separately from the SELECT statement, you can't use a substitution template to reference an alias created using an AS clause. You can reference only information present in the original payload, in addition to supported functions and operators.
I am ATTEMPTING to do this as the source:
SELECT fields.rms0, fields.rms1, fields.rms2, time_to_epoch(timestamp, "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")/1000 as ts
but I see from the document that won't work. In the rule, I tried it another way: in the timeStamp mapping (in the UI) I tried to set the time to:
${time_to_epoch(timestamp, "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")/1000}
but that doesn't work, either - it gave me an error saying it didn't understand time_to_epoch.
Next, I tried going back to this:
SELECT *
and in the Rule to write to SiteWise I set all the timestamp fields to:
${floor(time_to_epoch(timestamp, "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") / 1E3)}
following the manual.
"resources": {
"FunctionName": "time_to_epoch"
},
"details": "Undefined result"
"resources": {
"FunctionName": "floor"
},
"details": "Undefined result"
so I am not having much success. Is there any way to make it log what the BatchPutAssetPropertyValue request contains?
Extra thought: is this whole problem because my timestamp column is named 'timestamp' ?
A mechanism I use for rapidly testing rules is to set up an action that forwards modified payloads to another IoT Core topic (the republish action). Then I can test complicated use of functions in the rule query to see the output using the IoT Core web console test client. Once I figure out the right rule query syntax, I will move it into the substitution template section of whatever action I'm actually trying to use. You may find this helpful over the trial and error of seeing whether a message successfully makes it into SiteWise.