Stability is not sufficient. The connection gets lost from time to time.
Added a watchdog to add another connection, if no messages arrives.
Seems, that this is only interesting for me. If I get no feedback I will stop spaming this thread.
[{"id":"ba386057.845d3","type":"mqtt-broker","broker":"192.168.92.4","port":"1883","clientid":"NodeRed"},{"id":"e6ce260d.1931d8","type":"switch","z":"9592163f.6a6de8","name":"switch message type","property":"messageType","rules":[{"t":"eq","v":"0"},{"t":"eq","v":"1"},{"t":"eq","v":"2"},{"t":"eq","v":"3"},{"t":"eq","v":"4"}],"checkall":"true","outputs":5,"x":1259.166648864746,"y":182.50001335144043,"wires":[["8c663d73.7399c"],["4a1e5f84.b5e1a"],["7753f9a2.88ac08"],["1e4aa61b.e1b55a"],["60a0dde4.9f5f24"]]},{"id":"8c663d73.7399c","type":"function","z":"9592163f.6a6de8","name":"presentation","func":"msg.subTypeString = context.global.MYS.SString(msg.subType);\n\nmsg.topic = context.global.MYS.TOPIC_PREFIX + '/' + msg.controller + \"/\" + msg.nodeId + \"/\" + msg.childSensorId + \"/\" + msg.subTypeString;\n\nreturn msg;","outputs":1,"noerr":0,"x":1488.916648864746,"y":45.24998474121094,"wires":[["df9e131d.2061f","4d15a037.b2ea6"]]},{"id":"7753f9a2.88ac08","type":"function","z":"9592163f.6a6de8","name":"req","func":"msg.topic = \"req\";\nreturn msg;","outputs":1,"noerr":0,"x":1484.5000228881836,"y":182.75000190734863,"wires":[["4d15a037.b2ea6"]]},{"id":"1e4aa61b.e1b55a","type":"function","z":"9592163f.6a6de8","name":"internal","func":"msg.subTypeString = context.global.MYS.IString(msg.subType);\n\nmsg.topic = context.global.MYS.TOPIC_PREFIX + '/' + msg.controller + \"/\" + msg.nodeId + \"/\" + msg.childSensorId + \"/\" + msg.subTypeString;\n\nreturn msg;","outputs":1,"noerr":0,"x":1488.5000228881836,"y":233.00000190734863,"wires":[["df9e131d.2061f","4d15a037.b2ea6","b5e4f17d.4a1b1"]]},{"id":"60a0dde4.9f5f24","type":"function","z":"9592163f.6a6de8","name":"stream","func":"msg.topic = \"stream\";\nreturn msg;","outputs":1,"x":1496.5000228881836,"y":328.00000190734863,"wires":[[]]},{"id":"4d15a037.b2ea6","type":"debug","z":"9592163f.6a6de8","name":"debug","active":false,"console":"false","complete":"true","x":1845.7500267028809,"y":242.00000286102295,"wires":[]},{"id":"4a1e5f84.b5e1a","type":"function","z":"9592163f.6a6de8","name":"set","func":"msg.subTypeString = context.global.MYS.VString(msg.subType);\n\nmsg.topic = context.global.MYS.TOPIC_PREFIX + '/' + msg.controller + \"/\" + msg.nodeId + \"/\" + msg.childSensorId + \"/\" + msg.subTypeString;\n\n\nreturn msg;","outputs":1,"noerr":0,"x":1492.166648864746,"y":107.5,"wires":[["4d15a037.b2ea6","df9e131d.2061f"]]},{"id":"fc54bb91.03ab48","type":"debug","z":"9592163f.6a6de8","name":"","active":false,"console":"false","complete":"true","x":1218.9166259765625,"y":41.66668510437012,"wires":[]},{"id":"6aa2d9f6.955d28","type":"function","z":"9592163f.6a6de8","name":"Split GW Message","func":"\n var tokens = msg.payload.split(\";\")\n \n msg.rawData = tokens;\n if(tokens.length >= 6)\n {\n msg.nodeId = parseInt(tokens[0]);\n msg.childSensorId = parseInt(tokens[1]);\n msg.messageType = parseInt(tokens[2]);\n msg.ack = parseInt(tokens[3]);\n msg.subType = parseInt(tokens[4]);\n msg.payload = tokens[5];\n for (j=6; j<tokens.length; j++) \n msg.payload = msg.payload + ';' + tokens[j];\n }\n\nreturn msg;","outputs":1,"noerr":0,"x":1023.6666488647461,"y":180.66664123535156,"wires":[["e6ce260d.1931d8","fc54bb91.03ab48","e0e76d62.1f189"]]},{"id":"df9e131d.2061f","type":"mqtt out","z":"9592163f.6a6de8","name":"Publish to MQTT","topic":"","qos":"","retain":"","broker":"ba386057.845d3","x":1858.9166526794434,"y":181.16665649414062,"wires":[]},{"id":"b5e4f17d.4a1b1","type":"function","z":"9592163f.6a6de8","name":"hanlde internal messages","func":"//msg.subTypeString = \"\";\n//msg.topic = \"internal respones\";\n\nif (msg.subTypeString == 'I_TIME')\n{\n var payload = parseInt(new Date().getTime()/1000);\n\tvar command = context.global.MYS.T_INTERNAL; \n\tvar acknowledge = 0; // no ack\n\tvar type = context.global.MYS.I_TIME; // I_TIME\n\tmsg.payload = context.global.MYS.encode(msg.nodeId, msg.childSensorId, command, acknowledge, type, payload);\n return msg;\n \n}\nelse if (msg.subTypeString == 'I_ID_REQUEST')\n{\n msg.topic = \"I_ID_RESPONSE\";\n msg.subTypeString = \"I_ID_RESPONSE\";\n // 255;255;3;0;4;8 for ID 8\n var command = context.global.MYS.T_INTERNAL;\n\tvar acknowledge = 0; // no ack\n\tvar type = context.global.MYS.I_ID_RESPONSE; // I_ID_RESPONSE\n\n\tif (context.global.mysnextid[msg.controller] === undefined) {\n\t payload = context.global.MYS.MIN_NODEID;\n\t} \n\telse\n\t{\n\t payload = context.global.mysnextid[msg.controller];\n\t}\n\t\n msg.payload = context.global.MYS.encode(msg.nodeId, msg.childSensorId, command, acknowledge, type, payload);\n return msg; \n} \nelse if (msg.subTypeString == 'I_CONFIG')\n{\n var payload = 'M';\n\tvar command = context.global.MYS.T_INTERNAL; \n\tvar acknowledge = 0; // no ack\n\tvar type = context.global.MYS.I_CONFIG; // I_TIME\n\tmsg.payload = context.global.MYS.encode(msg.nodeId, msg.childSensorId, command, acknowledge, type, payload);\n return msg;\n}\nelse if (msg.subTypeString == 'I_INCLUSION_MODE')\n{\n // not yet implemented\n}\n\nreturn;\n\n\n","outputs":1,"noerr":0,"x":1694.916648864746,"y":543.4166889190674,"wires":[["4d15a037.b2ea6","266b87b3.d99478"]]},{"id":"e6d67f33.19298","type":"inject","z":"9592163f.6a6de8","name":"Startup","topic":"","payload":"","payloadType":"none","repeat":"","crontab":"","once":true,"x":145.25,"y":81.41665363311768,"wires":[["64617800.9b9e88","56b9f6ab.a94608","3e866f6d.c1799"]]},{"id":"ebcef3df.14311","type":"function","z":"9592163f.6a6de8","name":"ToString","func":"msg.payload = msg.payload.toString().replace(/[\\n\\r]/g, '');\n\nreturn msg;","outputs":1,"noerr":0,"x":829.1666946411133,"y":181.91668796539307,"wires":[["6aa2d9f6.955d28"]]},{"id":"31047fa6.cefb8","type":"catch","z":"9592163f.6a6de8","name":"","x":58,"y":449,"wires":[["3622f9b9.c9dd06"]]},{"id":"3622f9b9.c9dd06","type":"debug","z":"9592163f.6a6de8","name":"","active":false,"console":"false","complete":"true","x":224,"y":450,"wires":[]},{"id":"64617800.9b9e88","type":"function","z":"9592163f.6a6de8","name":"MYS Initialize","func":"function MySHelper() { \n\nMySHelper.prototype.TOPIC_PREFIX = \"MYS-NODERED\";\n\nMySHelper.prototype.MIN_NODEID = 10;\n\n\n// don't touch below :)\n \nMySHelper.prototype.T_PRESENTATION = 0;\nMySHelper.prototype.T_SET = 1;\nMySHelper.prototype.T_REQ = 2;\nMySHelper.prototype.T_INTERNAL = 3;\nMySHelper.prototype.T_STREAM = 4;\n\nMySHelper.prototype.I_BATTERY_LEVEL = 0;\nMySHelper.prototype.I_TIME = 1;\nMySHelper.prototype.I_VERSION = 2;\nMySHelper.prototype.I_ID_REQUEST = 3;\nMySHelper.prototype.I_ID_RESPONSE = 4;\nMySHelper.prototype.I_INCLUSION_MODE = 5;\nMySHelper.prototype.I_CONFIG = 6;\nMySHelper.prototype.I_PING = 7;\nMySHelper.prototype.I_PING_ACK = 8;\nMySHelper.prototype.I_LOG_MESSAGE = 9;\nMySHelper.prototype.I_CHILDREN = 10;\nMySHelper.prototype.I_SKETCH_NAME = 11;\nMySHelper.prototype.I_SKETCH_VERSION = 12;\nMySHelper.prototype.I_REBOOT = 13;\nMySHelper.prototype.I_GATEWAY_READY = 14;\nMySHelper.prototype.I_REQUEST_SIGNING = 15;\nMySHelper.prototype.I_GET_NONCE = 16;\nMySHelper.prototype.I_GET_NONCE_RESPONSE = 17;\nMySHelper.prototype.I_HEARTBEAT = 18;\nMySHelper.prototype.I_PRESENTATION = 19;\n \nvar itype = {\nI_BATTERY_LEVEL: MySHelper.prototype.I_BATTERY_LEVEL,\nI_TIME: MySHelper.prototype.I_TIME,\nI_VERSION: MySHelper.prototype.I_VERSION,\nI_ID_REQUEST: MySHelper.prototype.I_ID_REQUEST,\nI_ID_RESPONSE: MySHelper.prototype.I_ID_RESPONSE,\nI_INCLUSION_MODE: MySHelper.prototype.I_INCLUSION_MODE,\nI_CONFIG: MySHelper.prototype.I_CONFIG,\nI_PING: MySHelper.prototype.I_PING,\nI_PING_ACK: MySHelper.prototype.I_PING_ACK,\nI_LOG_MESSAGE: MySHelper.prototype.I_LOG_MESSAGE,\nI_CHILDREN: MySHelper.prototype.I_CHILDREN,\nI_SKETCH_NAME: MySHelper.prototype.I_SKETCH_NAME,\nI_SKETCH_VERSION: MySHelper.prototype.I_SKETCH_VERSION,\nI_REBOOT: MySHelper.prototype.I_REBOOT,\nI_GATEWAY_READY: MySHelper.prototype.I_GATEWAY_READY,\nI_REQUEST_SIGNING: MySHelper.prototype.I_REQUEST_SIGNING,\nI_GET_NONCE: MySHelper.prototype.I_GET_NONCE,\nI_GET_NONCE_RESPONSE: MySHelper.prototype.I_GET_NONCE_RESPONSE,\nI_HEARTBEAT: MySHelper.prototype.I_HEARTBEAT,\nI_PRESENTATION: MySHelper.prototype.I_PRESENTATION\n};\n\nMySHelper.prototype.IString = function(I_SUBTYPE) {\n for (var prop in itype ) \n if( itype[ prop ] === parseInt(I_SUBTYPE) )\n return prop;\n};\n\nMySHelper.prototype.V_TEMP = 0;\nMySHelper.prototype.V_HUM = 1;\nMySHelper.prototype.V_LIGHT = 2;\nMySHelper.prototype.V_STATUS = 2;\nMySHelper.prototype.V_DIMMER = 3;\nMySHelper.prototype.V_PRESSURE = 4;\nMySHelper.prototype.V_FORECAST = 5;\nMySHelper.prototype.V_RAIN = 6;\nMySHelper.prototype.V_RAINRATE = 7;\nMySHelper.prototype.V_WIND = 8;\nMySHelper.prototype.V_GUST = 9;\nMySHelper.prototype.V_DIRECTION = 10;\nMySHelper.prototype.V_UV = 11;\nMySHelper.prototype.V_WEIGHT = 12;\nMySHelper.prototype.V_DISTANCE = 13;\nMySHelper.prototype.V_IMPEDANCE = 14;\nMySHelper.prototype.V_ARMED = 15;\nMySHelper.prototype.V_TRIPPED = 16;\nMySHelper.prototype.V_WATT = 17;\nMySHelper.prototype.V_KWH = 18;\nMySHelper.prototype.V_SCENE_ON = 19;\nMySHelper.prototype.V_SCENE_OFF = 20;\nMySHelper.prototype.V_HEATER = 21;\nMySHelper.prototype.V_HEATER_SW = 22;\nMySHelper.prototype.V_LIGHT_LEVEL = 23;\nMySHelper.prototype.V_VAR1 = 24;\nMySHelper.prototype.V_VAR2 = 25;\nMySHelper.prototype.V_VAR3 = 26;\nMySHelper.prototype.V_VAR4 = 27;\nMySHelper.prototype.V_VAR5 = 28;\nMySHelper.prototype.V_UP = 29;\nMySHelper.prototype.V_DOWN = 30;\nMySHelper.prototype.V_STOP = 31;\nMySHelper.prototype.V_IR_SEND = 32;\nMySHelper.prototype.V_IR_RECEIVE = 33;\nMySHelper.prototype.V_FLOW = 34;\nMySHelper.prototype.V_VOLUME = 35;\nMySHelper.prototype.V_LOCK_STATUS = 36;\nMySHelper.prototype.V_LEVEL = 37; \nMySHelper.prototype.V_VOLTAGE = 38; \nMySHelper.prototype.V_CURRENT = 39; \nMySHelper.prototype.V_RGB = 40; \nMySHelper.prototype.V_RGBW = 41;\nMySHelper.prototype.V_ID = 42;\nMySHelper.prototype.V_UNIT_PREFIX = 43;\nMySHelper.prototype.V_HVAC_SETPOINT_COOL = 44;\nMySHelper.prototype.V_HVAC_SETPOINT_HEAT = 45;\nMySHelper.prototype.V_HVAC_FLOW_MODE = 46;\nMySHelper.prototype.V_TEXT = 47;\n\nvar vtype = {\nV_TEMP: MySHelper.prototype.V_TEMP,\nV_HUM: MySHelper.prototype.V_HUM,\nV_STATUS: MySHelper.prototype.V_STATUS,\nV_LIGHT: MySHelper.prototype.V_LIGHT,\nV_DIMMER: MySHelper.prototype.V_DIMMER,\nV_PRESSURE: MySHelper.prototype.V_PRESSURE,\nV_FORECAST: MySHelper.prototype.V_FORECAST,\nV_RAIN: MySHelper.prototype.V_RAIN,\nV_RAINRATE: MySHelper.prototype.V_RAINRATE,\nV_WIND: MySHelper.prototype.V_WIND,\nV_GUST: MySHelper.prototype.V_GUST,\nV_DIRECTION: MySHelper.prototype.V_DIRECTION,\nV_UV: MySHelper.prototype.V_UV,\nV_WEIGHT: MySHelper.prototype.V_WEIGHT,\nV_DISTANCE: MySHelper.prototype.V_DISTANCE,\nV_IMPEDANCE: MySHelper.prototype.V_IMPEDANCE,\nV_ARMED: MySHelper.prototype.V_ARMED,\nV_TRIPPED: MySHelper.prototype.V_TRIPPED,\nV_WATT: MySHelper.prototype.V_WATT,\nV_KWH: MySHelper.prototype.V_KWH,\nV_SCENE_ON: MySHelper.prototype.V_SCENE_ON,\nV_SCENE_OFF: MySHelper.prototype.V_SCENE_OFF,\nV_HEATER: MySHelper.prototype.V_HEATER,\nV_HEATER_SW: MySHelper.prototype.V_HEATER_SW,\nV_LIGHT_LEVEL: MySHelper.prototype.V_LIGHT_LEVEL,\nV_VAR1: MySHelper.prototype.V_VAR1,\nV_VAR2: MySHelper.prototype.V_VAR2,\nV_VAR3: MySHelper.prototype.V_VAR3,\nV_VAR4: MySHelper.prototype.V_VAR4,\nV_VAR5: MySHelper.prototype.V_VAR5,\nV_UP: MySHelper.prototype.V_UP,\nV_DOWN: MySHelper.prototype.V_DOWN,\nV_STOP: MySHelper.prototype.V_STOP,\nV_IR_SEND: MySHelper.prototype.V_IR_SEND,\nV_IR_RECEIVE: MySHelper.prototype.V_IR_RECEIVE,\nV_FLOW: MySHelper.prototype.V_FLOW,\nV_VOLUME: MySHelper.prototype.V_VOLUME,\nV_LOCK_STATUS: MySHelper.prototype.V_LOCK_STATUS,\nV_LEVEL: MySHelper.prototype.V_LEVEL,\nV_VOLTAGE: MySHelper.prototype.V_VOLTAGE, \nV_CURRENT: MySHelper.prototype.V_CURRENT,\nV_RGB: MySHelper.prototype.V_RGB,\nV_RGBW: MySHelper.prototype.V_RGBW,\nV_ID: MySHelper.prototype.V_ID,\nV_UNIT_PREFIX: MySHelper.prototype.V_UNIT_PREFIX,\nV_HVAC_SETPOINT_COOL:MySHelper.prototype.V_HVAC_SETPOINT_COOL,\nV_HVAC_SETPOINT_HEAT:MySHelper.prototype.V_HVAC_SETPOINT_HEAT,\nV_HVAC_FLOW_MODE: MySHelper.prototype.V_HVAC_FLOW_MODE,\nV_TEXT: MySHelper.prototype.V_TEXT\n};\n\n\n\nMySHelper.prototype.VString = function(V_SUBTYPE) {\n for (var prop in vtype ) \n if( vtype[ prop ] === parseInt(V_SUBTYPE) )\n return prop;\n};\n \nMySHelper.prototype.VNum = function(V_SUBTYPE) {\n sRet = vtype [V_SUBTYPE];\n if (sRet === undefined)\n sRet = V_SUBTYPE;\n return sRet;\n}\n\nMySHelper.prototype.S_DOOR = 0; // Door sensor; V_TRIPPED; V_ARMED\nMySHelper.prototype.S_MOTION = 1; // Motion sensor; V_TRIPPED; V_ARMED \nMySHelper.prototype.S_SMOKE = 2; // Smoke sensor; V_TRIPPED; V_ARMED\nMySHelper.prototype.S_LIGHT = 3; // Binary light or relay; V_STATUS (or V_LIGHT); V_WATT\nMySHelper.prototype.S_BINARY = 3; // Binary light or relay; V_STATUS (or V_LIGHT); V_WATT (same as MySHelper.prototype.S_LIGHT)\nMySHelper.prototype.S_DIMMER = 4; // Dimmable light or fan device; V_STATUS (on/off); V_DIMMER (dimmer level 0-100); V_WATT\nMySHelper.prototype.S_COVER = 5; // Blinds or window cover; V_UP; V_DOWN; V_STOP; V_DIMMER (open/close to a percentage)\nMySHelper.prototype.S_TEMP = 6; // Temperature sensor; V_TEMP\nMySHelper.prototype.S_HUM = 7; // Humidity sensor; V_HUM\nMySHelper.prototype.S_BARO = 8; // Barometer sensor; V_PRESSURE; V_FORECAST\nMySHelper.prototype.S_WIND = 9; // Wind sensor; V_WIND; V_GUST\nMySHelper.prototype.S_RAIN = 10; // Rain sensor; V_RAIN; V_RAINRATE\nMySHelper.prototype.S_UV = 11; // Uv sensor; V_UV\nMySHelper.prototype.S_WEIGHT = 12; // Personal scale sensor; V_WEIGHT; V_IMPEDANCE\nMySHelper.prototype.S_POWER = 13; // Power meter; V_WATT; V_KWH\nMySHelper.prototype.S_HEATER = 14; // Header device; V_HVAC_SETPOINT_HEAT; V_HVAC_FLOW_STATE; V_TEMP\nMySHelper.prototype.S_DISTANCE = 15; // Distance sensor; V_DISTANCE\nMySHelper.prototype.S_LIGHT_LEVEL = 16; // Light level sensor; V_LIGHT_LEVEL (uncalibrated in percentage); V_LEVEL (light level in lux)\nMySHelper.prototype.S_ARDUINO_NODE = 17 ; // Used (internally) for presenting a non-repeating Arduino node\nMySHelper.prototype.S_ARDUINO_REPEATER_NODE = 18; // Used (internally) for presenting a repeating Arduino node \nMySHelper.prototype.S_LOCK = 19; // Lock device; V_LOCK_STATUS\nMySHelper.prototype.S_IR = 20; // Ir device; V_IR_SEND; V_IR_RECEIVE\nMySHelper.prototype.S_WATER = 21; // Water meter; V_FLOW; V_VOLUME\nMySHelper.prototype.S_AIR_QUALITY = 22; // Air quality sensor; V_LEVEL\nMySHelper.prototype.S_CUSTOM = 23; // Custom sensor \nMySHelper.prototype.S_DUST = 24; // Dust sensor; V_LEVEL\nMySHelper.prototype.S_SCENE_CONTROLLER = 25; // Scene controller device; V_SCENE_ON; V_SCENE_OFF. \nMySHelper.prototype.S_RGB_LIGHT = 26; // RGB light. Send color component data using V_RGB. Also supports V_WATT \nMySHelper.prototype.S_RGBW_LIGHT = 27; // RGB light with an additional White component. Send data using V_RGBW. Also supports V_WATT\nMySHelper.prototype.S_COLOR_SENSOR = 28; // Color sensor; send color information using V_RGB\nMySHelper.prototype.S_HVAC = 28; // Thermostat/HVAC device. V_HVAC_SETPOINT_HEAT; V_HVAC_SETPOINT_COLD; V_HVAC_FLOW_STATE; V_HVAC_FLOW_MODE; V_TEMP\nMySHelper.prototype.S_MULTIMETER = 29; // Multimeter device; V_VOLTAGE; V_CURRENT; V_IMPEDANCE \nMySHelper.prototype.S_SPRINKLER = 30; // Sprinkler; V_STATUS (turn on/off); V_TRIPPED (if fire detecting device)\nMySHelper.prototype.S_WATER_LEAK = 31; // Water leak sensor; V_TRIPPED; V_ARMED\nMySHelper.prototype.S_SOUND = 32; // Sound sensor; V_TRIPPED; V_ARMED; V_LEVEL (sound level in dB)\nMySHelper.prototype.S_VIBRATION = 33; // Vibration sensor; V_TRIPPED; V_ARMED; V_LEVEL (vibration in Hz)\nMySHelper.prototype.S_MOISTURE = 34; // Moisture sensor; V_TRIPPED; V_ARMED; V_LEVEL (water content or moisture in percentage?) \nMySHelper.prototype.S_INFO = 35; // LCD text device / Simple information device on controller; V_TEXT\nMySHelper.prototype.S_GAS = 36; // Gas meter; V_FLOW; V_VOLUME\nMySHelper.prototype.S_GPS = 37; // GPS Sensor; V_POSITION\n \nvar stype = {\nS_DOOR: MySHelper.prototype.S_DOOR, // Door sensor; V_TRIPPED; V_ARMED\nS_MOTION: MySHelper.prototype.S_MOTION, // Motion sensor; V_TRIPPED; V_ARMED \nS_SMOKE: MySHelper.prototype.S_SMOKE, // Smoke sensor; V_TRIPPED; V_ARMED\nS_LIGHT: MySHelper.prototype.S_LIGHT, // Binary light or relay; V_STATUS (or V_LIGHT); V_WATT\nS_BINARY: MySHelper.prototype.S_BINARY, // Binary light or relay; V_STATUS (or V_LIGHT); V_WATT (same as MySHelper.prototype.S_LIGHT)\nS_DIMMER: MySHelper.prototype.S_DIMMER, // Dimmable light or fan device; V_STATUS (on/off); V_DIMMER (dimmer level 0-100); V_WATT\nS_COVER: MySHelper.prototype.S_COVER, // Blinds or window cover; V_UP; V_DOWN; V_STOP; V_DIMMER (open/close to a percentage)\nS_TEMP: MySHelper.prototype.S_TEMP, // Temperature sensor; V_TEMP\nS_HUM: MySHelper.prototype.S_HUM, // Humidity sensor; V_HUM\nS_BARO: MySHelper.prototype.S_BARO, // Barometer sensor; V_PRESSURE; V_FORECAST\nS_WIND: MySHelper.prototype.S_WIND, // Wind sensor; V_WIND; V_GUST\nS_RAIN: MySHelper.prototype.S_RAIN, // Rain sensor; V_RAIN; V_RAINRATE\nS_UV: MySHelper.prototype.S_UV, // Uv sensor; V_UV\nS_WEIGHT: MySHelper.prototype.S_WEIGHT, // Personal scale sensor; V_WEIGHT; V_IMPEDANCE\nS_POWER: MySHelper.prototype.S_POWER, // Power meter; V_WATT; V_KWH\nS_HEATER: MySHelper.prototype.S_HEATER, // Header device; V_HVAC_SETPOINT_HEAT; V_HVAC_FLOW_STATE; V_TEMP\nS_DISTANCE: MySHelper.prototype.S_DISTANCE, // Distance sensor; V_DISTANCE\nS_LIGHT_LEVEL: MySHelper.prototype.S_LIGHT_LEVEL, // Light level sensor; V_LIGHT_LEVEL (uncalibrated in percentage); V_LEVEL (light level in lux)\nS_ARDUINO_NODE: MySHelper.prototype.S_ARDUINO_NODE, // Used (internally) for presenting a non-repeating Arduino node\nS_ARDUINO_REPEATER_NODE:MySHelper.prototype.S_ARDUINO_REPEATER_NODE, // Used (internally) for presenting a repeating Arduino node \nS_LOCK: MySHelper.prototype.S_LOCK, // Lock device; V_LOCK_STATUS\nS_IR: MySHelper.prototype.S_IR, // Ir device; V_IR_SEND; V_IR_RECEIVE\nS_WATER: MySHelper.prototype.S_WATER, // Water meter; V_FLOW; V_VOLUME\nS_AIR_QUALITY: MySHelper.prototype.S_AIR_QUALITY, // Air quality sensor; V_LEVEL\nS_CUSTOM: MySHelper.prototype.S_CUSTOM, // Custom sensor \nS_DUST: MySHelper.prototype.S_DUST, // Dust sensor; V_LEVEL\nS_SCENE_CONTROLLER: MySHelper.prototype.S_SCENE_CONTROLLER, // Scene controller device; V_SCENE_ON; V_SCENE_OFF. \nS_RGB_LIGHT: MySHelper.prototype.S_RGB_LIGHT, // RGB light. Send color component data using V_RGB. Also supports V_WATT \nS_RGBW_LIGHT: MySHelper.prototype.S_RGBW_LIGHT, // RGB light with an additional White component. Send data using V_RGBW. Also supports V_WATT\nS_COLOR_SENSOR: MySHelper.prototype.S_COLOR_SENSOR, // Color sensor; send color information using V_RGB\nS_HVAC: MySHelper.prototype.S_HVAC, // Thermostat/HVAC device. V_HVAC_SETPOINT_HEAT; V_HVAC_SETPOINT_COLD; V_HVAC_FLOW_STATE; V_HVAC_FLOW_MODE; V_TEMP\nS_MULTIMETER: MySHelper.prototype.S_MULTIMETER, // Multimeter device; V_VOLTAGE; V_CURRENT; V_IMPEDANCE \nS_SPRINKLER: MySHelper.prototype.S_SPRINKLER, // Sprinkler; V_STATUS (turn on/off); V_TRIPPED (if fire detecting device)\nS_WATER_LEAK: MySHelper.prototype.S_WATER_LEAK, // Water leak sensor; V_TRIPPED; V_ARMED\nS_SOUND: MySHelper.prototype.S_SOUND, // Sound sensor; V_TRIPPED; V_ARMED; V_LEVEL (sound level in dB)\nS_VIBRATION: MySHelper.prototype.S_VIBRATION, // Vibration sensor; V_TRIPPED; V_ARMED; V_LEVEL (vibration in Hz)\nS_MOISTURE: MySHelper.prototype.S_MOISTURE, // Moisture sensor; V_TRIPPED; V_ARMED; V_LEVEL (water content or moisture in percentage?) \nS_INFO: MySHelper.prototype.S_INFO, // LCD text device / Simple information device on controller; V_TEXT\nS_GAS: MySHelper.prototype.S_GAS, // Gas meter; V_FLOW; V_VOLUME\nS_GPS: MySHelper.prototype.S_GPS // GPS Sensor; V_POSITION\n};\n\nMySHelper.prototype.SString = function(S_SUBTYPE) {\n for (var prop in stype ) \n if( stype[ prop ] === parseInt(S_SUBTYPE) )\n return prop;\n}; \n \n MySHelper.prototype.encode = function(destination, sensor, command, acknowledge, type, payload) {\n\tvar msg = destination.toString(10) + \";\" + sensor.toString(10) + \";\" + command.toString(10) + \";\" + acknowledge.toString(10) + \";\" + type.toString(10) + \";\";\n\tif (command == 4) {\n\t\tfor (var i = 0; i < payload.length; i++) {\n\t\t\tif (payload[i] < 16)\n\t\t\t\tmsg += \"0\";\n\t\t\tmsg += payload[i].toString(16);\n\t\t}\n\t} else {\n\t\tmsg += payload;\n\t}\n\tmsg += '\\n';\n\treturn msg.toString();\n}\n}\n\n\nvar MySHelperObj = new MySHelper();\n\ncontext.global.MYS = MySHelperObj;\n\nreturn msg;","outputs":1,"noerr":0,"x":383.25,"y":20,"wires":[[]]},{"id":"df1e322.f20e1d","type":"function","z":"9592163f.6a6de8","name":"Set Controller 1","func":"msg.controller = 1\n\nreturn msg;","outputs":1,"noerr":0,"x":641.0000076293945,"y":147.49999809265137,"wires":[["ebcef3df.14311"]]},{"id":"266b87b3.d99478","type":"switch","z":"9592163f.6a6de8","name":"route to controller n","property":"controller","rules":[{"t":"eq","v":"1"},{"t":"eq","v":"2"},{"t":"eq","v":"3"},{"t":"eq","v":"4"}],"checkall":"false","outputs":4,"x":133,"y":214.25,"wires":[["3e866f6d.c1799"],["c7d0d88b.382f28"],[],[]]},{"id":"c7d0d88b.382f28","type":"tcp request","z":"9592163f.6a6de8","server":"192.168.92.14","port":"5003","out":"sit","splitc":"0","name":"MySWifi ESP8266 GW AES 14","x":410.5,"y":207.24999618530273,"wires":[["c5f14d8f.3a0eb"]]},{"id":"c5f14d8f.3a0eb","type":"function","z":"9592163f.6a6de8","name":"Set Controller 2","func":"msg.controller = 2\n\nreturn msg;","outputs":1,"noerr":0,"x":653.5,"y":205.7500114440918,"wires":[["ebcef3df.14311"]]},{"id":"56b9f6ab.a94608","type":"file in","z":"9592163f.6a6de8","name":"read store for next ids","filename":"mysids.dump","format":"utf8","x":395,"y":65,"wires":[["57db23d6.a824dc"]]},{"id":"e000bd09.1fff4","type":"debug","z":"9592163f.6a6de8","name":"Debug","active":false,"console":"false","complete":"true","x":732,"y":361,"wires":[]},{"id":"57db23d6.a824dc","type":"function","z":"9592163f.6a6de8","name":"store to context.global.mysnextid","func":"if (msg.payload === undefined) {\n var mysnextid = {};\n\n obj = mysnextid; \n}\nelse \n{\ntry{\n obj = JSON.parse(msg.payload);\n }\n catch(e){\n \n var mysnextid = {};\n\n obj = mysnextid;\n \n }\n} \n\ncontext.global.mysnextid = obj;\n\nmsg.payload = context.global.mysnextid;\n\nreturn msg;","outputs":1,"noerr":0,"x":658,"y":53,"wires":[[]]},{"id":"dfba7d69.20458","type":"file","z":"9592163f.6a6de8","name":"dump mysids","filename":"mysids.dump","appendNewline":true,"createDir":false,"overwriteFile":"true","x":1473,"y":381.99999618530273,"wires":[]},{"id":"e0e76d62.1f189","type":"function","z":"9592163f.6a6de8","name":"handle nextids","func":"// increase nextid, if nodeid >= nextid \n// node.log(\"Handling next ids\");\n// node.log(\"nodeId: \" + msg.nodeId);\n\nbChanged = false;\n\nif (msg.nodeId === 0) return;\n\nif (msg.nodeId < 255)\n{\n // node.log(\"Test if next node-id must be set\");\n if (context.global.mysnextid[msg.controller] === undefined) {\n node.log(\"node-id not initialized yet\");\n context.global.mysnextid[msg.controller] = msg.nodeId+1;\n if (context.global.mysnextid[msg.controller] < context.global.MYS.MIN_NODEID)\n context.global.mysnextid[msg.controller] = context.global.MYS.MIN_NODEID;\n bChanged = true;\n }\n \n // node.log(\"Nexid stored \" + parseInt(context.global.mysnextid[msg.controller]));\n \n if (msg.nodeId >= parseInt(context.global.mysnextid[msg.controller])) {\n node.log(\"node-id >= next -> increase\");\n // convert to int\n context.global.mysnextid[msg.controller] = parseInt(context.global.mysnextid[msg.controller]);\n context.global.mysnextid[msg.controller] = msg.nodeId+1; \n if (context.global.mysnextid[msg.controller] < context.global.MYS.MIN_NODEID)\n context.global.mysnextid[msg.controller] = context.global.MYS.MIN_NODEID;\n bChanged = true;\n }\n\n if (bChanged) {\n node.log(\"next id must be stored\");\n msg.payload = JSON.stringify(context.global.mysnextid); \n return msg;\n }\n}\n\n\n","outputs":1,"noerr":0,"x":1262,"y":374.99999618530273,"wires":[["dfba7d69.20458","5c074c19.a3f8b4"]]},{"id":"8da09002.725f7","type":"function","z":"9592163f.6a6de8","name":"MQTT to MYS convert","func":"// topic = MYS-NODERED/set/controller/node-id/sensor-id/ack/sub-type\n// payload = payload :)\n\n var tokens = msg.topic.split(\"/\");\n \n msg.rawData = tokens;\n msg.tokens = tokens.length;\n if(tokens.length == 7)\n {\n if (tokens[0] != context.global.MYS.TOPIC_PREFIX) // not for us\n return;\n if (tokens[1] != 'set') // not for us\n return;\n \n msg.controller = parseInt(tokens[2]);\n msg.messageType = context.global.MYS.T_SET;\n msg.nodeId = parseInt(tokens[3]);\n msg.childSensorId = parseInt(tokens[4]);\n msg.ack = parseInt(tokens[5]);\n msg.subType = context.global.MYS.VNum(tokens[6]);\n \n msg.payload = context.global.MYS.encode(msg.nodeId, msg.childSensorId, msg.messageType, msg.ack, msg.subType, msg.payload);\n \n return msg; \n }\n","outputs":1,"noerr":0,"x":490,"y":361,"wires":[["e000bd09.1fff4","266b87b3.d99478"]]},{"id":"3e866f6d.c1799","type":"tcp request","z":"9592163f.6a6de8","server":"192.168.92.13","port":"5003","out":"sit","splitc":"0","name":"MySWifi ESP8266 GW AES 13","x":407,"y":145.99999618530273,"wires":[["df1e322.f20e1d","9386fdb0.6c79"]]},{"id":"5c074c19.a3f8b4","type":"debug","z":"9592163f.6a6de8","name":"","active":true,"console":"false","complete":"false","x":1454,"y":543.9999961853027,"wires":[]},{"id":"c75fd7f4.38a028","type":"mqtt in","z":"9592163f.6a6de8","name":"Read MQTT Stream: change Topic to your needs","topic":"MYS-NODERED/set/#","broker":"ba386057.845d3","x":183.5,"y":362,"wires":[["8da09002.725f7"]]},{"id":"9386fdb0.6c79","type":"function","z":"9592163f.6a6de8","name":"Watchdog controller 1","func":"if (isNaN(context.global.controller1count))\n context.global.controller1count=0;\n\n\ncontext.global.controller1count++;\n\n","outputs":1,"noerr":0,"x":630,"y":105,"wires":[[]]},{"id":"d465a67.f2b9a58","type":"inject","z":"9592163f.6a6de8","name":"Check health controller 1 every 5 minutes","topic":"","payload":"","payloadType":"none","repeat":"60","crontab":"","once":false,"x":173,"y":516,"wires":[["aa935a.ff556ca8"]]},{"id":"aa935a.ff556ca8","type":"function","z":"9592163f.6a6de8","name":"check health controlller 1","func":"if (isNaN(context.global.controller1count))\n context.global.controller1count=0;\n \nif (context.global.controller1count === 0) {\n // make a new connection to the controller\n msg.payload = \"\";\n node.log(\"no message recieved on mys controller 1, try to connect\");\n \n return msg;\n}\nelse\n{\n // reset counter\n context.global.controller1count=0;\n}\n","outputs":1,"noerr":0,"x":470,"y":510,"wires":[["c8b342e9.374cc","3e866f6d.c1799"]]},{"id":"c8b342e9.374cc","type":"debug","z":"9592163f.6a6de8","name":"","active":true,"console":"false","complete":"false","x":682,"y":511,"wires":[]}]```