setup consists of a MQTT broker running in a PC.
Node red runs in a Raspberry PI.
i would like to generate fake values every 5 secs repeatedly of WATTS in the range 1-5 with 2 decimal points. Then send those values to MQTT broker to a certain topic in the MQTT of the PC. eg topic /bedroom/lights/master
i have created a sample to check how it will look in debug, with a chart, a gauge and a debug every 5 secs. It seems that it outputs the values, but with 1 decimal point, not 2.
Also how do i send this information to my MQTT broker (192.168.178.251/24), to the topic /bedroom/lights/master ?
Here is my
and the json.
[
{
"id": "02971057881eb4a0",
"type": "tab",
"label": "Flow 2",
"disabled": false,
"info": "",
"env": []
},
{
"id": "7b3ceefc5f6f4dc1",
"type": "inject",
"z": "02971057881eb4a0",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "5",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 130,
"y": 100,
"wires": [
[
"42f9d6d97e491ddd"
]
]
},
{
"id": "42f9d6d97e491ddd",
"type": "function",
"z": "02971057881eb4a0",
"name": "Random_generator",
"func": "msg.payload = Math.round(Math.random()*10);\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 350,
"y": 140,
"wires": [
[
"eafdc1be9aaec763",
"1a5206170bab8791",
"eeda97170d857a95",
"94d95500410527dd",
"3ae60c20ad27b74a"
]
]
},
{
"id": "eafdc1be9aaec763",
"type": "debug",
"z": "02971057881eb4a0",
"name": "debug 1",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 580,
"y": 80,
"wires": []
},
{
"id": "d226331329827763",
"type": "comment",
"z": "02971057881eb4a0",
"name": "Random_generate_every_5s_a_number_0_5",
"info": "",
"x": 350,
"y": 20,
"wires": []
},
{
"id": "1a5206170bab8791",
"type": "ui_text",
"z": "02971057881eb4a0",
"group": "ef108d3cefe2d6ee",
"order": 0,
"width": 0,
"height": 0,
"name": "",
"label": "text",
"format": "{{msg.payload}}",
"layout": "row-spread",
"className": "",
"style": false,
"font": "",
"fontSize": 16,
"color": "#000000",
"x": 590,
"y": 180,
"wires": []
},
{
"id": "eeda97170d857a95",
"type": "ui_gauge",
"z": "02971057881eb4a0",
"name": "",
"group": "ef108d3cefe2d6ee",
"order": 1,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "gauge",
"label": "units",
"format": "{{value}}",
"min": 0,
"max": "5",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"diff": false,
"className": "",
"x": 590,
"y": 240,
"wires": []
},
{
"id": "94d95500410527dd",
"type": "ui_slider",
"z": "02971057881eb4a0",
"name": "",
"label": "slider",
"tooltip": "",
"group": "ef108d3cefe2d6ee",
"order": 2,
"width": 0,
"height": 0,
"passthru": true,
"outs": "all",
"topic": "topic",
"topicType": "msg",
"min": 0,
"max": "5",
"step": "0.1",
"className": "",
"x": 590,
"y": 300,
"wires": [
[]
]
},
{
"id": "3ae60c20ad27b74a",
"type": "ui_chart",
"z": "02971057881eb4a0",
"name": "",
"group": "ef108d3cefe2d6ee",
"order": 3,
"width": 0,
"height": 0,
"label": "chart",
"chartType": "line",
"legend": "false",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": false,
"ymin": "",
"ymax": "",
"removeOlder": 1,
"removeOlderPoints": "",
"removeOlderUnit": "3600",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"x": 590,
"y": 360,
"wires": [
[]
]
},
{
"id": "ef108d3cefe2d6ee",
"type": "ui_group",
"name": "Lab",
"tab": "8af0828ba460aacc",
"order": 1,
"disp": true,
"width": "6",
"collapse": false,
"className": ""
},
{
"id": "8af0828ba460aacc",
"type": "ui_tab",
"name": "Home",
"icon": "dashboard",
"disabled": false,
"hidden": false
}
]