Wie kann im NodeRED Covid-19 Dashboard die Skala für alle gleichzeitig gesetzt werden? In diesem Dasboard gibt es 2×3 Werte die immer gleich sein sollen:
Bisher musste ich in jedem der 6 Gauge-Nodes den Wert einzeln setzen. Man kann die Gauge-Nodes aber auch über die Eigenschaft: msg.ui_control setzen:
Deshalb habe ich eine globale Variable gemacht, die man an einer Stelle mit global.set setzen kann. Das auslesen geht dann mit global.get. So braucht man nur eine Stelle ändern. Hier die Details:
Hier der Code:
[ { "id": "61f1bbef.1e19bc", "type": "ui_gauge", "z": "e5fe4838.e62b68", "name": "Bestätigt", "group": "9a7db4b9.81f32", "order": 0, "width": 0, "height": 0, "gtype": "gage", "title": "Bestätigt", "label": "Personen", "format": "{{msg.payload | number:0}}", "min": 0, "max": "100000", "colors": [ "#e5e500", "#e6e600", "#e5e500" ], "seg1": "", "seg2": "", "x": 800, "y": 220, "wires": [] }, { "id": "c44c7747.fd9098", "type": "function", "z": "e5fe4838.e62b68", "name": "Deutschland bestätigt ermitteln", "func": "// Hier das gewünschte Land angeben\nvar land = \"Germany\"\n \n// Suche den Index des Land\nfor (var i = 0; i < msg.payload.length; i++){\n if (msg.payload[i].countryRegion == land ){\n land = i\n break\n }\n} \nmsg.payload = msg.payload[land].confirmed\n\nvar max_deutschland=global.get('max_deutschland') || 0;\nmsg.ui_control = {\"min\":0,\"max\":max_deutschland};\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 550, "y": 220, "wires": [ [ "61f1bbef.1e19bc", "4cc8a8a5.89cef" ] ] }, { "id": "78c20335.cf2564", "type": "ui_gauge", "z": "e5fe4838.e62b68", "name": "Gestorben", "group": "9a7db4b9.81f32", "order": 0, "width": 0, "height": 0, "gtype": "gage", "title": "Gestorben", "label": "Personen", "format": "{{msg.payload | number:0}}", "min": 0, "max": "100000", "colors": [ "#ff4f3e", "#ff4c36", "#ff493f" ], "seg1": "", "seg2": "", "x": 810, "y": 260, "wires": [] }, { "id": "4e48b5ce.a13d24", "type": "function", "z": "e5fe4838.e62b68", "name": "Deutschland gestorben ermitteln", "func": "// Hier das gewünschte Land angeben\nvar land = \"Germany\"\n \n// Suche den Index des Land\nfor (var i = 0; i < msg.payload.length; i++){\n if (msg.payload[i].countryRegion == land ){\n land = i\n break\n }\n} \nmsg.payload = msg.payload[land].deaths\n\nvar max_deutschland=global.get('max_deutschland') || 0;\nmsg.ui_control = {\"min\":0,\"max\":max_deutschland};\n\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 560, "y": 260, "wires": [ [ "78c20335.cf2564" ] ] }, { "id": "3b13ce0b.da418a", "type": "ui_gauge", "z": "e5fe4838.e62b68", "name": "Genesen", "group": "9a7db4b9.81f32", "order": 0, "width": 0, "height": 0, "gtype": "gage", "title": "Genesen", "label": "Personen", "format": "{{msg.payload | number:0}}", "min": 0, "max": "100000", "colors": [ "#46b22a", "#45b22a", "#45b22a" ], "seg1": "", "seg2": "", "x": 800, "y": 300, "wires": [] }, { "id": "42b25b9.3a079a4", "type": "function", "z": "e5fe4838.e62b68", "name": "Deutschland genesen ermitteln", "func": "// Hier das gewünschte Land angeben\nvar land = \"Germany\"\n \n// Suche den Index des Land\nfor (var i = 0; i < msg.payload.length; i++){\n if (msg.payload[i].countryRegion == land ){\n land = i\n break\n }\n} \n\nmsg.payload = msg.payload[land].recovered\n\nvar max_deutschland=global.get('max_deutschland') || 0;\nmsg.ui_control = {\"min\":0,\"max\":max_deutschland};\n\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 550, "y": 300, "wires": [ [ "3b13ce0b.da418a" ] ] }, { "id": "ab1d62f3.d098f8", "type": "link in", "z": "e5fe4838.e62b68", "name": "Corona Dashboard", "links": [ "ca102a5a.f531e", "fa301f7e.a515e8" ], "x": 275, "y": 260, "wires": [ [ "c44c7747.fd9098", "4e48b5ce.a13d24", "42b25b9.3a079a4", "67fcb377.a92404" ] ] }, { "id": "53442036.3b67b8", "type": "comment", "z": "e5fe4838.e62b68", "name": "www.wenzlaff.info", "info": "", "x": 830, "y": 40, "wires": [] }, { "id": "3fca9c6d.9cd794", "type": "link in", "z": "e5fe4838.e62b68", "name": "", "links": [ "fa301f7e.a515e8" ], "x": 275, "y": 480, "wires": [ [ "86e1a9de.f78a8", "7f0f952f.fb10c4", "fd2d76fa.0bb928", "553d75b.5d80a8c" ] ] }, { "id": "747550fc.314aa8", "type": "ui_gauge", "z": "e5fe4838.e62b68", "name": "Bestätigt", "group": "24fb8d4d.6a1dba", "order": 0, "width": 0, "height": 0, "gtype": "gage", "title": "Bestätigt", "label": "Personen", "format": "{{msg.payload | number:0}}", "min": 0, "max": "1000000", "colors": [ "#e5e500", "#e6e600", "#e5e500" ], "seg1": "", "seg2": "", "x": 800, "y": 440, "wires": [] }, { "id": "fd2d76fa.0bb928", "type": "function", "z": "e5fe4838.e62b68", "name": "Weltweit bestätigt ermitteln", "func": "msg.payload = msg.payload.confirmed.value\n\nvar max_weltweit=global.get('max_weltweit') || 0;\nmsg.ui_control = {\"min\":0,\"max\":max_weltweit}\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 540, "y": 440, "wires": [ [ "747550fc.314aa8", "4f44db07.4f4c8c" ] ] }, { "id": "68266eb.034aa1", "type": "ui_gauge", "z": "e5fe4838.e62b68", "name": "Gestorben", "group": "24fb8d4d.6a1dba", "order": 0, "width": 0, "height": 0, "gtype": "gage", "title": "Gestorben", "label": "Personen", "format": "{{msg.payload | number:0}}", "min": 0, "max": "1000000", "colors": [ "#ff4f3e", "#ff4c36", "#ff493f" ], "seg1": "", "seg2": "", "x": 810, "y": 480, "wires": [] }, { "id": "86e1a9de.f78a8", "type": "function", "z": "e5fe4838.e62b68", "name": "Weltweit gestorben ermitteln", "func": "msg.payload = msg.payload.deaths.value\n\nvar max_weltweit=global.get('max_weltweit') || 0;\nmsg.ui_control = {\"min\":0,\"max\":max_weltweit};\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 540, "y": 480, "wires": [ [ "68266eb.034aa1" ] ] }, { "id": "f3857e2c.676af8", "type": "ui_gauge", "z": "e5fe4838.e62b68", "name": "Genesen", "group": "24fb8d4d.6a1dba", "order": 0, "width": 0, "height": 0, "gtype": "gage", "title": "Genesen", "label": "Personen", "format": "{{msg.payload | number:0}}", "min": 0, "max": "1000000", "colors": [ "#46b22a", "#e6e600", "#ca3838" ], "seg1": "", "seg2": "", "x": 800, "y": 520, "wires": [] }, { "id": "7f0f952f.fb10c4", "type": "function", "z": "e5fe4838.e62b68", "name": "Weltweit genesen ermitteln", "func": "msg.payload = msg.payload.recovered.value\n\nvar max_weltweit=global.get('max_weltweit') || 0;\nmsg.ui_control = {\"min\":0,\"max\":max_weltweit};\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 540, "y": 520, "wires": [ [ "f3857e2c.676af8" ] ] }, { "id": "b4c4712e.2309a8", "type": "comment", "z": "e5fe4838.e62b68", "name": "Covid-19 Dashboard", "info": "", "x": 510, "y": 40, "wires": [] }, { "id": "4cc8a8a5.89cef", "type": "ui_chart", "z": "e5fe4838.e62b68", "name": "", "group": "9a7db4b9.81f32", "order": 3, "width": 0, "height": 0, "label": "Bestätigt", "chartType": "line", "legend": "false", "xformat": "dd HH:mm", "interpolate": "linear", "nodata": "", "dot": false, "ymin": "", "ymax": "", "removeOlder": 1, "removeOlderPoints": "", "removeOlderUnit": "86400", "cutout": 0, "useOneColor": false, "colors": [ "#1f77b4", "#aec7e8", "#ff7f0e", "#2ca02c", "#98df8a", "#d62728", "#ff9896", "#9467bd", "#c5b0d5" ], "useOldStyle": false, "outputs": 1, "x": 800, "y": 180, "wires": [ [] ] }, { "id": "4f44db07.4f4c8c", "type": "ui_chart", "z": "e5fe4838.e62b68", "name": "", "group": "24fb8d4d.6a1dba", "order": 3, "width": 0, "height": 0, "label": "Bestätigt", "chartType": "line", "legend": "false", "xformat": "dd HH:mm", "interpolate": "linear", "nodata": "", "dot": false, "ymin": "", "ymax": "", "removeOlder": 1, "removeOlderPoints": "", "removeOlderUnit": "86400", "cutout": 0, "useOneColor": false, "colors": [ "#1f77b4", "#aec7e8", "#ff7f0e", "#2ca02c", "#98df8a", "#d62728", "#ff9896", "#9467bd", "#c5b0d5" ], "useOldStyle": false, "outputs": 1, "x": 800, "y": 400, "wires": [ [] ] }, { "id": "1f7e3570.a2948b", "type": "ui_text", "z": "e5fe4838.e62b68", "group": "24fb8d4d.6a1dba", "order": 4, "width": 0, "height": 0, "name": "", "label": "", "format": "{{msg.payload}}", "layout": "row-spread", "x": 790, "y": 600, "wires": [] }, { "id": "553d75b.5d80a8c", "type": "function", "z": "e5fe4838.e62b68", "name": "Zeitpunkt bestätigt ermitteln", "func": "msg.payload = msg.payload.lastUpdate\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 540, "y": 600, "wires": [ [ "1f7e3570.a2948b" ] ] }, { "id": "ec43a02e.1036c", "type": "ui_text", "z": "e5fe4838.e62b68", "group": "9a7db4b9.81f32", "order": 4, "width": 0, "height": 0, "name": "", "label": "", "format": "{{msg.payload}}", "layout": "row-spread", "x": 790, "y": 340, "wires": [] }, { "id": "67fcb377.a92404", "type": "function", "z": "e5fe4838.e62b68", "name": "Zeitpunkt bestätigt ermitteln", "func": "// Hier das gewünschte Land angeben\nvar land = \"Germany\"\n \n// Suche den Index des Land\nfor (var i = 0; i < msg.payload.length; i++){\n if (msg.payload[i].countryRegion == land ){\n land = i\n break\n }\n} \nmsg.payload = new Date(msg.payload[land].lastUpdate)\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 540, "y": 340, "wires": [ [ "ec43a02e.1036c" ] ] }, { "id": "ed80f35e.784d08", "type": "function", "z": "e5fe4838.e62b68", "name": "Global Set Skala", "func": "\nvar max_weltweit= 2000000;\nvar max_deutschland= 200000;\n\nnode.warn(\"Setzte folgende Skalen: \");\nnode.warn(\"Max. Weltweit : \" + max_weltweit);\nnode.warn(\"Max. Deutschland: \" + max_deutschland);\n\nglobal.set('max_weltweit',max_weltweit);\nglobal.set('max_deutschland',max_deutschland);\n\n\n\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 350, "y": 100, "wires": [ [ "74f04be9.0802c4" ] ] }, { "id": "76910c03.0f6df4", "type": "inject", "z": "e5fe4838.e62b68", "name": "Set Skala", "topic": "", "payload": "true", "payloadType": "bool", "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "x": 140, "y": 100, "wires": [ [ "ed80f35e.784d08" ] ] }, { "id": "74f04be9.0802c4", "type": "debug", "z": "e5fe4838.e62b68", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "x": 550, "y": 100, "wires": [] }, { "id": "9a7db4b9.81f32", "type": "ui_group", "z": "", "name": "Covid-19 in Deutschland", "tab": "9f205757.68494", "disp": true, "width": "6", "collapse": false }, { "id": "24fb8d4d.6a1dba", "type": "ui_group", "z": "", "name": "Covid-19 Weltweit", "tab": "9f205757.68494", "disp": true, "width": "6", "collapse": false }, { "id": "9f205757.68494", "type": "ui_tab", "z": "", "name": "wenzlaff.de", "icon": "dashboard", "disabled": false, "hidden": false } ]
Ähnliche Artikel:
- Node-Red organisieren mit link-in bzw. link-out am Beispiel: Covid-19 Dashboard
- NodeRed Corona-Dashboard mit kleiner History-Tabelle
- Corona Dashboard mit NodeRed erstellen