To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/01744842-4777-42a2-8266-9f8b852272cc%40googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/2cc2b17d-8c80-4dde-9771-54eb82387546%40googlegroups.com.
The Change node is one of the core nodes already in your palette. If you provide an example of what your Function is doing we can advise how best to do it with other core nodes.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/a7b30bfb-1a62-4136-9103-65a9b94b7b05%40googlegroups.com.
jsonPayload = msg.payload;
timestampInDate = jsonPayload["timestamp"];
splitted = timestampInDate.split(".");ts = splitted[0];ms = splitted[1];
parsed = Date.parse(ts)/1000;millisecondsValue = parsed + Number(ms);
familiarSensorName = "Acceleration Sensor x-y-z"commercialSensorName = "ACC_SensorXYZ"graphID = millisecondsValue.toString()+commercialSensorName+"-"+"LC"
x_comp = jsonPayload["LC-acc-x"];y_comp = jsonPayload["LC-acc-y"];z_comp = jsonPayload["LC-acc-z"];
send_to_Kafka = '{"@context":{"generatedAt":{"@id":"http://www.w3.org/ns/prov#generatedAtTime","@type":"http://www.w3.org/2001/XMLSchema#date"},"Sensor":"http://purl.oclc.org/NET/ssnx/ssn#Sensor","SensorName":"http://purl.oclc.org/NET/ssnx/ssn#SensingDevice","ObservedParam":"http://purl.oclc.org/NET/ssnx/ssn#MeasurementProperty","Observes":"http://purl.oclc.org/NET/ssnx/ssn#observes","hasPosition":"http://www.loa-cnr.it/ontologies/DUL.owl#hasLocation","hasValue":"http://purl.oclc.org/NET/ssnx/ssn#hasValue"},"@id":"'+graphID+'","generatedAt":"'+timestampInDate+'","@graph":[{"@id":"http://www.sensor-market-example/sensor/'+commercialSensorName+'","@type":"Sensor","SensorName":"'+familiarSensorName+'","Observes":"'+sensing+'"}, {"@id":"'+sensing+'","@type":"ObservedParam","hasValue":"'+x_comp+'#'+y_comp+'#'+z_comp+'"},{"@id":"http://www.sensor-market-example/sensor/'+commercialSensorName+'","@type":"Sensor","SensorName":"'+familiarSensorName+'","hasPosition":"'+location+'"}]}';
var out = { _msgid:"code", payload:send_to_Kafka};return out;
persistence false
connections_messages true
max_inflight_messages 0
max_queued_messages 0
max_connections -1
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/5c872e15-80c6-46c0-ab51-67b004671647%40googlegroups.com.