Hi all.
I am newbie in node red. I have som little experiences, but not much.So I have read many examples and also imported example ui control of table, but I am not able to create simple function, that highlight a row by red color in the table, that has a value send via flow.set <10.
UI table is readed from DB directly. Here is code. If you can help me, I will be glad. Many thanks for your time.
[
{
"id": "13861ca69f2c20b6",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "79f18799d32c03d1",
"type": "ui_table",
"z": "13861ca69f2c20b6",
"group": "ec06941b4e2e607f",
"name": "",
"order": 8,
"width": "25",
"height": "12",
"columns": [
{
"field": "id",
"title": "<small>ID</small>",
"width": "3%",
"align": "center",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "location",
"title": "<small>Umiestnenie</small>",
"width": "12%",
"align": "left",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "input_rel",
"title": "<small>Zdroj.relé</small>",
"width": "",
"align": "center",
"formatter": "tickCross",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "charge_rel",
"title": "<small>NabĂj.relĂ©</small>",
"width": "",
"align": "center",
"formatter": "tickCross",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "output_rel",
"title": "<small>Výst.relé</small>",
"width": "",
"align": "center",
"formatter": "tickCross",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "output_rel_time",
"title": "<small>ÄŚas do zap.rel.</small>",
"width": "",
"align": "center",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "batt_volt",
"title": "<small>U bat.(V)</small>",
"width": "",
"align": "center",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "charge_volt",
"title": "<small>U nab.(V)</small>",
"width": "",
"align": "center",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "input_volt",
"title": "<small>U zdroja(V)</small>",
"width": "",
"align": "center",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "charge_curr",
"title": "<small>I nab.(A)</small>",
"width": "",
"align": "center",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "output_curr",
"title": "<small>I výst.(A)</small>",
"width": "",
"align": "center",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "charge_status",
"title": "<small>Stav nab.</small>",
"width": "",
"align": "center",
"formatter": "traffic",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "output_power",
"title": "<small>P-(W)</small>",
"width": "6%",
"align": "center",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "temp_box",
"title": "<small>T(°C)</small>",
"width": "5%",
"align": "center",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "errors_mess",
"title": "<small>Info/Err</small>",
"width": "6%",
"align": "left",
"formatter": "color",
"formatterParams": {
"target": "_blank"
}
}
],
"outputs": 1,
"cts": true,
"x": 470,
"y": 100,
"wires": [
[
"01fac031c65184bc"
]
]
},
{
"id": "54f34611329ab63f",
"type": "sqlite",
"z": "13861ca69f2c20b6",
"mydb": "77663dac4f64af8e",
"sqlquery": "msg.topic",
"sql": "",
"name": "sqlitedb",
"x": 300,
"y": 100,
"wires": [
[
"79f18799d32c03d1"
]
]
},
{
"id": "6e7912c9adec9a32",
"type": "inject",
"z": "13861ca69f2c20b6",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "5",
"crontab": "",
"once": true,
"onceDelay": "2",
"topic": "SELECT * FROM ups_data ORDER BY id;",
"payload": "",
"payloadType": "date",
"x": 130,
"y": 100,
"wires": [
[
"54f34611329ab63f"
]
]
},
{
"id": "f6aedf5c5e1a93f0",
"type": "ui_toast",
"z": "13861ca69f2c20b6",
"position": "dialog",
"displayTime": "3",
"highlight": "",
"sendall": false,
"outputs": 1,
"ok": "OK",
"cancel": "",
"raw": true,
"className": "",
"topic": "",
"name": "info_panel",
"x": 690,
"y": 200,
"wires": [
[]
]
},
{
"id": "01fac031c65184bc",
"type": "function",
"z": "13861ca69f2c20b6",
"name": "function 22",
"func": "var msg1, msg2, msg3, errs;\nvar sel_row = flow.get(\"db_row_id\");// ID autoincremented by DB\nvar data_extr = msg.payload; // extracted data from payload\nvar info_loc, info_text, info_err;\ninfo_loc = msg.payload.location; // location info from DB\nif (msg.payload.errors_num==0){\nerrs = \"Without err\"; \n} else if (msg.payload.errors_num == 1){\n errs = \"Battery charging error.\"; \n} else if (msg.payload.errors_num == 2) {\n errs = \"Low battery capacity.\";\n} else if (msg.payload.errors_num == 3) {\n errs = \"Battery discarged.\";\n} else if (msg.payload.errors_num == 4) {\n errs = \"Battery not connected.\";\n} else if (msg.payload.errors_num == 5) {\n errs = \"Longest duration of battery capacity !\";\n} else if (msg.payload.errors_num == 6) {\n errs = \"Battery test running\";\n}\ninfo_text = \"<b>IP adr :</b> \" + msg.payload.ris_ip + \"<br><b>ASDU(ID) :</b> \" + msg.payload.ris_id + \"<br><b>Messages :</b> \" + errs;\nmsg1 = { topic: info_loc, payload: info_text};\nmsg1.socketid = msg.socketid;\nreturn [msg1, msg2, msg3];",
"outputs": 3,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 630,
"y": 110,
"wires": [
[
"f6aedf5c5e1a93f0"
],
[],
[]
]
},
{
"id": "391dfd00f6a932dd",
"type": "link in",
"z": "13861ca69f2c20b6",
"name": "link in 1",
"links": [
"4555861d9e04dff6"
],
"x": 275,
"y": 240,
"wires": [
[]
]
},
{
"id": "ec06941b4e2e607f",
"type": "ui_group",
"name": "Dáta UPS",
"tab": "8971efe7.4a1af",
"order": 1,
"disp": true,
"width": "25",
"collapse": false,
"className": ""
},
{
"id": "77663dac4f64af8e",
"type": "sqlitedb",
"db": "/home/pi/SmartUPS/db_data_ups.sqlite",
"mode": "RW"
},
{
"id": "8971efe7.4a1af",
"type": "ui_tab",
"name": "Main view",
"icon": "fa-bar-chart",
"order": 1,
"disabled": false,
"hidden": false
}
]