diff --git a/databases/modbus_config.js b/databases/modbus_config.js index 574de9f..b73116a 100644 --- a/databases/modbus_config.js +++ b/databases/modbus_config.js @@ -1,4 +1,5 @@ const timeoutInterval = 150000; + const deviceConfig = [ { device: "em340", @@ -110,4 +111,4 @@ const deviceConfig = [ } ]; -module.exports = { timeoutInterval, deviceConfig }; +module.exports = { timeoutInterval, deviceConfig }; \ No newline at end of file diff --git a/databases/notifications.table b/databases/notifications.table index b207fe7..a0590d3 100644 --- a/databases/notifications.table +++ b/databases/notifications.table @@ -31,4 +31,7 @@ key:string|weight:string|sk:string|en:string +|voltage_on_phase_restored|NOTICE|Napätie na fáze č. ${phase} bolo obnovené|Voltage on phase no. ${phase} has been restored|............... +|flow_start|NOTICE|FLOW bol spustený|FLOW has been started |............... +|twilight_sensor_nok|ERROR|Sensor súmraku neodpovedá|Twilight sensor is not responding|............... -+|twilight_sensor_ok|NOTICE|Sensor súmraku znovu odpovedá|Twilight sensor is responding again|............... \ No newline at end of file ++|twilight_sensor_ok|NOTICE|Sensor súmraku znovu odpovedá|Twilight sensor is responding again|............... ++|lamps_have_turned_on|NOTICE|Lampy sa zapli|Lamps have turned on|............... ++|lamps_have_turned_off|NOTICE|Lampy sa vypli|Lamps have turned off|............... ++|flow_restart|NOTICE|Restart flowu|Flow has been restarted|............... diff --git a/flow/cmd_manager.js b/flow/cmd_manager.js index 3a03acc..48b4987 100644 --- a/flow/cmd_manager.js +++ b/flow/cmd_manager.js @@ -280,30 +280,20 @@ function processNodeProfile(node) try{ nodeProfile = JSON.parse( profile ); if(Object.keys(nodeProfile).length === 0) throw ("profile is not defined"); - } catch (error) {} - - //test reset profilu - //nodeProfile = undefined; + } catch (error) { + logger.debug("Error parsing node profile", error); + } logger.debug("processNodeProfile", node, line, nodeObj, nodeProfile); - //return; - - //let timestamp = PRIORITY_TYPES.node_cmd; - - //let now = new Date(); - //now.setSeconds(now.getSeconds() + 10); - //let timestamp = now.getTime(); let timestamp = PRIORITY_TYPES.node_cmd; - //nodeProfile = undefined; removeTask({type: "set_node_profile", address: node}); cmdNOKNodeCounter[node] = 0; //co ked sa prave spracovava? //if(cmdNOKNodeCounter[params.address] < 5) saveToTb = false; - if(nodeProfile === undefined) { //vypneme profil nodu, posleme cmd @@ -318,7 +308,7 @@ function processNodeProfile(node) params.byte1 = 0; params.byte2 = 0; params.byte3 = 0; - params.byte4 = 32; + params.byte4 = 96; params.recipient = 1; params.register = 8; params.rw = 1;//write @@ -347,7 +337,7 @@ function processNodeProfile(node) params.byte1 = 0; params.byte2 = 0; params.byte3 = 0; - params.byte4 = 32; + params.byte4 = 96; params.recipient = 1; params.register = 8; params.rw = 1;//write @@ -615,7 +605,7 @@ function processNodeProfile(node) else bits.push(0); //Bit 1 - riadenie úsvitu podľa lux senzoru (1 – zapnuté). Úsvit sa môže posúvať v rámci času v registri 97 podľa intenzity osvetlenia - if(profile.dawn_lux_sensor == true)//usvit + if(nodeProfile.dawn_lux_sensor == true)//usvit { bits.push(1); } @@ -765,7 +755,7 @@ exports.install = function(instance) { if(key == "0") continue; if(line != undefined) { - //ak sa jedna o update profilu linie - pozor di_co_controller posiela command pre loadRelaysData + //ak sa jedna o update profilu linie - pozor dido_controller posiela command pre loadRelaysData if(line != value.line ) continue; } @@ -1254,28 +1244,20 @@ exports.install = function(instance) { { //run broadcast Time of dusk - // addMinutesToTimestamp = 60*5; addMinutesToTimestamp = 60 * 3; //kazde 3 hodiny zisti novy dusk let params = getParams(PRIORITY_TYPES.node_broadcast); - let recipient = 2;//2 broadcast, address = 0 - let address = 0;//0 - if(recipient === 2) - { - address = 0xffffffff;//Broadcast - } - let sunCalcResult = calculateDuskDawn(); let dusk_hours = sunCalcResult["dusk_hours"]; let dusk_minutes = sunCalcResult["dusk_minutes"]; - params.address = address;//broadcast + params.address = 0xffffffff;//broadcast params.byte1 = dusk_hours;//h params.byte2 = dusk_minutes;//m params.byte3 = 0;//s params.byte4 = 0; - params.recipient = recipient; + params.recipient = 2;//2 broadcast, params.register = 6;//Time of dusk - Reg 6 params.rw = 1;//write @@ -1300,23 +1282,16 @@ exports.install = function(instance) { let params = getParams(PRIORITY_TYPES.node_broadcast); - let recipient = 2;//2 broadcast, address = 0 - let address = 0;//0 - if(recipient === 2) - { - address = 0xffffffff;//Broadcast - } - let sunCalcResult = calculateDuskDawn(); let dawn_hours = sunCalcResult["dawn_hours"]; let dawn_minutes = sunCalcResult["dawn_minutes"]; - params.address = address;//broadcast + params.address = 0xffffffff;//broadcast params.byte1 = dawn_hours;//h params.byte2 = dawn_minutes;//m params.byte3 = 0;//s params.byte4 = 0; - params.recipient = recipient; + params.recipient = 2; //2 broadcast params.register = 7;//Time of dawn - Reg 6 params.rw = 1;//write @@ -1332,31 +1307,23 @@ exports.install = function(instance) { tasks.push(params); } - { //run broadcast //Actual time addMinutesToTimestamp = 5; let params = getParams(PRIORITY_TYPES.node_broadcast); - let recipient = 2;//2 broadcast, address = 0 - let address = 0;//0 - if(recipient === 2) - { - address = 0xffffffff;//Broadcast - } - var d = new Date(); let hours = d.getHours(); let minutes = d.getMinutes(); let seconds = d.getSeconds(); - params.address = address;//broadcast + params.address = 0xffffffff;//broadcast params.byte1 = hours;//h params.byte2 = minutes;//m params.byte3 = seconds;//s params.byte4 = 0; - params.recipient = recipient; + params.recipient = 2; //2 broadcast params.register = 87;//Actual time params.rw = 1;//write @@ -1370,37 +1337,8 @@ exports.install = function(instance) { params.info = "run broadcast: Actual time"; tasks.push(params); - } - { - //run broadcast Actual Lux level from cabinet - - //Do tohto registra posiela riadiaca jednotka hodnotu intenzity osvetlenia ktorú meria jej senzor pre potreby riadenia časov súmraku resp. úsvitu podľa intenzity osvetlenia. - //Byty 0 (LSB) a 1 obsahujú 16 bitový integer s luxami. - - let params = getParams(PRIORITY_TYPES.node_broadcast); - - addMinutesToTimestamp = 15; - - let recipient = 2;//2 broadcast, address = 0 - let address = 0;//0 - if(recipient === 2) - { - address = 0xffffffff;//Broadcast - } - - //TODO - //16 bitový integer s luxami - params.byte3 = lux_sensor; - params.byte4 = lux_sensor; - params.timestamp = PRIORITY_TYPES.node_broadcast; - params.addMinutesToTimestamp = addMinutesToTimestamp; - params.info = "run broadcast: Actual Lux level from cabinet"; - params.register = 95;//Actual Lux level from cabinet - params.rw = 1;//write - - } } //process nodes & tasks @@ -1909,7 +1847,7 @@ exports.install = function(instance) { tasks[0].timestamp = currentTimestamp + tasks[0].addMinutesToTimestamp * 60000; } - let info = "aplikovaný bod profilu"; + let info = "aplikovany bod profilu"; let message = ""; if(value == 1) { @@ -2099,8 +2037,9 @@ exports.install = function(instance) { let resp = com_generic(params.address, params.recipient, params.rw, params.register, params.name, params.byte1, params.byte2, params.byte3, params.byte4); let readBytes = 11; + let timeout = 5000; - await writeData(rsPort, resp, readBytes).then(function (data) { + await writeData(rsPort, resp, readBytes, timeout).then(function (data) { endTime = new Date(); var timeDiff = endTime - startTime; @@ -2690,8 +2629,31 @@ exports.install = function(instance) { { lux_sensor = parseInt(flowdata.data.value); - //process profiles - turnOnOffLinesAccordingToLuxSensor(lux_sensor); + // POSSIBLE SOURCE OF PROBLEMS, IF USER SETS LUX TRESHOLD LEVEL GREATER THAN 100 - WE SHOULD BE CHECKING "DUSK/DAWN_LUX_SENSOR_VALUE" IN PROFILE MAYBE ?? + if(lux_sensor < 100) + { + + // we send lux_sensor value to all nodes: + let params = getParams(PRIORITY_TYPES.node_broadcast); + + params.recipient = 2;//2 broadcast, address = 0 + params.address = 0xffffffff;//Broadcast + + let ba = longToByteArray(lux_sensor); + + params.byte3 = ba[1];//msb + params.byte4 = ba[0]; + params.timestamp = PRIORITY_TYPES.node_broadcast; + params.info = "run broadcast: Actual Lux level from cabinet"; + params.register = 95;//Actual Lux level from cabinet + params.rw = 1;//write + + tasks.push(params); + + + //process profiles + turnOnOffLinesAccordingToLuxSensor(lux_sensor); + } } else if(cmd == "state_of_breaker") { diff --git a/flow/designer.json b/flow/designer.json index 7cb3ebb..7d57d69 100644 --- a/flow/designer.json +++ b/flow/designer.json @@ -25,8 +25,8 @@ "component": "debug", "tab": "1611921777196", "name": "ERROR", - "x": 404, - "y": 36, + "x": 401, + "y": 31, "connections": {}, "disabledio": { "input": [], @@ -36,13 +36,13 @@ "text": "Enabled", "color": "gray" }, - "color": "#DA4453", - "notes": "", "options": { "type": "data", "repository": false, "enabled": true - } + }, + "color": "#DA4453", + "notes": "" }, { "id": "1612776786008", @@ -87,14 +87,14 @@ "text": "Connected", "color": "green" }, - "color": "#888600", - "notes": "", "options": { "username": "", "clientid": "", "port": "1883", "host": "" - } + }, + "color": "#888600", + "notes": "" }, { "id": "1612778461252", @@ -123,11 +123,11 @@ "text": "tb-push", "color": "gray" }, - "color": "#303E4D", - "notes": "", "options": { "wirename": "tb-push" - } + }, + "color": "#303E4D", + "notes": "" }, { "id": "1612783322136", @@ -147,13 +147,13 @@ "text": "Enabled", "color": "gray" }, - "color": "#967ADC", - "notes": "", "options": { "type": "data", "repository": false, "enabled": true - } + }, + "color": "#967ADC", + "notes": "" }, { "id": "1615551060773", @@ -173,13 +173,13 @@ "text": "Enabled", "color": "gray" }, - "color": "#DA4453", - "notes": "", "options": { "type": "data", "repository": false, "enabled": true - } + }, + "color": "#DA4453", + "notes": "" }, { "id": "1615563373927", @@ -199,13 +199,13 @@ "text": "Enabled", "color": "gray" }, - "color": "#DA4453", - "notes": "", "options": { "type": "data", "repository": false, "enabled": true - } + }, + "color": "#DA4453", + "notes": "" }, { "id": "1615566865233", @@ -223,11 +223,11 @@ "text": "tb-push", "color": "gray" }, - "color": "#303E4D", - "notes": "", "options": { "wirename": "tb-push" - } + }, + "color": "#303E4D", + "notes": "" }, { "id": "1615798582262", @@ -247,21 +247,21 @@ "text": "Enabled", "color": "gray" }, - "color": "#967ADC", - "notes": "", "options": { "type": "data", "repository": false, "enabled": true - } + }, + "color": "#967ADC", + "notes": "" }, { "id": "1615802995322", "component": "debug", "tab": "1611921777196", "name": "Debug", - "x": 400.8833312988281, - "y": 484.3500061035156, + "x": 398.8833312988281, + "y": 528.3500061035156, "connections": {}, "disabledio": { "input": [ @@ -270,24 +270,24 @@ "output": [] }, "state": { - "text": "Enabled", + "text": "Disabled", "color": "gray" }, - "color": "#967ADC", - "notes": "", "options": { "type": "data", "repository": false, - "enabled": true - } + "enabled": false + }, + "color": "#967ADC", + "notes": "" }, { "id": "1615809128443", "component": "debug", "tab": "1611921777196", "name": "Debug", - "x": 405.8833312988281, - "y": 566.3500061035156, + "x": 401.8833312988281, + "y": 625.3500061035156, "connections": {}, "disabledio": { "input": [ @@ -299,21 +299,21 @@ "text": "Enabled", "color": "gray" }, - "color": "#967ADC", - "notes": "", "options": { "type": "data", "repository": false, "enabled": true - } + }, + "color": "#967ADC", + "notes": "" }, { "id": "1615809595184", "component": "virtualwireout", "tab": "1611921777196", "name": "tb-push", - "x": 401.8833312988281, - "y": 306.25, + "x": 400.8833312988281, + "y": 328.25, "connections": {}, "disabledio": { "input": [], @@ -323,11 +323,11 @@ "text": "tb-push", "color": "gray" }, - "color": "#303E4D", - "notes": "", "options": { "wirename": "tb-push" - } + }, + "color": "#303E4D", + "notes": "" }, { "id": "1616165795916", @@ -356,9 +356,6 @@ "text": "Listening", "color": "green" }, - "color": "#5D9CEC", - "notes": "### Configuration\n\n- __POST /terminal__\n- flags: \n- maximum request data length: __5 kB__\n- empty response: __false__\n- cache policy: __no cache__\n- cache expire: __5 minutes__", - "cloning": false, "options": { "timeout": 10, "cachepolicy": 0, @@ -373,7 +370,10 @@ 10000 ], "emptyresponse": false - } + }, + "color": "#5D9CEC", + "notes": "### Configuration\n\n- __POST /terminal__\n- flags: \n- maximum request data length: __5 kB__\n- empty response: __false__\n- cache policy: __no cache__\n- cache expire: __5 minutes__", + "cloning": false }, { "id": "1616165824813", @@ -391,11 +391,11 @@ "text": "", "color": "gray" }, - "color": "#5D9CEC", - "notes": "", "options": { "datatype": "json" - } + }, + "color": "#5D9CEC", + "notes": "" }, { "id": "1617104731852", @@ -415,13 +415,13 @@ "text": "Enabled", "color": "gray" }, - "color": "#967ADC", - "notes": "", "options": { "type": "data", "repository": false, "enabled": true - } + }, + "color": "#967ADC", + "notes": "" }, { "id": "1617114651703", @@ -446,19 +446,19 @@ "text": "", "color": "gray" }, - "color": "#F6BB42", - "notes": "", "options": { "data": "{line: 3, command: \"turnOff\", force: true}", "datatype": "object" - } + }, + "color": "#F6BB42", + "notes": "" }, { "id": "1617115013095", "component": "virtualwireout", "tab": "1615551125555", "name": "tb-push", - "x": 747, + "x": 741, "y": 736, "connections": {}, "disabledio": { @@ -469,11 +469,11 @@ "text": "tb-push", "color": "gray" }, - "color": "#303E4D", - "notes": "", "options": { "wirename": "tb-push" - } + }, + "color": "#303E4D", + "notes": "" }, { "id": "1617178324650", @@ -491,13 +491,13 @@ "text": "Enabled", "color": "gray" }, - "color": "#967ADC", - "notes": "", "options": { "type": "data", "repository": false, "enabled": true - } + }, + "color": "#967ADC", + "notes": "" }, { "id": "1617179044099", @@ -522,12 +522,12 @@ "text": "", "color": "gray" }, - "color": "#F6BB42", - "notes": "", "options": { "datatype": "object", "data": "{table: \"konsberg_production_line_operations_error\", startFrom: 1, delimiter: \";\", uniqueColumn: \"\", path: \"flow/operations_error.csv\", mapImport: {0: \"production_line\",\t1: \"operation\", 2: \"error_type\", 3: \"error_code\", 4: \"error_text\", 5: \"error_text_user_defined\"}}" - } + }, + "color": "#F6BB42", + "notes": "" }, { "id": "1617180390661", @@ -552,11 +552,11 @@ "text": "", "color": "gray" }, - "color": "#2134B0", - "notes": "", "options": { "edge": "undefined" - } + }, + "color": "#2134B0", + "notes": "" }, { "id": "1617197763128", @@ -574,9 +574,9 @@ "text": "", "color": "gray" }, + "options": {}, "color": "#704cff", - "notes": "", - "options": {} + "notes": "" }, { "id": "1617284749681", @@ -601,12 +601,12 @@ "text": "", "color": "gray" }, - "color": "#F6BB42", - "notes": "", "options": { "datatype": "string", "data": "profile_nodes" - } + }, + "color": "#F6BB42", + "notes": "" }, { "id": "1618235171399", @@ -631,11 +631,11 @@ "text": "", "color": "gray" }, - "color": "#F6BB42", - "notes": "", "options": { "data": "run" - } + }, + "color": "#F6BB42", + "notes": "" }, { "id": "1618300858252", @@ -653,13 +653,13 @@ "text": "Enabled", "color": "gray" }, - "color": "#967ADC", - "notes": "", "options": { "type": "data", "repository": false, "enabled": true - } + }, + "color": "#967ADC", + "notes": "" }, { "id": "1618300863816", @@ -679,13 +679,13 @@ "text": "Enabled", "color": "gray" }, - "color": "#967ADC", - "notes": "", "options": { "type": "data", "repository": false, "enabled": true - } + }, + "color": "#967ADC", + "notes": "" }, { "id": "1618393583970", @@ -703,11 +703,11 @@ "text": "from-dido-controller", "color": "gray" }, - "color": "#303E4D", - "notes": "", "options": { "wirename": "from-dido-controller" - } + }, + "color": "#303E4D", + "notes": "" }, { "id": "1618393674428", @@ -732,11 +732,11 @@ "text": "platform-rpc-call", "color": "gray" }, - "color": "#303E4D", - "notes": "", "options": { "wirename": "platform-rpc-call" - } + }, + "color": "#303E4D", + "notes": "" }, { "id": "1618393759854", @@ -765,11 +765,11 @@ "text": "cmd_to_dido", "color": "gray" }, - "color": "#303E4D", - "notes": "", "options": { "wirename": "cmd_to_dido" - } + }, + "color": "#303E4D", + "notes": "" }, { "id": "1618393827655", @@ -787,11 +787,11 @@ "text": "cmd_to_dido", "color": "gray" }, - "color": "#303E4D", - "notes": "", "options": { "wirename": "cmd_to_dido" - } + }, + "color": "#303E4D", + "notes": "" }, { "id": "1618558465485", @@ -809,11 +809,11 @@ "text": "platform-rpc-call", "color": "gray" }, - "color": "#303E4D", - "notes": "", "options": { "wirename": "platform-rpc-call" - } + }, + "color": "#303E4D", + "notes": "" }, { "id": "1618572059773", @@ -838,12 +838,12 @@ "text": "", "color": "gray" }, - "color": "#F6BB42", - "notes": "", "options": { "datatype": "object", "data": "{line: 1, command: \"turnOn\", force: true}" - } + }, + "color": "#F6BB42", + "notes": "" }, { "id": "1619515097737", @@ -896,9 +896,9 @@ "text": "", "color": "gray" }, + "options": {}, "color": "#5D9CEC", - "notes": "", - "options": {} + "notes": "" }, { "id": "1619605019281", @@ -927,9 +927,6 @@ "text": "Listening", "color": "green" }, - "color": "#5D9CEC", - "notes": "### Configuration\n\n- __GET /db__\n- flags: undefined\n- maximum request data length: __5 kB__\n- empty response: __undefined__\n- cache policy: __no cache__\n- cache expire: __5 minutes__", - "cloning": false, "options": { "timeout": 5, "cachepolicy": 0, @@ -943,7 +940,10 @@ "get", 5000 ] - } + }, + "color": "#5D9CEC", + "notes": "### Configuration\n\n- __GET /db__\n- flags: undefined\n- maximum request data length: __5 kB__\n- empty response: __undefined__\n- cache policy: __no cache__\n- cache expire: __5 minutes__", + "cloning": false }, { "id": "1619784672383", @@ -968,12 +968,12 @@ "text": "", "color": "gray" }, - "color": "#F6BB42", - "notes": "", "options": { "data": "{command: \"turnOnAlarm\"}", "datatype": "object" - } + }, + "color": "#F6BB42", + "notes": "" }, { "id": "1619784812964", @@ -998,20 +998,20 @@ "text": "", "color": "gray" }, - "color": "#F6BB42", - "notes": "", "options": { "data": "{command: \"turnOffAlarm\"}", "datatype": "object" - } + }, + "color": "#F6BB42", + "notes": "" }, { "id": "1621340721628", "component": "virtualwireout", "tab": "1611921777196", "name": "modbus_to_dido", - "x": 403, - "y": 394, + "x": 399, + "y": 433, "connections": {}, "disabledio": { "input": [], @@ -1021,11 +1021,11 @@ "text": "modbus_to_dido", "color": "gray" }, - "color": "#303E4D", - "notes": "", "options": { "wirename": "modbus_to_dido" - } + }, + "color": "#303E4D", + "notes": "" }, { "id": "1622640022885", @@ -1050,9 +1050,6 @@ "text": "Listening", "color": "green" }, - "color": "#5D9CEC", - "notes": "### Configuration\n\n- __POST /db_connector__\n- flags: \n- maximum request data length: __5 kB__\n- empty response: __undefined__\n- cache policy: __no cache__\n- cache expire: __5 minutes__", - "cloning": false, "options": { "timeout": 5, "cachepolicy": 0, @@ -1065,7 +1062,10 @@ "post", 5000 ] - } + }, + "color": "#5D9CEC", + "notes": "### Configuration\n\n- __POST /db_connector__\n- flags: \n- maximum request data length: __5 kB__\n- empty response: __undefined__\n- cache policy: __no cache__\n- cache expire: __5 minutes__", + "cloning": false }, { "id": "1622640073521", @@ -1090,11 +1090,11 @@ "text": "", "color": "gray" }, - "color": "#2134B0", - "notes": "", "options": { "edge": "undefined" - } + }, + "color": "#2134B0", + "notes": "" }, { "id": "1622641420685", @@ -1112,9 +1112,9 @@ "text": "", "color": "gray" }, + "options": {}, "color": "#5D9CEC", - "notes": "", - "options": {} + "notes": "" }, { "id": "1634303504177", @@ -1136,15 +1136,15 @@ "output": [] }, "state": { - "text": "801.23 MB / 987.80 MB", + "text": "834.19 MB / 985.68 MB", "color": "gray" }, - "color": "#F6BB42", - "notes": "", "options": { "enabled": true, "interval": 30000 - } + }, + "color": "#F6BB42", + "notes": "" }, { "id": "1634303533779", @@ -1166,16 +1166,16 @@ "output": [] }, "state": { - "text": "5.90 GB / 7.26 GB", + "text": "5.84 GB / 7.26 GB", "color": "gray" }, - "color": "#F6BB42", - "notes": "", "options": { "enabled": true, "path": "/", "interval": 30000 - } + }, + "color": "#F6BB42", + "notes": "" }, { "id": "1634303595494", @@ -1204,11 +1204,11 @@ "text": "send-to-services", "color": "gray" }, - "color": "#303E4D", - "notes": "", "options": { "wirename": "send-to-services" - } + }, + "color": "#303E4D", + "notes": "" }, { "id": "1634303602169", @@ -1226,11 +1226,11 @@ "text": "send-to-services", "color": "gray" }, - "color": "#303E4D", - "notes": "", "options": { "wirename": "send-to-services" - } + }, + "color": "#303E4D", + "notes": "" }, { "id": "1634303685503", @@ -1248,11 +1248,11 @@ "text": "send-to-services", "color": "gray" }, - "color": "#303E4D", - "notes": "", "options": { "wirename": "send-to-services" - } + }, + "color": "#303E4D", + "notes": "" }, { "id": "1634303743260", @@ -1278,13 +1278,13 @@ "text": "", "color": "gray" }, - "color": "#5D9CEC", - "notes": "", "options": { "stringify": "json", "method": "POST", "url": "http://192.168.252.2:8004/sentmessage" - } + }, + "color": "#5D9CEC", + "notes": "" }, { "id": "1634463186563", @@ -1304,13 +1304,13 @@ "text": "Enabled", "color": "gray" }, - "color": "#967ADC", - "notes": "", "options": { "type": "data", "repository": false, "enabled": true - } + }, + "color": "#967ADC", + "notes": "" }, { "id": "1634464580289", @@ -1339,13 +1339,13 @@ "text": "", "color": "gray" }, - "color": "#656D78", - "notes": "", "options": { "keepmessage": true, "code": "let response = {};\nresponse.cpu = value.cpu;\nresponse.uptime = value.uptime;\n\nsend(0, response);", "outputs": 1 - } + }, + "color": "#656D78", + "notes": "" }, { "id": "1634465243324", @@ -1365,13 +1365,13 @@ "text": "Enabled", "color": "gray" }, - "color": "#967ADC", - "notes": "", "options": { "type": "data", "repository": false, "enabled": true - } + }, + "color": "#967ADC", + "notes": "" }, { "id": "1634465281992", @@ -1400,13 +1400,13 @@ "text": "", "color": "gray" }, - "color": "#656D78", - "notes": "", "options": { "keepmessage": true, "code": "value.sender = \"ram\";\n//let total = value.total/1024/1024;\n//let free = value.free/1024/1024;\n//let used = value.used/1024/1024;\nlet response = {};\n//value.memory_total = (total).toFixed(0) + ' MB';\n//value.memory_free = (free).toFixed(0) + ' MB';\n//value.memory_used = (used).toFixed(0) + ' MB';\n\nresponse.memory_total = value.total;\nresponse.memory_free = value.free;\nresponse.memory_used = value.used;\n\nsend(0, response);", "outputs": 1 - } + }, + "color": "#656D78", + "notes": "" }, { "id": "1634465338103", @@ -1426,13 +1426,13 @@ "text": "Enabled", "color": "gray" }, - "color": "#967ADC", - "notes": "", "options": { "type": "data", "repository": false, "enabled": true - } + }, + "color": "#967ADC", + "notes": "" }, { "id": "1634465821120", @@ -1461,13 +1461,13 @@ "text": "", "color": "gray" }, - "color": "#656D78", - "notes": "", "options": { "keepmessage": true, "code": "value.sender = \"hdd\";\n//let total = value.total/1024/1024;\n//let free = value.free/1024/1024;\n//let used = value.used/1024/1024;\nlet response = {};\n//value.hdd_total = (total).toFixed(0) + ' MB';\n//value.hdd_free = (free).toFixed(0) + ' MB';\n//value.used = (used).toFixed(0) + ' MB';\n\nresponse.hdd_total = value.total;\nresponse.hdd_free = value.free;\nresponse.hdd_used = value.used;\n\nsend(0, response);", "outputs": 1 - } + }, + "color": "#656D78", + "notes": "" }, { "id": "1634465892500", @@ -1487,13 +1487,13 @@ "text": "Enabled", "color": "gray" }, - "color": "#967ADC", - "notes": "", "options": { "type": "data", "repository": false, "enabled": true - } + }, + "color": "#967ADC", + "notes": "" }, { "id": "1634484067516", @@ -1513,13 +1513,13 @@ "text": "Enabled", "color": "gray" }, - "color": "#967ADC", - "notes": "", "options": { "type": "data", "repository": false, "enabled": true - } + }, + "color": "#967ADC", + "notes": "" }, { "id": "1634488120710", @@ -1548,11 +1548,11 @@ "text": "", "color": "gray" }, - "color": "#2134B0", - "notes": "", "options": { "edge": "undefined" - } + }, + "color": "#2134B0", + "notes": "" }, { "id": "1635327431236", @@ -1572,13 +1572,13 @@ "text": "Enabled", "color": "gray" }, - "color": "#967ADC", - "notes": "", "options": { "type": "data", "repository": false, "enabled": true - } + }, + "color": "#967ADC", + "notes": "" }, { "id": "1635936391935", @@ -1596,11 +1596,11 @@ "text": "send-to-services", "color": "gray" }, - "color": "#303E4D", - "notes": "", "options": { "wirename": "send-to-services" - } + }, + "color": "#303E4D", + "notes": "" }, { "id": "1637069803394", @@ -1622,11 +1622,9 @@ "output": [] }, "state": { - "text": "11.7% / 69.98 MB", + "text": "1.9% / 86.94 MB", "color": "gray" }, - "color": "#967ADC", - "notes": "", "options": { "monitorfiles": true, "monitorconnections": true, @@ -1634,7 +1632,9 @@ "monitorconsumption": true, "enabled": true, "interval": 30000 - } + }, + "color": "#967ADC", + "notes": "" }, { "id": "1683664161036", @@ -1654,13 +1654,13 @@ "text": "Enabled", "color": "gray" }, - "color": "#967ADC", - "notes": "", "options": { "type": "data", "repository": false, "enabled": true - } + }, + "color": "#967ADC", + "notes": "" }, { "id": "1683981346282", @@ -1689,11 +1689,11 @@ "text": "from-dido-controller", "color": "gray" }, - "color": "#303E4D", - "notes": "", "options": { "wirename": "from-dido-controller" - } + }, + "color": "#303E4D", + "notes": "" }, { "id": "1684055037116", @@ -1713,13 +1713,13 @@ "text": "Enabled", "color": "gray" }, - "color": "#967ADC", - "notes": "", "options": { "type": "data", "repository": false, "enabled": true - } + }, + "color": "#967ADC", + "notes": "" }, { "id": "1684060205000", @@ -1739,13 +1739,13 @@ "text": "Enabled", "color": "gray" }, - "color": "#967ADC", - "notes": "", "options": { "type": "data", "repository": false, "enabled": true - } + }, + "color": "#967ADC", + "notes": "" }, { "id": "1684179110403", @@ -1753,7 +1753,7 @@ "tab": "1611921777196", "name": "MDBToDido", "x": 401, - "y": 125, + "y": 118, "connections": {}, "disabledio": { "input": [], @@ -1763,13 +1763,13 @@ "text": "Enabled", "color": "gray" }, - "color": "#967ADC", - "notes": "", "options": { "type": "data", "repository": false, "enabled": true - } + }, + "color": "#967ADC", + "notes": "" }, { "id": "1699963668903", @@ -1810,11 +1810,11 @@ "text": "", "color": "gray" }, - "color": "#2134B0", - "notes": "", "options": { "edge": "undefined" - } + }, + "color": "#2134B0", + "notes": "" }, { "id": "1699964678894", @@ -1843,11 +1843,11 @@ "text": "modbus_to_dido", "color": "gray" }, - "color": "#303E4D", - "notes": "", "options": { "wirename": "modbus_to_dido" - } + }, + "color": "#303E4D", + "notes": "" }, { "id": "1699964793925", @@ -1867,13 +1867,13 @@ "text": "Enabled", "color": "gray" }, - "color": "#967ADC", - "notes": "", "options": { "type": "data", "repository": false, "enabled": true - } + }, + "color": "#967ADC", + "notes": "" }, { "id": "1699965957410", @@ -1897,6 +1897,10 @@ { "index": "0", "id": "1684179110403" + }, + { + "index": "0", + "id": "1717441414646" } ], "2": [ @@ -1918,17 +1922,17 @@ "text": "", "color": "gray" }, + "options": {}, "color": "#2134B0", - "notes": "", - "options": {} + "notes": "" }, { "id": "1700411878636", "component": "thermometer", "tab": "1611921777196", "name": "Thermometer", - "x": 103.75, - "y": 408, + "x": 107.75, + "y": 449, "connections": { "0": [ { @@ -1961,9 +1965,9 @@ "text": "", "color": "gray" }, + "options": {}, "color": "#5CB36D", - "notes": "", - "options": {} + "notes": "" }, { "id": "1714752862828", @@ -1971,7 +1975,7 @@ "tab": "1611921777196", "name": "MDBToTb", "x": 402, - "y": 215, + "y": 228, "connections": {}, "disabledio": { "input": [], @@ -1981,14 +1985,248 @@ "text": "Enabled", "color": "gray" }, - "color": "#967ADC", - "notes": "", "options": { "type": "data", "repository": false, "enabled": true - } + }, + "color": "#967ADC", + "notes": "" + }, + { + "id": "1717441414646", + "component": "code", + "tab": "1611921777196", + "name": "device-status", + "x": 588.0833282470703, + "y": 177, + "connections": { + "0": [ + { + "index": "0", + "id": "1717442627834" + }, + { + "index": "0", + "id": "1717442631338" + } + ] + }, + "disabledio": { + "input": [], + "output": [] + }, + "state": { + "text": "", + "color": "gray" + }, + "options": { + "keepmessage": true, + "code": "if(value.hasOwnProperty(\"status\"))\n{\n\tif(value.status.includes(\"-em\"))\n\t{\n\t\tsend(0, {\"em_status\": \"NOK\"});\n\t}\n\telse if(value.status.includes(\"twilight\"))\n\t{\n\t\tsend(0, {\"lux_sensor\": \"NOK\"});\n\t}\n}\n\nif(value.hasOwnProperty(\"values\"))\n{\n\tif(value.values.hasOwnProperty(\"twilight_sensor\"))\n\t{\n\t\tsend(0, {\"lux_sensor\": \"OK\"});\n\t}\n\telse if(value.values.hasOwnProperty(\"Phase_1_power\") ||\n\t\t\tvalue.values.hasOwnProperty(\"Phase_1_voltage\") ||\n\t\t\tvalue.values.hasOwnProperty(\"Total_power\") ||\n\t\t\tvalue.values.hasOwnProperty(\"Phase_1_current\"))\n\t{\n\t\tsend(0, {\"em_status\": \"OK\"});\n\t}\n}", + "outputs": 1 + }, + "color": "#656D78", + "notes": "" + }, + { + "id": "1717442627834", + "component": "debug", + "tab": "1611921777196", + "name": "modbus service", + "x": 802.0833282470703, + "y": 139, + "connections": {}, + "disabledio": { + "input": [ + 0 + ], + "output": [] + }, + "state": { + "text": "Enabled", + "color": "gray" + }, + "options": { + "type": "data", + "repository": false, + "enabled": true + }, + "color": "#967ADC", + "notes": "" + }, + { + "id": "1717442631338", + "component": "virtualwireout", + "tab": "1611921777196", + "name": "send-to-services", + "x": 801.0833282470703, + "y": 236, + "connections": {}, + "disabledio": { + "input": [], + "output": [] + }, + "state": { + "text": "send-to-services", + "color": "gray" + }, + "options": { + "wirename": "send-to-services" + }, + "color": "#303E4D", + "notes": "" + }, + { + "id": "1718016045116", + "component": "virtualwirein", + "tab": "1612772287426", + "name": "tb-push", + "x": 84.75, + "y": 1300, + "connections": { + "0": [ + { + "index": "0", + "id": "1718016052341" + } + ] + }, + "disabledio": { + "input": [], + "output": [] + }, + "state": { + "text": "tb-push", + "color": "gray" + }, + "options": { + "wirename": "tb-push" + }, + "color": "#303E4D", + "notes": "" + }, + { + "id": "1718016052341", + "component": "slack_filter", + "tab": "1612772287426", + "name": "Slack Filter", + "x": 278, + "y": 1297, + "connections": { + "0": [ + { + "index": "0", + "id": "1718016086212" + }, + { + "index": "0", + "id": "1718016073501" + } + ] + }, + "disabledio": { + "input": [], + "output": [] + }, + "state": { + "text": "Running", + "color": "gray" + }, + "options": { + "slack_channel": "C071KN2Q8SK", + "tag_on_include": "[{\"user_id\":\"U072JE5JUQG\", \"includes\":[\"Electrometer\", \"Twilight sensor\"]}]", + "message_includes": "[\"is responding again\", \"Lamps have turned\", \"Flow has been restarted\"]", + "types": "[\"emergency\", \"critical\", \"error\", \"alert\"]", + "name": "RVO16 Senica - 10.0.0.131" + }, + "color": "#30E193", + "notes": "" + }, + { + "id": "1718016073501", + "component": "httprequest", + "tab": "1612772287426", + "name": "http://192.168.252.2:8004/slack", + "x": 471, + "y": 1354, + "connections": { + "0": [ + { + "index": "0", + "id": "1718016086212" + } + ] + }, + "disabledio": { + "input": [], + "output": [] + }, + "state": { + "text": "", + "color": "gray" + }, + "options": { + "stringify": "json", + "method": "POST", + "url": "http://192.168.252.2:8004/slack" + }, + "color": "#5D9CEC", + "notes": "" + }, + { + "id": "1718016086212", + "component": "debug", + "tab": "1612772287426", + "name": "Debug", + "x": 808, + "y": 1302, + "connections": {}, + "disabledio": { + "input": [], + "output": [] + }, + "state": { + "text": "Enabled", + "color": "gray" + }, + "options": { + "type": "data", + "repository": false, + "enabled": true + }, + "color": "#967ADC", + "notes": "" + }, + { + "id": "1718016094070", + "component": "trigger", + "tab": "1612772287426", + "name": "Trigger", + "x": 73, + "y": 1388, + "connections": { + "0": [ + { + "index": "0", + "id": "1718016052341" + } + ] + }, + "disabledio": { + "input": [], + "output": [] + }, + "state": { + "text": "", + "color": "gray" + }, + "options": { + "datatype": "object", + "data": "{ \"g9OxBZ5KRwNznlY6pAppqEAWXvjdEL4eGQobMDy2\": [ { \"ts\": 1716289039281, \"values\": { \"_event\": { \"type\": \"alert\", \"status\": \"new\", \"source\": { \"func\": \"CMD Manager: process cmd\", \"component\": \"1619515097737\", \"component_name\": \"CMD Manager\", \"edge\": \"g9OxBZ5KRwNznlY6pAppqEAWXvjdEL4eGQobMDy2\" }, \"message\": \"NOW CONNECTED TO SLACK !\", \"message_data\": \"\" } } } ] }" + }, + "color": "#F6BB42", + "notes": "" } ], - "version": 618 + "version": 615 } \ No newline at end of file diff --git a/flow/dido_controller.js b/flow/dido_controller.js index 0952350..b429b14 100644 --- a/flow/dido_controller.js +++ b/flow/dido_controller.js @@ -11,11 +11,11 @@ exports.icon = 'bolt'; exports.options = { edge: "undefined" }; exports.html = `