add kernel device auto subflow
This commit is contained in:
parent
8d2734e748
commit
a43bb96156
5 changed files with 1568 additions and 22 deletions
1539
flows.json
1539
flows.json
File diff suppressed because it is too large
Load diff
34
src/Kernel/check_device2.js
Normal file
34
src/Kernel/check_device2.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
// output 1 : error message
|
||||
// output 2 : device registration
|
||||
|
||||
// script var
|
||||
var msg = msg;
|
||||
var newmsg = {};
|
||||
|
||||
if (typeof msg === 'undefined'){
|
||||
return [null,null];
|
||||
}
|
||||
|
||||
// check var existence
|
||||
if (typeof msg.bucket === 'undefined' ||
|
||||
typeof msg.model === 'undefined' ||
|
||||
typeof msg.id === 'undefined'
|
||||
) {
|
||||
node.status({
|
||||
fill: "red", shape: "ring", text: 'undefined device'});
|
||||
return [msg,null];
|
||||
}
|
||||
|
||||
// recreate msg
|
||||
newmsg = {
|
||||
'bucket': msg.bucket,
|
||||
'measurement': typeof msg.measurement === 'undefined' ? '' : msg.measurement,
|
||||
'field': typeof msg.field === 'undefined' ? '' : msg.field,
|
||||
'model': msg.model,
|
||||
'option': typeof msg.option === 'undefined' ? 0 : msg.option,
|
||||
'id': msg.id,
|
||||
'payload':''
|
||||
};
|
||||
|
||||
node.status({ fill: 'green', shape: "ring", text: newmsg.model + ' / ' + newmsg.id });
|
||||
return [null,newmsg];
|
1
src/Kernel/check_device2_finalizejs
Normal file
1
src/Kernel/check_device2_finalizejs
Normal file
|
@ -0,0 +1 @@
|
|||
|
1
src/Kernel/check_device2_initializejs
Normal file
1
src/Kernel/check_device2_initializejs
Normal file
|
@ -0,0 +1 @@
|
|||
|
|
@ -49,6 +49,21 @@
|
|||
"property": "finalize",
|
||||
"file": "Kernel/set_gate_message2_finalizejs"
|
||||
},
|
||||
{
|
||||
"id": "c3d88e1872a9789b",
|
||||
"property": "func",
|
||||
"file": "Kernel/check_device2.js"
|
||||
},
|
||||
{
|
||||
"id": "c3d88e1872a9789b",
|
||||
"property": "initialize",
|
||||
"file": "Kernel/check_device2_initializejs"
|
||||
},
|
||||
{
|
||||
"id": "c3d88e1872a9789b",
|
||||
"property": "finalize",
|
||||
"file": "Kernel/check_device2_finalizejs"
|
||||
},
|
||||
{
|
||||
"id": "0385dd3208b83d41",
|
||||
"property": "func",
|
||||
|
|
Loading…
Reference in a new issue