How to get string timestamp from IoT Core into SitWise

0

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.

profile picture
wz2b
질문됨 2년 전458회 조회
1개 답변
0
수락된 답변

I simulated by publishing this message to IoT:

{
  "rms0": 1.4,
  "rms1": 2.2,
  "timestamp": "2022-03-10T08:26:00.500Z"
}

With the Rule havingSELECT * and the following for Time in seconds:

${floor(time_to_epoch(timestamp, "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") / 1E3)}

And the data landed in Sitewise with a timestamp of March 10, 2022, 16:26:00 (UTC+8:00).

I hope this helps.

profile pictureAWS
전문가
Greg_B
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인