Ich hab ein paar Flows gebastelt um die API Schnittstelle zu testen - ich häng dir die Flows hier im Text dran.
Du musst nur den API-Key anpassen und die WLAN Adresse deines TXT in der URL eintragen.
(Start der Flows)
[
{
"id": "ce8d8a558e1ab29c",
"type": "http request",
"z": "32711f3c08d8be6f",
"name": "",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "
http://192.168.0.16/api/v1/controller/0/inputs/1",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"senderr": false,
"x": 450,
"y": 340,
"wires": [
[
"39c71c0a61a7286f"
]
]
},
{
"id": "a8ccfcde86a483c6",
"type": "function",
"z": "32711f3c08d8be6f",
"name": "",
"func": "var apikey = \"oShVKk\";\n\nmsg.headers = { \n \"X-API-KEY\": apikey,\n \"Content-Type\":\"application/json\"\n };\n\nmsg.payload = {};\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 280,
"y": 340,
"wires": [
[
"ce8d8a558e1ab29c"
]
]
},
{
"id": "39c71c0a61a7286f",
"type": "debug",
"z": "32711f3c08d8be6f",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 610,
"y": 340,
"wires": []
},
{
"id": "b70f6defd4774b3f",
"type": "inject",
"z": "32711f3c08d8be6f",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 120,
"y": 340,
"wires": [
[
"a8ccfcde86a483c6"
]
]
},
{
"id": "de2a8d82513d5556",
"type": "http request",
"z": "32711f3c08d8be6f",
"name": "",
"method": "POST",
"ret": "txt",
"paytoqs": "ignore",
"url": "
http://192.168.0.16/api/v1/controller/0/inputs/2",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"senderr": false,
"x": 450,
"y": 220,
"wires": [
[
"626824f25103c824"
]
]
},
{
"id": "549d90d06f661342",
"type": "function",
"z": "32711f3c08d8be6f",
"name": "",
"func": "var apikey = \"oShVKk\";\n\nmsg.headers = { \n \"X-API-KEY\": apikey,\n \"Content-Type\":\"application/json\"\n };\n\nmsg.payload = { \"device\": \"PHOTO_RESISTOR\",\n \"enabled\": true,\n \"name\": \"string\",\n \"value\": 0\n };\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 280,
"y": 220,
"wires": [
[
"de2a8d82513d5556"
]
]
},
{
"id": "626824f25103c824",
"type": "debug",
"z": "32711f3c08d8be6f",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 610,
"y": 220,
"wires": []
},
{
"id": "69ded15a837bac55",
"type": "inject",
"z": "32711f3c08d8be6f",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 120,
"y": 220,
"wires": [
[
"549d90d06f661342"
]
]
},
{
"id": "fe0ee6c071d15fdb",
"type": "inject",
"z": "32711f3c08d8be6f",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 120,
"y": 180,
"wires": [
[
"cbc4082cb4ee0e5a"
]
]
},
{
"id": "cbc4082cb4ee0e5a",
"type": "function",
"z": "32711f3c08d8be6f",
"name": "",
"func": "var apikey = \"oShVKk\";\n\nmsg.headers = { \n \"X-API-KEY\": apikey,\n \"Content-Type\":\"application/json\"\n };\n\nmsg.payload = { \"device\": \"MINI_SWITCH\",\n \"enabled\": true,\n \"name\": \"string\",\n \"value\": 0\n };\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 280,
"y": 180,
"wires": [
[
"65fa4095764f73cf"
]
]
},
{
"id": "65fa4095764f73cf",
"type": "http request",
"z": "32711f3c08d8be6f",
"name": "",
"method": "POST",
"ret": "txt",
"paytoqs": "ignore",
"url": "
http://192.168.0.16/api/v1/controller/0/inputs/1",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"senderr": false,
"x": 450,
"y": 180,
"wires": [
[
"a6fb586ac02c3957"
]
]
},
{
"id": "a6fb586ac02c3957",
"type": "debug",
"z": "32711f3c08d8be6f",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 610,
"y": 180,
"wires": []
},
{
"id": "9fb68a3470844e1e",
"type": "inject",
"z": "32711f3c08d8be6f",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 120,
"y": 380,
"wires": [
[
"9ea3efc939716748"
]
]
},
{
"id": "9ea3efc939716748",
"type": "function",
"z": "32711f3c08d8be6f",
"name": "",
"func": "var apikey = \"oShVKk\";\n\nmsg.headers = { \n \"X-API-KEY\": apikey,\n \"Content-Type\":\"application/json\"\n };\n\nmsg.payload = {};\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 280,
"y": 380,
"wires": [
[
"ad6baa95d571fafe"
]
]
},
{
"id": "ad6baa95d571fafe",
"type": "http request",
"z": "32711f3c08d8be6f",
"name": "",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "
http://192.168.0.16/api/v1/controller/0/inputs/2",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"senderr": false,
"x": 450,
"y": 380,
"wires": [
[
"a686d3dbf2ec3f89"
]
]
},
{
"id": "a686d3dbf2ec3f89",
"type": "debug",
"z": "32711f3c08d8be6f",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 610,
"y": 380,
"wires": []
},
{
"id": "5afd9dafe03ea131",
"type": "inject",
"z": "32711f3c08d8be6f",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 120,
"y": 80,
"wires": [
[
"b6661bb071f9c5cf"
]
]
},
{
"id": "b6661bb071f9c5cf",
"type": "function",
"z": "32711f3c08d8be6f",
"name": "",
"func": "var apikey = \"oShVKk\";\n\nmsg.headers = { \"accept\":\"*/*\",\n \"X-API-KEY\": apikey\n //\"Content-Type\":\"application/json\"\n };\n\nmsg.payload = { //\"device\": \"MINI_SWITCH\",\n //\"enabled\": true,\n //\"name\": \"string\",\n //\"value\": 0\n };\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 280,
"y": 80,
"wires": [
[
"43190488443a1054"
]
]
},
{
"id": "43190488443a1054",
"type": "http request",
"z": "32711f3c08d8be6f",
"name": "",
"method": "POST",
"ret": "txt",
"paytoqs": "ignore",
"url": "
http://192.168.0.16/api/v1/controller/0",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"senderr": false,
"x": 450,
"y": 80,
"wires": [
[
"373f28e1237f4dfc"
]
]
},
{
"id": "373f28e1237f4dfc",
"type": "debug",
"z": "32711f3c08d8be6f",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 610,
"y": 80,
"wires": []
},
{
"id": "a5419c8a7f0ed424",
"type": "comment",
"z": "32711f3c08d8be6f",
"name": "init controller",
"info": "",
"x": 110,
"y": 40,
"wires": []
},
{
"id": "6ba2bcc2a8c065ab",
"type": "comment",
"z": "32711f3c08d8be6f",
"name": "init IO",
"info": "",
"x": 90,
"y": 140,
"wires": []
},
{
"id": "a8b299678eb5be11",
"type": "comment",
"z": "32711f3c08d8be6f",
"name": "read IO",
"info": "",
"x": 90,
"y": 300,
"wires": []
}
]