UNPKG

node-red-contrib-convert-kitchen

Version:
293 lines 7.85 kB
[ { "id": "9833aa89b8775756", "type": "tab", "label": "Converter", "disabled": false, "info": "" }, { "id": "682fccf598700343", "type": "debug", "z": "9833aa89b8775756", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 730, "y": 200, "wires": [] }, { "id": "1b22265848933a02", "type": "ui_text", "z": "9833aa89b8775756", "group": "dc5caea0185710de", "order": 8, "width": 3, "height": 1, "name": "output", "label": "{{msg.payload}}", "format": "{{msg.finalUnit}}/s", "layout": "row-left", "x": 730, "y": 240, "wires": [] }, { "id": "ca724dfdb0fb5449", "type": "ui_form", "z": "9833aa89b8775756", "name": "", "label": "Converter", "group": "dc5caea0185710de", "order": 1, "width": 4, "height": 1, "options": [ { "label": "e.g. 1.66 or 5/3", "value": "value", "type": "text", "required": false, "rows": null }, { "label": "Input unit", "value": "unit", "type": "text", "required": false, "rows": null }, { "label": "Output unit", "value": "finalUnit", "type": "text", "required": false, "rows": null }, { "label": "US or Imperial", "value": "sys", "type": "text", "required": false, "rows": null } ], "formValue": { "value": "", "unit": "", "finalUnit": "", "sys": "" }, "payload": "", "submit": "submit", "cancel": "", "topic": "topic", "topicType": "msg", "splitLayout": false, "x": 140, "y": 240, "wires": [ [ "41c31e3ff8d1e9d1" ] ] }, { "id": "41c31e3ff8d1e9d1", "type": "function", "z": "9833aa89b8775756", "name": "formating", "func": "// handle strings and fractions as input, create fallback\nif (msg.payload.value.search(\"/\") !== -1) {\n msg.payload.value = msg.payload.value.split(\"/\");\n msg.payload.value = (msg.payload.value[0] / msg.payload.value[1]);\n msg.payload.value = Math.round(msg.payload.value * 10000) / 10000;\n} else if (msg.payload.value === '') {\n msg.payload.value = flow.get('value');\n} else {\n msg.payload.value = parseFloat(msg.payload.value);\n flow.set('value', msg.payload.value);\n};\nif (msg.payload.unit === '') {\n msg.payload.unit = flow.get('unit');\n} else {\n flow.set('unit', msg.payload.unit);\n};\nif (msg.payload.finalUnit === '') {\n msg.payload.finalUnit = flow.get('finalUnit');\n} else {\n flow.set('finalUnit', msg.payload.finalUnit);\n};\nif (msg.payload.sys === '') {\n msg.payload.sys = flow.get('sys');\n} else {\n flow.set('sys', msg.payload.sys);\n};\n\nreturn { \"value\": msg.payload.value, \"unit\": msg.payload.unit, \"finalUnit\": msg.payload.finalUnit, \"sys\": msg.payload.sys };", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 300, "y": 240, "wires": [ [ "cc1f8c4a7da8a5ce" ] ] }, { "id": "87dd3df17627d2ab", "type": "ui_text", "z": "9833aa89b8775756", "group": "dc5caea0185710de", "order": 6, "width": 3, "height": 1, "name": "input unit", "label": "", "format": "{{msg.unit}}/s", "layout": "row-left", "x": 740, "y": 320, "wires": [] }, { "id": "f2c1f1d17655f71e", "type": "ui_text", "z": "9833aa89b8775756", "group": "dc5caea0185710de", "order": 4, "width": 3, "height": 1, "name": "input value", "label": "", "format": "{{msg.value}}", "layout": "row-left", "x": 750, "y": 280, "wires": [] }, { "id": "a4d4b4f0326ad3b9", "type": "ui_template", "z": "9833aa89b8775756", "group": "dc5caea0185710de", "name": "Spacer", "order": 2, "width": 3, "height": 1, "format": "", "storeOutMessages": true, "fwdInMessages": true, "resendOnRefresh": true, "templateScope": "local", "x": 480, "y": 200, "wires": [ [] ] }, { "id": "cc1f8c4a7da8a5ce", "type": "convert-kitchen", "z": "9833aa89b8775756", "name": "", "value": "1", "unit": "gallon", "finalUnit": "gallon", "sys": "us", "output": "payload", "x": 500, "y": 240, "wires": [ [ "1b22265848933a02", "682fccf598700343", "f2c1f1d17655f71e", "87dd3df17627d2ab", "394ed36100d351de" ] ] }, { "id": "7e22a75a231ce2f2", "type": "inject", "z": "9833aa89b8775756", "name": "", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payloadType": "str", "x": 310, "y": 200, "wires": [ [ "cc1f8c4a7da8a5ce" ] ] }, { "id": "394ed36100d351de", "type": "ui_text", "z": "9833aa89b8775756", "group": "dc5caea0185710de", "order": 10, "width": 3, "height": 1, "name": "system", "label": "", "format": "{{msg.sys}}", "layout": "row-left", "x": 740, "y": 360, "wires": [] }, { "id": "1c1f36b8178542e7", "type": "ui_spacer", "z": "9833aa89b8775756", "name": "spacer", "group": "dc5caea0185710de", "order": 3, "width": 4, "height": 1 }, { "id": "8884b150cde027ea", "type": "ui_spacer", "z": "9833aa89b8775756", "name": "spacer", "group": "dc5caea0185710de", "order": 5, "width": 4, "height": 1 }, { "id": "876d9a4a5c3148d8", "type": "ui_spacer", "z": "9833aa89b8775756", "name": "spacer", "group": "dc5caea0185710de", "order": 7, "width": 4, "height": 1 }, { "id": "07f0e929e20cdd34", "type": "ui_spacer", "z": "9833aa89b8775756", "name": "spacer", "group": "dc5caea0185710de", "order": 9, "width": 4, "height": 1 }, { "id": "dc5caea0185710de", "type": "ui_group", "name": "Liquid volume", "tab": "b48aff32d36a85d0", "order": 1, "disp": true, "width": 7, "collapse": false }, { "id": "b48aff32d36a85d0", "type": "ui_tab", "name": "Converter", "icon": "dashboard", "disabled": false, "hidden": false } ]