In this example we will not only explain the phase of creating the scene for Payload Parsing, but also the whole preliminary phase, which consists in creating the node with its components.
At the end of the page there will also be some practical examples of currently present node models.
In the new page click on the "Add Custom Node" button and then fill in the fields with your sensor data, fill the sector "Node Fields" with all the tags that will contain the value of the data sent by the sensor (example, "Temperature", "Humidity", etc.) and then save.
Keep in mind, however, that the "Latitude", "Longitude", and "Altitude" tags will be created automatically, so if you need to serve one or more of these tags, you do not need to add them.
Reopen the node and go down until you find the field called "Payload parsing scene mode", click it and select the Manual Lua Scene option, and at this point you should find yourself with a very large field where you can write your code.
Port = resiot_comm_getparam("port") -- To know from which door the message has been sent, write "port"
Step 2: Get the data from the Payload The second step consists in obtaining the data that will then be processed to obtain the desired values.
Step 3: Process the data obtained (if necessary) If the data obtained in step 2 must be further processed, this is done during this step.
Step 4: Save the final values within the Node Tags Last step, at the end of all calculations, the values obtained must be saved inside the node tags.
-- can be found under the "Field Tag" column in the "Node Fields" section of a node.
-- The variable "Value" must be of string type, in case it is not, you can convert it using the internal function of lua "tostring ()".
-- the only difference is that with this one you can decide at what time save the value.
-- The Variable "Date" is the date in Epoch format, that is, the date expressed in seconds.
-- and then subtract the time of difference to the date you want to save the value in.
ReportTypeStr = "Periodic mode report"
ReportTypeStr = "Motion mode static report"
ReportTypeStr = "Motion mode moving report"
ReportTypeStr = "Motion mode static to motion report"
ReportTypeStr = "Motion mode moving to static report"
ReportTypeStr = "SOS alarm report"
ReportTypeStr = "Low battery alarm report"
ReportTypeStr = "Power off(low battery)"