Hello,
I'm new to Node-RED and javascript... hope you can help!
I want to perform a influxdb query between two specitic timestamps: boot, and now (being now the moment at which GPIO 21 turns to 0).
I don't manage to create a working function node that sends the msg.query to influxdb in node correctly.
I share below my flow in case it helps.
Thanks!
[
{
"id": "17f65318.ee1d2d",
"type": "tab",
"label": "Flow 3",
"disabled": false,
"info": ""
},
{
"id": "dd2abd31.35787",
"type": "rpi-gpio in",
"z": "17f65318.ee1d2d",
"name": "Key OFF",
"pin": "40",
"intype": "tri",
"debounce": "25",
"read": false,
"x": 80,
"y": 40,
"wires": [
[
"e8ded98b.83f858"
]
]
},
{
"id": "f04219ab.d9b908",
"type": "influxdb in",
"z": "17f65318.ee1d2d",
"influxdb": "9aa3d4b6.12c9b8",
"name": "max GS vuelo",
"query": "SELECT max(\"value\") /16203 FROM \"Accel[2]\" WHERE time >= now() - 200d and time < now()",
"rawOutput": false,
"precision": "",
"retentionPolicy": "",
"org": "organisation",
"x": 680,
"y": 40,
"wires": [
[
"2a35fba0.aa0014"
]
]
},
{
"id": "e8ded98b.83f858",
"type": "switch",
"z": "17f65318.ee1d2d",
"name": "Key off?",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "0",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 280,
"y": 40,
"wires": [
[
"1e8f57c3.271bd8"
]
]
},
{
"id": "30479452.86686c",
"type": "inject",
"z": "17f65318.ee1d2d",
"name": "key on",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 90,
"y": 100,
"wires": [
[
"d598061a.2cb6f8"
]
]
},
{
"id": "d598061a.2cb6f8",
"type": "change",
"z": "17f65318.ee1d2d",
"name": "Set flow.time",
"rules": [
{
"t": "set",
"p": "time",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 290,
"y": 100,
"wires": [
[]
]
},
{
"id": "2a35fba0.aa0014",
"type": "debug",
"z": "17f65318.ee1d2d",
"name": "Output 1",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 880,
"y": 40,
"wires": []
},
{
"id": "1e8f57c3.271bd8",
"type": "function",
"z": "17f65318.ee1d2d",
"name": "",
"func": "",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 460,
"y": 40,
"wires": [
[
"f04219ab.d9b908"
]
]
},
{
"id": "9aa3d4b6.12c9b8",
"type": "influxdb",
"hostname": "127.0.0.1",
"port": "8086",
"protocol": "http",
"database": "database",
"name": "test 1.8 flux",
"usetls": false,
"tls": "d50d0c9f.31e858",
"influxdbVersion": "1.8-flux",
"url": "https://localhost:8086",
"rejectUnauthorized": false
},
{
"id": "d50d0c9f.31e858",
"type": "tls-config",
"name": "",
"cert": "",
"key": "",
"ca": "",
"certname": "",
"keyname": "",
"caname": "",
"servername": "",
"verifyservercert": false
}
]