Hey all.
I'm building a dashboard UI and ran into an issue. I've dynamically set the min, max, step, and format via sending a msg.ui_control
object with no issues. The problem then comes when I try to dynamically input a number with decimal places. Here is an example:
input node with 2.5
sent to the numeric as the payload. Numeric will then display a 3
and not 2.5
. It appears that the Numeric is taking the payload and rounding to the nearest integer. Can someone shed some light on this? Is this supposed to happen? I'd like it to accept the number that I provide via the input (2.5, 2.75, 5.75, etc.). Here is my code for reference:
[
{
"id": "a2817fb1.a78d7",
"type": "inject",
"z": "37e80d8d.af11b2",
"name": "",
"topic": "",
"payload": "2.50",
"payloadType": "num",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 490,
"y": 4620,
"wires": [
[
"d5ff3850.9179b8"
]
]
},
{
"id": "491cfd1c.48ec84",
"type": "inject",
"z": "37e80d8d.af11b2",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 300,
"y": 4700,
"wires": [
[
"937176f2.459188"
]
]
},
{
"id": "937176f2.459188",
"type": "function",
"z": "37e80d8d.af11b2",
"name": "sets Parameters",
"func": "msg.ui_control = {\n \"min\": 0,\n \"max\": 5,\n \"step\": 0.25,\n \"format\": \"{{value | number:4}}\"\n};\nmsg.payload = 1;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 460,
"y": 4700,
"wires": [
[
"d5ff3850.9179b8"
]
]
},
{
"id": "640af37d.6a200c",
"type": "debug",
"z": "37e80d8d.af11b2",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 790,
"y": 4700,
"wires": []
},
{
"id": "d5ff3850.9179b8",
"type": "ui_numeric",
"z": "37e80d8d.af11b2",
"name": "",
"label": "numeric",
"tooltip": "",
"group": "f9439bec.8f69e8",
"order": 1,
"width": 0,
"height": 0,
"wrap": false,
"passthru": true,
"topic": "",
"format": "{{value | number:2}}",
"min": 0,
"max": 10,
"step": 1,
"x": 640,
"y": 4700,
"wires": [
[
"640af37d.6a200c"
]
]
},
{
"id": "adc3e2d8.d8085",
"type": "inject",
"z": "37e80d8d.af11b2",
"name": "",
"topic": "",
"payload": "2.35",
"payloadType": "num",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 490,
"y": 4580,
"wires": [
[
"d5ff3850.9179b8"
]
]
},
{
"id": "f9439bec.8f69e8",
"type": "ui_group",
"z": "",
"name": "Test",
"tab": "98b94b1.92c47b8",
"order": 1,
"disp": false,
"width": "8",
"collapse": false
},
{
"id": "98b94b1.92c47b8",
"type": "ui_tab",
"z": "",
"name": "Numeric Test",
"icon": "dashboard",
"disabled": false,
"hidden": false
}
]