diff --git a/cloud_topic.py b/cloud_topic.py
new file mode 100644
index 0000000..77c31f1
--- /dev/null
+++ b/cloud_topic.py
@@ -0,0 +1,76 @@
+# import os
+#
+# def modify_file(file_path):
+# """
+# Modifies the given file by:
+# 1. Appending "|cloud_topic" to the first line.
+# 2. Inserting the text from the third "." to the first "|" on the second line after the last "|" character.
+#
+# Args:
+# file_path (str): The path to the file to be modified.
+# """
+#
+# with open(file_path, 'r+') as f:
+# lines = f.readlines()
+#
+# # Modify the first line
+# lines[0] += "|cloud_topic:string"
+#
+# # Modify the second line
+# second_line = lines[1].strip() # Remove leading/trailing whitespace
+# first_pipe_index = second_line.find('|')
+# third_dot_index = second_line.find('.', second_line.find('.', second_line.find('.') + 1) + 1)
+# text_to_insert = second_line[third_dot_index:first_pipe_index]
+#
+# last_pipe_index = second_line.rfind('|')
+# lines[1] = second_line[:last_pipe_index + 1] + text_to_insert + "|" + second_line[last_pipe_index + 1:]
+#
+# print(first_pipe_index, third_dot_index, text_to_insert, last_pipe_index)
+# # Write the modified lines back to the file
+# # f.seek(0)
+# # f.writelines(lines)
+# # f.truncate()
+#
+# # Example usage:
+# file_path = "settings.table" # Replace with the actual file path
+# modify_file(file_path)
+#
+
+
+def modify_file(file_path):
+ """
+ Modifies the given file by:
+ 1. Appending "|cloud_topic" to the first line.
+ 2. Inserting the text between the third "." and the second "|" on the second line after the last "|" character.
+
+ Args:
+ file_path (str): The path to the file to be modified.
+ """
+
+ with open(file_path, 'r+') as f:
+ lines = f.readlines()
+
+ first_line = lines[0].strip()
+ first_line += "|cloud_topic:string\n"
+ # Modify the first line
+ lines[0] = first_line
+
+ # Modify the second line
+ second_line = lines[1].strip() # Remove leading/trailing whitespace
+ first_pipe_index = second_line.find('|')
+ second_pipe_index = second_line.find('|', first_pipe_index + 1)
+ third_dot_index = second_line.find('.', second_line.find('.', second_line.find('.') + 1) + 1)
+ text_to_insert = "u" + second_line[third_dot_index+1:second_pipe_index]
+
+ last_pipe_index = second_line.rfind('|')
+ lines[1] = second_line[:last_pipe_index + 1] + text_to_insert + "|" + second_line[last_pipe_index + 1:]
+
+ print(first_pipe_index, third_dot_index, text_to_insert, last_pipe_index)
+ # Write the modified lines back to the file
+ f.seek(0)
+ f.writelines(lines)
+ f.truncate()
+
+# Example usage:
+file_path = "/home/unipi/flowserver/databases/settings.table" # Replace with the actual file path
+modify_file(file_path)
diff --git a/config b/config
index 25ee651..6913e51 100644
--- a/config
+++ b/config
@@ -7,6 +7,6 @@ package#flow (Object) : { url: '/' }
table.relays : line:number|tbname:string|contactor:number|profile:string
table.nodes : node:number|tbname:string|line:number|profile:string|processed:boolean|status:boolean|time_of_last_communication:number
-table.settings : rvo_name:string|lang:string|temperature_address:string|latitude:number|longitude:number|mqtt_host:string|mqtt_clientid:string|mqtt_username:string|mqtt_port:number|maintanace_mode:boolean|project_id:number|controller_type:string|serial_port:string|backup_on_failure:boolean|restore_from_backup:number|restore_backup_wait:number|node_status_nok_time:number|phases:number
+table.settings : rvo_name:string|lang:string|temperature_address:string|latitude:number|longitude:number|mqtt_host:string|mqtt_clientid:string|mqtt_username:string|mqtt_port:number|maintanace_mode:boolean|project_id:number|controller_type:string|serial_port:string|backup_on_failure:boolean|restore_from_backup:number|restore_backup_wait:number|node_status_nok_time:number|phases:number|cloud_topic:string
table.pins : pin:string|type:string|line:number
table.notifications : key:string|weight:string|sk:string|en:string
diff --git a/databases/settings.table b/databases/settings.table
index b7ec7d6..0aec6b3 100644
--- a/databases/settings.table
+++ b/databases/settings.table
@@ -1,2 +1,2 @@
-rvo_name:string|lang:string|temperature_address:string|latitude:number|longitude:number|mqtt_host:string|mqtt_clientid:string|mqtt_username:string|mqtt_port:number|maintanace_mode:boolean|project_id:number|controller_type:string|serial_port:string|backup_on_failure:boolean|restore_from_backup:number|restore_backup_wait:number|node_status_nok_time:number|phases:number
-+|rvo_senica_42_10.0.0.118|en|28.427B45920702|48.70826502|17.28455203|192.168.252.1|rvo_senica_42_10.0.0.118|QMvF7etEvbYMMr8Q6baP|1883|0|59|unipi|ttyUSB0|1|20|5|6|3|..............
+rvo_name:string|lang:string|temperature_address:string|latitude:number|longitude:number|mqtt_host:string|mqtt_clientid:string|mqtt_username:string|mqtt_port:number|maintanace_mode:boolean|project_id:number|controller_type:string|serial_port:string|backup_on_failure:boolean|restore_from_backup:number|restore_backup_wait:number|node_status_nok_time:number|phases:number|cloud_topic:string
++|rvo_senica_22_ip10.0.0.109|en|28.F46E9D0E0000|48.70826502|17.28455203|192.168.252.1|rvo_senica_22_ip10.0.0.109|9excvr7yBcF3gl3kYZGY|1883|0|48|unipi|ttyUSB0|1|20|5|6|3|u109|...........................................
diff --git a/flow/cloudmqttconnect.js b/flow/cloudmqttconnect.js
index 79bc04e..85acfdc 100644
--- a/flow/cloudmqttconnect.js
+++ b/flow/cloudmqttconnect.js
@@ -4,7 +4,7 @@ exports.group = 'MQTT';
exports.color = '#888600';
exports.version = '1.0.2';
exports.icon = 'sign-out';
-exports.input = 1;
+exports.input = 2;
exports.output = 2;
exports.options = { host: 'tb-stage.worksys.io', port: 1883, clientid: "", username: "" };
@@ -22,7 +22,7 @@ exports.html = `
`;
@@ -77,6 +77,8 @@ exports.install = function(instance) {
{
o = instance.options;
+ if(!o.topic) o.topic = FLOW.GLOBALS.settings.cloud_topic;
+
opts = {
host: o.host,
port: o.port,
@@ -86,8 +88,7 @@ exports.install = function(instance) {
resubscribe: false
};
-
- console.log("wsmqttpublich -> loadSettings from instance.options", instance.options);
+ console.log("wsmqttpublich -> loadSettings from instance.options",o);
connectToTbServer();
}
@@ -212,6 +213,9 @@ exports.install = function(instance) {
}
});
+ instance.on("1", _ => {
+ main();
+ })
instance.close = function(done) {
if(clientReady){
@@ -399,6 +403,5 @@ exports.install = function(instance) {
}
instance.on('options', main);
- main();
};
diff --git a/flow/cmd_manager.js b/flow/cmd_manager.js
index ed4a928..255f48e 100644
--- a/flow/cmd_manager.js
+++ b/flow/cmd_manager.js
@@ -1451,7 +1451,7 @@ exports.install = function(instance) {
if (!rsPort.isOpen) {
instance.send(SEND_TO.debug, "!rsPort.isOpen");
//await rsPort.open();
- console.log("Cmd_manager - !rsPort.isOpen");
+ //console.log("Cmd_manager - !rsPort.isOpen");
}
let currentTask = tasks[0];
diff --git a/flow/db_init.js b/flow/db_init.js
index cf3b5a7..76408c8 100644
--- a/flow/db_init.js
+++ b/flow/db_init.js
@@ -84,6 +84,7 @@ exports.install = async function(instance) {
mqtt_username : responseSettings[0]["mqtt_username"],
mqtt_port : responseSettings[0]["mqtt_port"],
phases: responseSettings[0]["phases"],
+ cloud_topic: responseSettings[0]["cloud_topic"],
//dynamic values
masterNodeIsResponding : true, //cmd_manager
diff --git a/flow/designer.json b/flow/designer.json
index 455b37a..2223c18 100644
--- a/flow/designer.json
+++ b/flow/designer.json
@@ -82,6 +82,10 @@
{
"index": "0",
"id": "1731068754606"
+ },
+ {
+ "index": "0",
+ "id": "1733574445563"
}
]
},
@@ -449,8 +453,8 @@
"color": "gray"
},
"options": {
- "data": "{line: 3, command: \"turnOff\", force: true}",
- "datatype": "object"
+ "datatype": "object",
+ "data": "{line: 3, command: \"turnOff\", force: true}"
},
"color": "#F6BB42",
"notes": ""
@@ -477,116 +481,13 @@
"color": "#303E4D",
"notes": ""
},
- {
- "id": "1617178324650",
- "component": "debug",
- "tab": "1615551125555",
- "name": "Debug",
- "x": 700,
- "y": 1495,
- "connections": {},
- "disabledio": {
- "input": [],
- "output": []
- },
- "state": {
- "text": "Enabled",
- "color": "gray"
- },
- "options": {
- "type": "data",
- "repository": false,
- "enabled": true
- },
- "color": "#967ADC",
- "notes": ""
- },
- {
- "id": "1617179044099",
- "component": "trigger",
- "tab": "1615551125555",
- "name": "start import",
- "x": 330,
- "y": 1503,
- "connections": {
- "0": [
- {
- "index": "0",
- "id": "1617180390661"
- }
- ]
- },
- "disabledio": {
- "input": [],
- "output": []
- },
- "state": {
- "text": "",
- "color": "gray"
- },
- "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",
- "component": "csv_import",
- "tab": "1615551125555",
- "name": "CsvImport",
- "x": 509,
- "y": 1484,
- "connections": {
- "0": [
- {
- "index": "0",
- "id": "1617178324650"
- }
- ]
- },
- "disabledio": {
- "input": [],
- "output": []
- },
- "state": {
- "text": "",
- "color": "gray"
- },
- "options": {
- "edge": "undefined"
- },
- "color": "#2134B0",
- "notes": ""
- },
- {
- "id": "1617197763128",
- "component": "comment",
- "tab": "1615551125555",
- "name": "import data from csv",
- "x": 496,
- "y": 1417,
- "connections": {},
- "disabledio": {
- "input": [],
- "output": []
- },
- "state": {
- "text": "",
- "color": "gray"
- },
- "options": {},
- "color": "#704cff",
- "notes": ""
- },
{
"id": "1617284749681",
"component": "trigger",
"tab": "1615551125555",
"name": "update profile / node",
- "x": 122,
- "y": 209,
+ "x": 112,
+ "y": 215,
"connections": {
"0": [
{
@@ -604,8 +505,8 @@
"color": "gray"
},
"options": {
- "datatype": "string",
- "data": "profile_nodes"
+ "data": "profile_nodes",
+ "datatype": "string"
},
"color": "#F6BB42",
"notes": ""
@@ -841,8 +742,8 @@
"color": "gray"
},
"options": {
- "datatype": "object",
- "data": "{line: 1, command: \"turnOn\", force: true}"
+ "data": "{line: 1, command: \"turnOn\", force: true}",
+ "datatype": "object"
},
"color": "#F6BB42",
"notes": ""
@@ -852,8 +753,8 @@
"component": "cmd_manager",
"tab": "1615551125555",
"name": "CMD Manager",
- "x": 448.1091003417969,
- "y": 351.05455017089844,
+ "x": 452.1091003417969,
+ "y": 341.05455017089844,
"connections": {
"0": [
{
@@ -971,8 +872,8 @@
"color": "gray"
},
"options": {
- "data": "{command: \"turnOnAlarm\"}",
- "datatype": "object"
+ "datatype": "object",
+ "data": "{command: \"turnOnAlarm\"}"
},
"color": "#F6BB42",
"notes": ""
@@ -1001,8 +902,8 @@
"color": "gray"
},
"options": {
- "data": "{command: \"turnOffAlarm\"}",
- "datatype": "object"
+ "datatype": "object",
+ "data": "{command: \"turnOffAlarm\"}"
},
"color": "#F6BB42",
"notes": ""
@@ -1034,8 +935,8 @@
"component": "httproute",
"tab": "1615551125555",
"name": "POST /db_connector",
- "x": 1107,
- "y": 338,
+ "x": 98,
+ "y": 1586,
"connections": {
"0": [
{
@@ -1074,8 +975,8 @@
"component": "db_connector",
"tab": "1615551125555",
"name": "DbConnector",
- "x": 1363,
- "y": 395,
+ "x": 372,
+ "y": 1572,
"connections": {
"1": [
{
@@ -1103,8 +1004,8 @@
"component": "httpresponse",
"tab": "1615551125555",
"name": "HTTP Response",
- "x": 1588,
- "y": 454,
+ "x": 596,
+ "y": 1586,
"connections": {},
"disabledio": {
"input": [],
@@ -1123,8 +1024,8 @@
"component": "monitormemory",
"tab": "1612772287426",
"name": "RAM",
- "x": 77.88333129882812,
- "y": 703.5,
+ "x": 69.88333129882812,
+ "y": 885.5,
"connections": {
"0": [
{
@@ -1138,7 +1039,7 @@
"output": []
},
"state": {
- "text": "846.37 MB / 985.68 MB",
+ "text": "848.02 MB / 985.68 MB",
"color": "gray"
},
"options": {
@@ -1153,8 +1054,8 @@
"component": "monitordisk",
"tab": "1612772287426",
"name": "disk",
- "x": 78.88333129882812,
- "y": 800.5,
+ "x": 70.88333129882812,
+ "y": 982.5,
"connections": {
"0": [
{
@@ -1184,8 +1085,8 @@
"component": "virtualwirein",
"tab": "1612772287426",
"name": "send-to-services",
- "x": 38.883331298828125,
- "y": 1220.5,
+ "x": 51.883331298828125,
+ "y": 1400.5,
"connections": {
"0": [
{
@@ -1217,8 +1118,8 @@
"component": "virtualwireout",
"tab": "1612772287426",
"name": "send-to-services",
- "x": 434.8833312988281,
- "y": 696.5,
+ "x": 426.8833312988281,
+ "y": 878.5,
"connections": {},
"disabledio": {
"input": [],
@@ -1262,8 +1163,8 @@
"tab": "1612772287426",
"name": "192.168.252.2:8004/sentmessage",
"reference": "",
- "x": 467.8833312988281,
- "y": 1154.7333374023438,
+ "x": 480.8833312988281,
+ "y": 1334.7333374023438,
"connections": {
"0": [
{
@@ -1281,9 +1182,9 @@
"color": "gray"
},
"options": {
- "stringify": "json",
+ "url": "http://192.168.252.2:8004/sentmessage",
"method": "POST",
- "url": "http://192.168.252.2:8004/sentmessage"
+ "stringify": "json"
},
"color": "#5D9CEC",
"notes": ""
@@ -1293,8 +1194,8 @@
"component": "debug",
"tab": "1612772287426",
"name": "Debug",
- "x": 267.75,
- "y": 1266,
+ "x": 280.75,
+ "y": 1446,
"connections": {},
"disabledio": {
"input": [
@@ -1319,8 +1220,8 @@
"component": "code",
"tab": "1612772287426",
"name": "Code",
- "x": 261,
- "y": 606,
+ "x": 253,
+ "y": 788,
"connections": {
"0": [
{
@@ -1354,8 +1255,8 @@
"component": "debug",
"tab": "1612772287426",
"name": "Debug",
- "x": 436,
- "y": 602,
+ "x": 428,
+ "y": 784,
"connections": {},
"disabledio": {
"input": [
@@ -1380,8 +1281,8 @@
"component": "code",
"tab": "1612772287426",
"name": "Code",
- "x": 250,
- "y": 702,
+ "x": 242,
+ "y": 884,
"connections": {
"0": [
{
@@ -1415,8 +1316,8 @@
"component": "debug",
"tab": "1612772287426",
"name": "Debug",
- "x": 437,
- "y": 794,
+ "x": 429,
+ "y": 976,
"connections": {},
"disabledio": {
"input": [
@@ -1441,8 +1342,8 @@
"component": "code",
"tab": "1612772287426",
"name": "Code",
- "x": 253,
- "y": 796,
+ "x": 245,
+ "y": 978,
"connections": {
"0": [
{
@@ -1476,8 +1377,8 @@
"component": "debug",
"tab": "1612772287426",
"name": "Debug",
- "x": 440,
- "y": 886,
+ "x": 432,
+ "y": 1068,
"connections": {},
"disabledio": {
"input": [
@@ -1502,8 +1403,8 @@
"component": "debug",
"tab": "1612772287426",
"name": "Send info",
- "x": 467,
- "y": 1261,
+ "x": 480,
+ "y": 1441,
"connections": {},
"disabledio": {
"input": [
@@ -1528,8 +1429,8 @@
"component": "infosender",
"tab": "1612772287426",
"name": "Info sender",
- "x": 272,
- "y": 1158,
+ "x": 285,
+ "y": 1338,
"connections": {
"0": [
{
@@ -1561,8 +1462,8 @@
"component": "debug",
"tab": "1612772287426",
"name": "Debug",
- "x": 782.8833312988281,
- "y": 1149.5,
+ "x": 795.8833312988281,
+ "y": 1329.5,
"connections": {},
"disabledio": {
"input": [
@@ -1609,8 +1510,8 @@
"component": "monitorconsumption",
"tab": "1612772287426",
"name": "CPU",
- "x": 77,
- "y": 609,
+ "x": 69,
+ "y": 791,
"connections": {
"0": [
{
@@ -1624,7 +1525,7 @@
"output": []
},
"state": {
- "text": "6.2% / 70.96 MB",
+ "text": "0.5% / 88.03 MB",
"color": "gray"
},
"options": {
@@ -2087,8 +1988,8 @@
"component": "virtualwirein",
"tab": "1612772287426",
"name": "tb-push",
- "x": 64.75,
- "y": 1450,
+ "x": 77.75,
+ "y": 1630,
"connections": {
"0": [
{
@@ -2116,8 +2017,8 @@
"component": "slack_filter",
"tab": "1612772287426",
"name": "Slack Filter",
- "x": 283,
- "y": 1491,
+ "x": 296,
+ "y": 1671,
"connections": {
"0": [
{
@@ -2143,7 +2044,7 @@
"tag_on_include": "[{\"user_id\":\"U072JE5JUQG\", \"includes\":[\"Electrometer\", \"Twilight sensor\"]}]",
"message_includes": "[\"is responding again\", \"Lamps have turned\", \"Flow has been restarted\", \"Node db has changed\"]",
"types": "[\"emergency\", \"critical\", \"error\", \"alert\"]",
- "name": "rvo_senica_46_10.0.0.133"
+ "name": "rvo_senica_1_10.0.0.141"
},
"color": "#30E193",
"notes": ""
@@ -2153,8 +2054,8 @@
"component": "httprequest",
"tab": "1612772287426",
"name": "http://192.168.252.2:8004/slack",
- "x": 482,
- "y": 1573,
+ "x": 495,
+ "y": 1753,
"connections": {
"0": [
{
@@ -2172,9 +2073,9 @@
"color": "gray"
},
"options": {
- "stringify": "json",
+ "url": "http://192.168.252.2:8004/slack",
"method": "POST",
- "url": "http://192.168.252.2:8004/slack"
+ "stringify": "json"
},
"color": "#5D9CEC",
"notes": ""
@@ -2184,8 +2085,8 @@
"component": "debug",
"tab": "1612772287426",
"name": "Debug",
- "x": 819,
- "y": 1484,
+ "x": 832,
+ "y": 1664,
"connections": {},
"disabledio": {
"input": [
@@ -2210,8 +2111,8 @@
"component": "trigger",
"tab": "1612772287426",
"name": "Trigger",
- "x": 66,
- "y": 1543,
+ "x": 79,
+ "y": 1723,
"connections": {
"0": [
{
@@ -2229,8 +2130,8 @@
"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\": \"\" } } } ] }"
+ "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\": \"\" } } } ] }",
+ "datatype": "object"
},
"color": "#F6BB42",
"notes": ""
@@ -2240,8 +2141,8 @@
"component": "virtualwireout",
"tab": "1612772287426",
"name": "platform-rpc-call",
- "x": 1058.933334350586,
- "y": 488.3500061035156,
+ "x": 1062.933334350586,
+ "y": 532.3500061035156,
"connections": {},
"disabledio": {
"input": [],
@@ -2262,8 +2163,8 @@
"component": "debug",
"tab": "1612772287426",
"name": "rpc cloud",
- "x": 1066.933334350586,
- "y": 393.3500061035156,
+ "x": 1063.933334350586,
+ "y": 442.3500061035156,
"connections": {},
"disabledio": {
"input": [],
@@ -2315,8 +2216,8 @@
"component": "cloudmqttconnect",
"tab": "1612772287426",
"name": "MQTT client - to senica-prod01",
- "x": 739.75,
- "y": 434,
+ "x": 742.75,
+ "y": 520,
"connections": {
"1": [
{
@@ -2338,11 +2239,11 @@
"color": "green"
},
"options": {
- "username": "",
- "clientid": "",
- "port": "2764",
"host": "192.168.252.2",
- "topic": "u133"
+ "port": "2764",
+ "clientid": "",
+ "username": "",
+ "topic": ""
},
"color": "#888600",
"notes": ""
@@ -2401,8 +2302,8 @@
"component": "showdb",
"tab": "1612772287426",
"name": "Show db data",
- "x": 1076.75,
- "y": 745.25,
+ "x": 1121.75,
+ "y": 814.25,
"connections": {
"0": [
{
@@ -2428,8 +2329,8 @@
"component": "debug",
"tab": "1612772287426",
"name": "dbData",
- "x": 1270.75,
- "y": 784.25,
+ "x": 1315.75,
+ "y": 853.25,
"connections": {},
"disabledio": {
"input": [],
@@ -2452,8 +2353,8 @@
"component": "trigger",
"tab": "1612772287426",
"name": "settings",
- "x": 863.75,
- "y": 622.75,
+ "x": 911.75,
+ "y": 710.75,
"connections": {
"0": [
{
@@ -2479,8 +2380,8 @@
"component": "trigger",
"tab": "1612772287426",
"name": "relaysData",
- "x": 800.75,
- "y": 684.75,
+ "x": 832.75,
+ "y": 775.75,
"connections": {
"0": [
{
@@ -2506,8 +2407,8 @@
"component": "trigger",
"tab": "1612772287426",
"name": "nodesData",
- "x": 693.75,
- "y": 749.75,
+ "x": 747.75,
+ "y": 840.75,
"connections": {
"0": [
{
@@ -2533,8 +2434,8 @@
"component": "trigger",
"tab": "1612772287426",
"name": "pinsData",
- "x": 755.75,
- "y": 802.75,
+ "x": 803.75,
+ "y": 899.75,
"connections": {
"0": [
{
@@ -2560,8 +2461,8 @@
"component": "trigger",
"tab": "1612772287426",
"name": "sample data",
- "x": 812.75,
- "y": 856.75,
+ "x": 858.75,
+ "y": 959.75,
"connections": {
"0": [
{
@@ -2587,8 +2488,8 @@
"component": "virtualwirein",
"tab": "1612772287426",
"name": "db-init",
- "x": 50.75,
- "y": 1099,
+ "x": 63.75,
+ "y": 1279,
"connections": {
"0": [
{
@@ -2616,8 +2517,8 @@
"component": "virtualwirein",
"tab": "1615551125555",
"name": "db-init",
- "x": 184.88333129882812,
- "y": 129,
+ "x": 151.88333129882812,
+ "y": 148,
"connections": {
"0": [
{
@@ -2732,8 +2633,8 @@
"component": "trigger",
"tab": "1612772287426",
"name": "monitor.txt",
- "x": 865.75,
- "y": 911.75,
+ "x": 915.75,
+ "y": 1017.75,
"connections": {
"0": [
{
@@ -2759,8 +2660,8 @@
"component": "trigger",
"tab": "1612772287426",
"name": "err.txt",
- "x": 921.75,
- "y": 968.75,
+ "x": 966.75,
+ "y": 1080.75,
"connections": {
"0": [
{
@@ -2786,8 +2687,8 @@
"component": "nodesdb_change_check",
"tab": "1612772287426",
"name": "Nodes DB change check",
- "x": 250.88333129882812,
- "y": 1813.2333984375,
+ "x": 263.8833312988281,
+ "y": 1993.2333984375,
"connections": {
"0": [
{
@@ -2817,8 +2718,8 @@
"component": "virtualwirein",
"tab": "1612772287426",
"name": "db-init",
- "x": 71.75,
- "y": 1814,
+ "x": 84.75,
+ "y": 1994,
"connections": {
"0": [
{
@@ -2846,8 +2747,8 @@
"component": "debug",
"tab": "1612772287426",
"name": "nodesChange",
- "x": 548.8833312988281,
- "y": 1875.2333984375,
+ "x": 561.8833312988281,
+ "y": 2055.2333984375,
"connections": {},
"disabledio": {
"input": [],
@@ -2870,8 +2771,8 @@
"component": "virtualwireout",
"tab": "1612772287426",
"name": "tb-push",
- "x": 544.8833312988281,
- "y": 1769,
+ "x": 557.8833312988281,
+ "y": 1949,
"connections": {},
"disabledio": {
"input": [],
@@ -2910,7 +2811,62 @@
},
"color": "#967ADC",
"notes": ""
+ },
+ {
+ "id": "1733574412965",
+ "component": "virtualwirein",
+ "tab": "1612772287426",
+ "name": "db-init",
+ "x": 557.75,
+ "y": 574,
+ "connections": {
+ "0": [
+ {
+ "index": "1",
+ "id": "1731068754606"
+ }
+ ]
+ },
+ "disabledio": {
+ "input": [],
+ "output": []
+ },
+ "state": {
+ "text": "db-init",
+ "color": "gray"
+ },
+ "options": {
+ "wirename": "db-init"
+ },
+ "color": "#303E4D",
+ "notes": ""
+ },
+ {
+ "id": "1733574445563",
+ "component": "debug",
+ "tab": "1612772287426",
+ "name": "toCloudRado",
+ "x": 740.75,
+ "y": 435,
+ "connections": {},
+ "disabledio": {
+ "input": [
+ 0
+ ],
+ "output": []
+ },
+ "state": {
+ "text": "Enabled",
+ "color": "gray"
+ },
+ "options": {
+ "type": "data",
+ "repository": false,
+ "enabled": true
+ },
+ "color": "#967ADC",
+ "notes": ""
}
],
"version": 615
-}
\ No newline at end of file
+}
diff --git a/flow/helper/ErrorToServiceHandler.js b/flow/helper/ErrorToServiceHandler.js
index 97ee9d4..110ea8b 100644
--- a/flow/helper/ErrorToServiceHandler.js
+++ b/flow/helper/ErrorToServiceHandler.js
@@ -97,7 +97,9 @@ class ErrorToServiceHandler
console.log("ErrorToServiceHandler------------------------>send to service", dataToInfoSender);
//TODO UGLY!!!
- if(this.projects_id === undefined) this.projects_id = FLOW.GLOBALS.settings.project_id;
+ // if error occures too early FLOW.GLOBALs.settings.project_id is still undefined
+ // if(this.projects_id === undefined) this.projects_id = FLOW.GLOBALS.settings.project_id;
+ if(this.projects_id === undefined) return;
/*
if(this.projects_id === undefined)
diff --git a/flow/slack_connector.js b/flow/slack_connector.js
deleted file mode 100644
index 8c073a6..0000000
--- a/flow/slack_connector.js
+++ /dev/null
@@ -1,124 +0,0 @@
-exports.id = 'slack_connector';
-exports.title = 'Slack_Connector';
-exports.version = '1.0.0';
-exports.group = 'Worksys';
-exports.color = '#888600';
-exports.input = 1;
-exports.output = 1;
-exports.click = false;
-exports.author = 'Jakub Klena';
-exports.icon = 'sign-out';
-exports.options = { slack_channel: "C071KN2Q8SK", api_key: "", bot_name: "Flow DEMO", bot_icon: ":totaljs:" };
-// Slack channel - where to post the messages, can be name like "backend-alerts"
-// Bot Name - Name of the "user" that will post these messages, it should be based on which server it is running on.
-// Bot Icon - We can use any slack icon (even custom ones uploaded by us) as the "user" profile picture
-
-exports.html = ``;
-
-exports.readme = `Sends any string received on input to Slack Channel.`;
-
-var log4js = require("log4js");
-var path = require('path');
-
-log4js.configure({
- appenders: {
- errLogs: { type: 'file', compress:true, daysToKeep: 2, maxLogSize: 1048576, backups: 1, keepFileExt: true, filename: path.join(__dirname + "/../", 'err.txt') },
- monitorLogs: { type: 'file', compress:true, daysToKeep: 2, maxLogSize: 1048576, backups: 1, keepFileExt: true, filename: path.join(__dirname + "/../", 'monitor.txt') },
- console: { type: 'console' }
- },
- categories: {
- errLogs: { appenders: ['console', 'errLogs'], level: 'error' },
- monitorLogs: { appenders: ['console', 'monitorLogs'], level: 'trace' },
- //another: { appenders: ['console'], level: 'trace' },
- default: { appenders: ['console'], level: 'trace' }
- }
-});
-
-const errLogger = log4js.getLogger("errLogs");
-const logger = log4js.getLogger();
-const monitor = log4js.getLogger("monitorLogs");
-
-exports.install = function(instance) {
- var can = false;
-
- process.on('uncaughtException', function (err) {
- errLogger.error('uncaughtException:', err.message);
- errLogger.error(err.stack);
- instance.error(err);
- });
-
- instance.on('data', function(data) {
- if (!can) return;
-
- let str = String(data.data); // Ensuring data get converted to string
- let message = {
- 'channel': instance.options.slack_channel,
- 'username': instance.options.bot_name,
- 'icon_emoji': instance.options.bot_icon,
- 'text': str
- };
- let headers = {
- 'Content-type': `application/json`,
- 'Authorization': `Bearer ${instance.options.api_key}`
- };
-
- if (F.is4) {
- let opt = {
- 'method': 'post',
- 'url': 'https://slack.com/api/chat.postMessage',
- 'headers': headers,
- 'body': JSON.stringify(message),
- 'type': 'json',
- 'callback': function(err, response) {
- if (response && !err) {
- var msg = { data: response.body, status: response.status, headers: response.headers, host: response.host, cookies: response.cookies };
- instance.send2(msg);
- } else if (err) {
- errLogger.error('Slack post failed - err:', err, '\n - response was:', response);
- instance.error(err, response);
- }
- }
- };
- REQUEST(opt);
-
- } else {
- U.request('https://slack.com/api/chat.postMessage', ['json', 'post'], JSON.stringify(message), function(err, data, status, headers, host) {
- if (response && !err) {
- response.data = { data: data, status: status, headers: headers, host: host };
- instance.send2(response);
- } else if (err) {
- errLogger.error('Slack post failed - err:', err, '\n - response was:', response);
- instance.error(err, response);
- }
- }, null, headers);
- }
- });
-
- instance.reconfigure = function() {
- var options = instance.options;
- can = options.slack_channel && options.bot_name && options.bot_icon && options.api_key ? true : false;
- instance.status(can ? '' : 'Not configured', can ? undefined : 'red');
- };
-
- instance.on('options', instance.reconfigure);
- instance.reconfigure();
-}
diff --git a/flow/thermometer.js b/flow/thermometer.js
index 0be7eff..fa015c6 100644
--- a/flow/thermometer.js
+++ b/flow/thermometer.js
@@ -68,7 +68,7 @@ exports.install = function(instance) {
const parseData = function(data) {
data = parseFloat(data);
- logger.debug("Thermometer", data);
+ //logger.debug("Thermometer", data);
if(isNaN(data)) {
errLogger.error("Thermometer sends invalid data");