Node-Red

From Review or Discard at Will
Jump to: navigation, search

Node-Red

Dashboard

Chart

Flow

Node-Red Dashboard Line Chart flow
[
    {
        "id": "7d714356.2ad11c",
        "type": "tab",
        "label": "Right Weight",
        "disabled": false,
        "info": ""
    },
    {
        "id": "b205290d.6bb4b8",
        "type": "inject",
        "z": "7d714356.2ad11c",
        "name": "get right weight data",
        "topic": "",
        "payload": "send",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 150,
        "y": 80,
        "wires": [
            [
                "9d8ea6a6.57c828"
            ]
        ]
    },
    {
        "id": "9d8ea6a6.57c828",
        "type": "mqtt out",
        "z": "7d714356.2ad11c",
        "name": "Right Weight",
        "topic": "world/mesa/json/myrightweight",
        "qos": "0",
        "retain": "false",
        "broker": "4ed36834.7a4528",
        "x": 350,
        "y": 80,
        "wires": []
    },
    {
        "id": "5ff0b24d.4e926c",
        "type": "mqtt in",
        "z": "7d714356.2ad11c",
        "name": "Receive right weight",
        "topic": "world/mesa/json/myrightweight/returndata",
        "qos": "2",
        "datatype": "json",
        "broker": "4ed36834.7a4528",
        "x": 150,
        "y": 300,
        "wires": [
            [
                "5aba9d68.09c374",
                "b1056816.08d6f8"
            ]
        ]
    },
    {
        "id": "b1056816.08d6f8",
        "type": "debug",
        "z": "7d714356.2ad11c",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "x": 370,
        "y": 340,
        "wires": []
    },
    {
        "id": "e2bd55b4.32d818",
        "type": "debug",
        "z": "7d714356.2ad11c",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 590,
        "y": 340,
        "wires": []
    },
    {
        "id": "5aba9d68.09c374",
        "type": "change",
        "z": "7d714356.2ad11c",
        "name": "reduce rw",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "[{\t    \"series\": [\"userID.1\"],\t    \"labels\": [\"User 1\"],\t    \"data\": [\t        [payload.{\t            \t            \"x\": weighedDate,\t            \"y\": weight1\t        }]\t    ]\t}]\t",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 360,
        "y": 300,
        "wires": [
            [
                "e2bd55b4.32d818",
                "4cad4fa4.5e62c"
            ]
        ]
    },
    {
        "id": "dc9f5c79.2b5a",
        "type": "ui_button",
        "z": "7d714356.2ad11c",
        "name": "",
        "group": "3a152e37.b81d62",
        "order": 4,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "get rw data",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "icon": "",
        "payload": "send",
        "payloadType": "str",
        "topic": "",
        "x": 130,
        "y": 120,
        "wires": [
            [
                "9d8ea6a6.57c828"
            ]
        ]
    },
    {
        "id": "4cad4fa4.5e62c",
        "type": "ui_chart",
        "z": "7d714356.2ad11c",
        "name": "rw data",
        "group": "3a152e37.b81d62",
        "order": 4,
        "width": "0",
        "height": "0",
        "label": "Right Weight",
        "chartType": "line",
        "legend": "true",
        "xformat": "auto",
        "interpolate": "linear",
        "nodata": "awaiting data or error",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": "50",
        "removeOlderPoints": "",
        "removeOlderUnit": "604800",
        "cutout": 0,
        "useOneColor": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "useOldStyle": false,
        "outputs": 1,
        "x": 580,
        "y": 220,
        "wires": [
            []
        ]
    },
    {
        "id": "6df5b367.72f00c",
        "type": "ui_button",
        "z": "7d714356.2ad11c",
        "name": "clear rw data",
        "group": "3a152e37.b81d62",
        "order": 4,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "clear rw data",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "icon": "",
        "payload": "[]",
        "payloadType": "json",
        "topic": "",
        "x": 130,
        "y": 160,
        "wires": [
            [
                "4cad4fa4.5e62c"
            ]
        ]
    },
    {
        "id": "4ed36834.7a4528",
        "type": "mqtt-broker",
        "z": "",
        "name": "chapeau",
        "broker": "192.168.1.222",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    },
    {
        "id": "3a152e37.b81d62",
        "type": "ui_group",
        "z": "",
        "name": "rightweight",
        "tab": "998ca546.825768",
        "disp": true,
        "width": "6",
        "collapse": false
    },
    {
        "id": "998ca546.825768",
        "type": "ui_tab",
        "z": "",
        "name": "Sensors",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

Rendered Chart

Node-Red Dashboard Line Chart

Input JSON Array

[
  {
    "userID": 1,
    "weight1": 306.0,
    "weighedDate": "2009-08-24T12:57:00",
    "rwId": 1
  },
  {
    "userID": 1,
    "weight1": 302.8,
    "weighedDate": "2009-09-04T21:51:00",
    "rwId": 2
  },
  {
    "userID": 1,
    "weight1": 300.2,
    "weighedDate": "2009-09-09T11:56:00",
    "rwId": 3
  },
  {
    "userID": 1,
    "weight1": 297.8,
    "weighedDate": "2009-09-10T12:03:00",
    "rwId": 4
  },
  {
    "userID": 1,
    "weight1": 297.8,
    "weighedDate": "2009-09-11T18:52:00",
    "rwId": 5
  },
  {
    "userID": 1,
    "weight1": 295.8,
    "weighedDate": "2009-09-12T15:39:00",
    "rwId": 6
  }
]

Change Node

JSONata
[{
    "series": ["userID.1"],
    "labels": ["User 1"],
    "data": [
        [payload.{
            "x": weighedDate,
            "y": weight1
        }]
    ]
}]