This flow is used to generate heartbeat messages.

The flow uses the global assetId variable set in the startup flow.
[
{
"id": "e3a39e70.5684e",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": ""
},
{
"id": "1e62113a.c7b30f",
"type": "inject",
"z": "e3a39e70.5684e",
"name": "Interval for Heartbeat",
"topic": "",
"payload": "true",
"payloadType": "bool",
"repeat": "60",
"crontab": "",
"once": true,
"onceDelay": "",
"x": 220,
"y": 120,
"wires": [
[
"28a95094.1eaa2"
]
]
},
{
"id": "28a95094.1eaa2",
"type": "function",
"z": "e3a39e70.5684e",
"name": "Heartbeat Message",
"func": "var message = {};\nvar dataItemId = \"Heartbeat\"\nvar topic = 'Asset/'+ global.get(\"assetId\") + '/' + dataItemId;\nos = context.global.os;\nvar now = new Date();\n\nmessage[\"assetId\"] = global.get(\"assetId\");\nmessage[\"dateTime\"] = now.toISOString();\nmessage[\"dataItemId\"] = dataItemId;\nmessage[\"IPAddress\"] = os.networkInterfaces().wlan0[0].address;\nmessage[\"MACAddress\"] = os.networkInterfaces().wlan0[0].mac;\n\nreturn [{\"topic\": topic, \"payload\": JSON.stringify(message)}]",
"outputs": 1,
"noerr": 0,
"x": 530,
"y": 120,
"wires": [
[
"6e5162b1.c61f7c"
]
]
},
{
"id": "6e5162b1.c61f7c",
"type": "mqtt out",
"z": "e3a39e70.5684e",
"name": "mb.iotfm.org",
"topic": "",
"qos": "0",
"retain": "",
"broker": "7f68d892.c7edd8",
"x": 810,
"y": 120,
"wires": []
},
{
"id": "7f68d892.c7edd8",
"type": "mqtt-broker",
"z": "",
"name": "mb.iotfm.org",
"broker": "mb.iotfm.org",
"port": "1883",
"clientid": "A1000",
"usetls": false,
"compatmode": true,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]