[ { "id": "ad590cba.52a6f", "type": "switch", "z": "4be4e248.b41b1c", "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": 1285.166648864746, "y": 214.50001335144043, "wires": [ [ "de3f2183.21c0e" ], [ "a91583a0.56ea8" ], [ "e8c275e9.173d88" ], [ "4c807f78.b37f8" ], [ "1f090abb.e0f6f5" ] ] }, { "id": "de3f2183.21c0e", "type": "function", "z": "4be4e248.b41b1c", "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": 1514.916648864746, "y": 77.24998474121094, "wires": [ [ "b0a17c80.4f5e8", "91b23d93.2ed68" ] ] }, { "id": "e8c275e9.173d88", "type": "function", "z": "4be4e248.b41b1c", "name": "req", "func": "msg.topic = \"req\";\nreturn msg;", "outputs": 1, "noerr": 0, "x": 1510.5000228881836, "y": 214.75000190734863, "wires": [ [ "99df14ae.b09398", "b0a17c80.4f5e8" ] ] }, { "id": "4c807f78.b37f8", "type": "function", "z": "4be4e248.b41b1c", "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": 1514.5000228881836, "y": 265.00000190734863, "wires": [ [ "b0a17c80.4f5e8", "e0eade9b.1f152", "eff35da5.100ca" ] ] }, { "id": "1f090abb.e0f6f5", "type": "function", "z": "4be4e248.b41b1c", "name": "stream", "func": "msg.topic = \"stream\";\nreturn msg;", "outputs": 1, "x": 1522.5000228881836, "y": 360.00000190734863, "wires": [ [] ] }, { "id": "e0eade9b.1f152", "type": "debug", "z": "4be4e248.b41b1c", "name": "debug", "active": false, "console": "false", "complete": "true", "x": 1851.75, "y": 266, "wires": [] }, { "id": "a91583a0.56ea8", "type": "function", "z": "4be4e248.b41b1c", "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": 1518.166648864746, "y": 139.5, "wires": [ [ "b0a17c80.4f5e8", "833bccd9.5488" ] ] }, { "id": "a2e67a32.5d1988", "type": "debug", "z": "4be4e248.b41b1c", "name": "", "active": false, "console": "false", "complete": "true", "x": 1244.9166259765625, "y": 73.66668510437012, "wires": [] }, { "id": "115888c2.eea777", "type": "function", "z": "4be4e248.b41b1c", "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 0) {\n outputMsg.push({ \n payload: payload, \n controller: msg.controller\n });\n }\n}\n\nreturn [outputMsg];", "outputs": 1, "noerr": 0, "x": 794.1666870117188, "y": 167.91668701171875, "wires": [ [ "115888c2.eea777" ] ] }, { "id": "650dd90e.9af228", "type": "function", "z": "4be4e248.b41b1c", "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;\nMySHelper.prototype.V_CUSTOM\t\t\t = 48;\t//!< Custom messages used for controller/inter node specific commands, preferably using S_CUSTOM device type.\nMySHelper.prototype.V_POSITION\t\t \t = 49;\t//!< GPS position and altitude. Payload: latitude;longitude;altitude(m). E.g. \"55.722526;13.017972;18\"\nMySHelper.prototype.V_IR_RECORD\t\t\t = 50;\t//!< Record IR codes S_IR for playback\nMySHelper.prototype.V_PH\t\t\t\t = 51;\t//!< S_WATER_QUALITY, water PH\nMySHelper.prototype.V_ORP\t\t\t\t = 52;\t//!< S_WATER_QUALITY, water ORP : redox potential in mV\nMySHelper.prototype.V_EC\t\t\t\t = 53;\t//!< S_WATER_QUALITY, water electric conductivity µS/cm (microSiemens/cm)\nMySHelper.prototype.V_VAR\t\t\t\t = 54;\t//!< S_POWER, Reactive power: volt-ampere reactive (var)\nMySHelper.prototype.V_VA\t\t\t\t = 55;\t//!< S_POWER, Apparent power: volt-ampere (VA)\nMySHelper.prototype.V_POWER_FACTOR\t\t = 56;\t//!< S_POWER, Ratio of real power to apparent power: floating point value in the range [-1,..,1]\n\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,\nV_CUSTOM: MySHelper.prototype.V_CUSTOM,\t//!< Custom messages used for controller/inter node specific commands, preferably using S_CUSTOM device type.\nV_POSITION:\t\t\t MySHelper.prototype.V_POSITION,\t//!< GPS position and altitude. Payload: latitude;longitude;altitude(m). E.g. \"55.722526;13.017972;18\"\nV_IR_RECORD:\t\t MySHelper.prototype.V_IR_RECORD,\t//!< Record IR codes S_IR for playback\nV_PH:\t\t\t\t MySHelper.prototype.V_PH,\t//!< S_WATER_QUALITY, water PH\nV_ORP:\t\t\t\t MySHelper.prototype.V_ORP,\t//!< S_WATER_QUALITY, water ORP : redox potential in mV\nV_EC:\t\t\t\t MySHelper.prototype.V_EC,\t//!< S_WATER_QUALITY, water electric conductivity µS/cm (microSiemens/cm)\nV_VAR:\t\t\t\t MySHelper.prototype.V_VAR,\t//!< S_POWER, Reactive power: volt-ampere reactive (var)\nV_VA:\t\t\t\t MySHelper.prototype.V_VA,\t//!< S_POWER, Apparent power: volt-ampere (VA)\nV_POWER_FACTOR:\t\t MySHelper.prototype.V_POWER_FACTOR\t//!< S_POWER, Ratio of real power to apparent power: floating point value in the range [-1,..,1]\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 = 29; // 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 = 30; // Multimeter device; V_VOLTAGE; V_CURRENT; V_IMPEDANCE \nMySHelper.prototype.S_SPRINKLER = 31; // Sprinkler; V_STATUS (turn on/off); V_TRIPPED (if fire detecting device)\nMySHelper.prototype.S_WATER_LEAK = 32; // Water leak sensor; V_TRIPPED; V_ARMED\nMySHelper.prototype.S_SOUND = 33; // Sound sensor; V_TRIPPED; V_ARMED; V_LEVEL (sound level in dB)\nMySHelper.prototype.S_VIBRATION = 34; // Vibration sensor; V_TRIPPED; V_ARMED; V_LEVEL (vibration in Hz)\nMySHelper.prototype.S_MOISTURE = 35; // Moisture sensor; V_TRIPPED; V_ARMED; V_LEVEL (water content or moisture in percentage?) \nMySHelper.prototype.S_INFO = 36; // LCD text device / Simple information device on controller; V_TEXT\nMySHelper.prototype.S_GAS = 37; // Gas meter; V_FLOW; V_VOLUME\nMySHelper.prototype.S_GPS = 38; // GPS Sensor; V_POSITION\nMySHelper.prototype.S_WATER_QUALITY\t= 39;\t//!< V_TEMP, V_PH, V_ORP, V_EC, V_STATUS \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\nS_WATER_QUALITY: MySHelper.prototype.S_WATER_QUALITY // 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": 421.25, "y": 74, "wires": [ [] ] }, { "id": "c033a93.f3fcc58", "type": "function", "z": "4be4e248.b41b1c", "name": "Set Controller 1", "func": "msg.controller = 1\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 620, "y": 168.5, "wires": [ [ "be71c1fb.418e4" ] ] }, { "id": "171730bc.e8e8cf", "type": "switch", "z": "4be4e248.b41b1c", "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": 496, "y": 282.25, "wires": [ [ "2124191a.a39336", "529033aa.5cc32c" ], [], [], [] ] }, { "id": "e727412d.18d8c", "type": "file in", "z": "4be4e248.b41b1c", "name": "read store for next ids", "filename": "mysids.dump", "format": "utf8", "x": 442, "y": 120, "wires": [ [ "d67e3100.2981d" ] ] }, { "id": "d67e3100.2981d", "type": "function", "z": "4be4e248.b41b1c", "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": 684, "y": 85, "wires": [ [] ] }, { "id": "ab3f2caa.54c0d", "type": "file", "z": "4be4e248.b41b1c", "name": "dump mysids", "filename": "mysids.dump", "appendNewline": true, "createDir": false, "overwriteFile": "true", "x": 1499, "y": 413.99999618530273, "wires": [] }, { "id": "a140d5e.f5ebf28", "type": "function", "z": "4be4e248.b41b1c", "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": 1288, "y": 406.99999618530273, "wires": [ [ "ab3f2caa.54c0d", "b2f9fa35.4d0608" ] ] }, { "id": "b2f9fa35.4d0608", "type": "debug", "z": "4be4e248.b41b1c", "name": "", "active": false, "console": "false", "complete": "false", "x": 1480, "y": 575.9999961853027, "wires": [] }, { "id": "ea210f89.d12a7", "type": "serial in", "z": "4be4e248.b41b1c", "name": "MySensors Gateway Mega2560", "serial": "41544898.ab7ca8", "x": 190, "y": 153, "wires": [ [ "c033a93.f3fcc58", "63e5b024.1fe2e" ] ] }, { "id": "2124191a.a39336", "type": "serial out", "z": "4be4e248.b41b1c", "name": "MySensors Gateway Mega2560 Write", "serial": "41544898.ab7ca8", "x": 795, "y": 290, "wires": [] }, { "id": "91b23d93.2ed68", "type": "debug", "z": "4be4e248.b41b1c", "name": "debug", "active": false, "console": "false", "complete": "true", "x": 1849, "y": 77, "wires": [] }, { "id": "833bccd9.5488", "type": "debug", "z": "4be4e248.b41b1c", "name": "debug", "active": false, "console": "false", "complete": "true", "x": 1849, "y": 144, "wires": [] }, { "id": "99df14ae.b09398", "type": "debug", "z": "4be4e248.b41b1c", "name": "debug", "active": false, "console": "false", "complete": "true", "x": 1859, "y": 217, "wires": [] }, { "id": "ad7f8649.7f9e88", "type": "mqtt in", "z": "4be4e248.b41b1c", "name": "From Outside", "topic": "MYS-NODERED/+/+/+/+/SET", "qos": "2", "broker": "9db9bcfe.62464", "x": 139.5, "y": 27, "wires": [ [ "71681849.bea918" ] ] }, { "id": "3fbf3e0b.462a32", "type": "debug", "z": "4be4e248.b41b1c", "name": "Dump from MQTT", "active": false, "console": "false", "complete": "true", "x": 699.5, "y": 26, "wires": [] }, { "id": "71681849.bea918", "type": "function", "z": "4be4e248.b41b1c", "name": "Parse", "func": "// msg.topic = context.global.MYS.TOPIC_PREFIX + '/' + msg.controller + \"/\" + msg.nodeId + \"/\" + msg.childSensorId + \"/\" + msg.subTypeString;\n\n\n var tokens = msg.topic.split(\"/\");\n \n msg.rawData = tokens;\n if(tokens.length >= 5)\n {\n msg.controller = parseInt(tokens[1]);\n msg.nodeId = parseInt(tokens[2]);\n msg.childSensorId = parseInt(tokens[3]);\n msg.subTypeString = tokens[4];\n msg.subType = context.global.MYS.VNum(msg.subTypeString);\n msg.command = 1; // SET\n msg.acknowledge = 0; // no ack as default\n }\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 318.5, "y": 27, "wires": [ [ "3fbf3e0b.462a32", "9808fcdc.efeca" ] ] }, { "id": "9808fcdc.efeca", "type": "function", "z": "4be4e248.b41b1c", "name": "Send to Gateway", "func": "msg.payload = context.global.MYS.encode(msg.nodeId, msg.childSensorId, msg.command, msg.acknowledge, msg.subType, msg.payload);\n\n//msg.payload = msg.nodeId + ' ' + msg.childSensorId + ' ' + msg.command;\n//msg.childSensorId, msg.command, msg.acknowledge, msg.subType, msg.payload);\n\n \nreturn msg;", "outputs": 1, "noerr": 0, "x": 147.5, "y": 225, "wires": [ [ "529033aa.5cc32c", "171730bc.e8e8cf" ] ] }, { "id": "529033aa.5cc32c", "type": "debug", "z": "4be4e248.b41b1c", "name": "Serial", "active": false, "console": "false", "complete": "true", "x": 487.5, "y": 210, "wires": [] }, { "id": "633cc4d0.a533fc", "type": "inject", "z": "4be4e248.b41b1c", "name": "", "topic": "Test", "payload": "", "payloadType": "date", "repeat": "", "crontab": "", "once": false, "x": 111.5, "y": 290, "wires": [ [ "f556cdd6.15b9e" ] ] }, { "id": "f556cdd6.15b9e", "type": "function", "z": "4be4e248.b41b1c", "name": "Set Relay On", "func": "msg.controller = 1;\nmsg.nodeId = 14;\nmsg.childSensorId = 2;\nmsg.subTypeString = 'V_LIGHT';\nmsg.subType = context.global.MYS.VNum(msg.subTypeString);\nmsg.command = 1; // SET\nmsg.acknowledge = 0; // no ack as default\nmsg.payload = 1;\nreturn msg;", "outputs": 1, "noerr": 0, "x": 244.5, "y": 289, "wires": [ [ "9808fcdc.efeca" ] ] }, { "id": "1285c2fb.954e2d", "type": "function", "z": "4be4e248.b41b1c", "name": "Set Relay Off", "func": "msg.controller = 1;\nmsg.nodeId = 14;\nmsg.childSensorId = 2;\nmsg.subTypeString = 'V_LIGHT';\nmsg.subType = context.global.MYS.VNum(msg.subTypeString);\nmsg.command = 1; // SET\nmsg.acknowledge = 0; // no ack as default\nmsg.payload = 0;\nreturn msg;", "outputs": 1, "noerr": 0, "x": 238, "y": 328, "wires": [ [ "9808fcdc.efeca" ] ] }, { "id": "a2947aed.9e60c8", "type": "inject", "z": "4be4e248.b41b1c", "name": "", "topic": "Test", "payload": "", "payloadType": "date", "repeat": "", "crontab": "", "once": false, "x": 94, "y": 326, "wires": [ [ "1285c2fb.954e2d" ] ] }, { "id": "1d97446f.e06aac", "type": "inject", "z": "4be4e248.b41b1c", "name": "", "topic": "Test", "payload": "", "payloadType": "date", "repeat": "", "crontab": "", "once": false, "x": 97, "y": 377, "wires": [ [ "6b316558.2bc3ec" ] ] }, { "id": "6b316558.2bc3ec", "type": "function", "z": "4be4e248.b41b1c", "name": "Set Relay 2 On", "func": "msg.controller = 1;\nmsg.nodeId = 14;\nmsg.childSensorId = 3;\nmsg.subTypeString = 'V_LIGHT';\nmsg.subType = context.global.MYS.VNum(msg.subTypeString);\nmsg.command = 1; // SET\nmsg.acknowledge = 0; // no ack as default\nmsg.payload = 1;\nreturn msg;", "outputs": 1, "noerr": 0, "x": 240, "y": 376, "wires": [ [ "9808fcdc.efeca" ] ] }, { "id": "ae5df53f.f74108", "type": "function", "z": "4be4e248.b41b1c", "name": "Set Relay 2 Off", "func": "msg.controller = 1;\nmsg.nodeId = 14;\nmsg.childSensorId = 2;\nmsg.subTypeString = 'V_LIGHT';\nmsg.subType = context.global.MYS.VNum(msg.subTypeString);\nmsg.command = 1; // SET\nmsg.acknowledge = 0; // no ack as default\nmsg.payload = 0;\nreturn msg;", "outputs": 1, "noerr": 0, "x": 245.5, "y": 415, "wires": [ [ "9808fcdc.efeca" ] ] }, { "id": "e99b4cae.c8f9f", "type": "inject", "z": "4be4e248.b41b1c", "name": "", "topic": "Test", "payload": "", "payloadType": "date", "repeat": "", "crontab": "", "once": false, "x": 79.5, "y": 413, "wires": [ [ "ae5df53f.f74108" ] ] }, { "id": "63e5b024.1fe2e", "type": "debug", "z": "4be4e248.b41b1c", "name": "", "active": false, "console": "false", "complete": "true", "x": 960, "y": 127, "wires": [] }, { "id": "9db9bcfe.62464", "type": "mqtt-broker", "z": "", "broker": "192.168.92.5", "port": "1883", "clientid": "", "usetls": false, "verifyservercert": false, "compatmode": false, "keepalive": "15", "cleansession": true, "willTopic": "", "willQos": "1", "willRetain": "false", "willPayload": "", "birthTopic": "", "birthQos": "0", "birthRetain": "false", "birthPayload": "" }, { "id": "41544898.ab7ca8", "type": "serial-port", "z": "4be4e248.b41b1c", "serialport": "/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0", "serialbaud": "115200", "databits": "8", "parity": "none", "stopbits": "1", "newline": "\\n", "bin": "false", "out": "char", "addchar": false } ]