<aside> 💡 THE STARTING POINT:
</aside>
<aside> 💡 The overall logic: each time the inductive sensor reaches a limit value, it sends a message with “1” as payload. By this we can count each part coming through.
</aside>
You start with a MQTT-IN node that runs under the topic of your inductive sensor (as defined in documentation)
After that place a json for the convertation from string to object:
Then we need to extract the payload, as this sensor does store its value under msg.payload.PDV1
msg.timestamp=msg.payload.timestamp_ms
msg.payload=msg.payload.PDV1;
return msg;
Implement the rising edge (it will compare to the msg.payload to a limit value). The value for the threshold has to be defined out of the context in production. In this example it is 500.
After this the payload gets redefined in the “PreventiveMaintenanceStop” function.
msg.payload={
"timestamp_ms": msg.timestamp,
"state": 210000
}
msg.topic = "ia/"customerID"/"location"/"AssetID"/state"
return msg;
The last step is to just send this message out via a MQTT-OUT node.