liaan / victron_thethingbox

Monitor Victron Multiplus inveter using the Mk2 Usb interface on Thethingbox.io raspberry and log to emoncms.org
0 stars 1 forks source link

TypeError: Cannot assign to read only property '_msgid' of diff = #1

Closed bidouilleur31 closed 8 years ago

bidouilleur31 commented 8 years ago

Hello Am trying to make work your flow and used import clipboard. Deleted the lower posting to local. When activating I get the above mentioned error that seems to be related to

Build EmonCMS url

To be honest am brand new node-red user (even user is a big word) Is it possible to elaborate a bit more on how to configure this correctly please ? thanks

bidouilleur31 commented 8 years ago

A friend helped me to solve the issue, here is the flow that works for me Hope this helps others to make it work.

[
    {
        "id": "49e8b7a8.b61748",
        "type": "serial in",
        "z": "d9f7633c.2608a",
        "name": "Mk2",
        "serial": "37f5231a.c80adc",
        "x": 914,
        "y": 1168.7142601013184,
        "wires": [
            [
                "e83cdf41.17c32",
                "482408ae.b7dbf8"
            ]
        ]
    },
    {
        "id": "e83cdf41.17c32",
        "type": "debug",
        "z": "d9f7633c.2608a",
        "name": "",
        "active": false,
        "console": "false",
        "complete": "true",
        "x": 1080.2857093811035,
        "y": 1219.2856817245483,
        "wires": []
    },
    {
        "id": "f8135cd6.07eca",
        "type": "inject",
        "z": "d9f7633c.2608a",
        "name": "Get Led Status",
        "topic": "",
        "payload": "L",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 1003.7142448425293,
        "y": 597,
        "wires": [
            [
                "fc938237.036c8"
            ]
        ]
    },
    {
        "id": "6dbbc983.924438",
        "type": "template",
        "z": "d9f7633c.2608a",
        "name": "Make Packet",
        "field": "payload",
        "fieldType": "msg",
        "syntax": "mustache",
        "template": "{{#leds}}\n\n{{name}} is {{status}}\n\n{{/leds}}",
        "x": 1865.5715522766113,
        "y": 999.2856750488281,
        "wires": [
            [
                "770d703b.88f29"
            ]
        ]
    },
    {
        "id": "482408ae.b7dbf8",
        "type": "function",
        "z": "d9f7633c.2608a",
        "name": "Decode MK2 String",
        "func": "\ncommand = String.fromCharCode(msg.payload[2]);\n\nchecksum = 0;\n\nfor (i=0;i<msg.payload.length;i++){\n  checksum = (checksum + msg.payload.readInt8(i))%0x100 ;\n}\nmsg.checksum = checksum\nif(checksum != 0){\n\treturn null\n}\n\nif(msg.payload[1] == 255){ \n\tswitch (command){\n\t\tcase \"L\": //LED Status\n\t\t\t\n\t\t\tmsg.type = 1;\t\t\n\t\t\tmsg.value = [msg.payload[3],msg.payload[4]];\n\t\t\t\n\t\tbreak;\n\t\tcase 'V': // Version\n\t\t  \n\t\t  msg.type = 2;\n\t\t  \n\t\t \n\t\tbreak;\n\t\tcase 'F':\t\t\n\t\t\tmsg.type = 3;\n\t\t\t\n\t\tbreak;\n\t\tdefault:\n\t\t\tmsg.type=0;\n\t\tbreak;\n\t}\n\treturn [msg,null,msg]\n}\n\n//Info Frame\nif(msg.payload[1] == 0x20){\n\t\n\treturn [null,msg,msg];\t\n}\n\n\n",
        "outputs": "3",
        "x": 1115.0000038146973,
        "y": 1168.9999794960022,
        "wires": [
            [
                "81fd5ed8.7e02a"
            ],
            [
                "790f20e3.86f0e"
            ],
            [
                "583c106a.a7c3f"
            ]
        ]
    },
    {
        "id": "cf72ebc5.308d18",
        "type": "debug",
        "z": "d9f7633c.2608a",
        "name": "",
        "active": false,
        "console": "false",
        "complete": "true",
        "x": 1519.6507759094238,
        "y": 1038.0635375976562,
        "wires": []
    },
    {
        "id": "81fd5ed8.7e02a",
        "type": "switch",
        "z": "d9f7633c.2608a",
        "name": "Switch MK2 packet type",
        "property": "type",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "1",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "0",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "outputs": 2,
        "x": 1331.58736038208,
        "y": 1074.15869140625,
        "wires": [
            [
                "cf72ebc5.308d18",
                "ff7dd586.008228"
            ],
            [
                "e54d59c0.1ab2a8"
            ]
        ]
    },
    {
        "id": "770d703b.88f29",
        "type": "debug",
        "z": "d9f7633c.2608a",
        "name": "",
        "active": false,
        "console": "false",
        "complete": "false",
        "x": 2039.1428413391113,
        "y": 1002.7142944335938,
        "wires": []
    },
    {
        "id": "ff7dd586.008228",
        "type": "function",
        "z": "d9f7633c.2608a",
        "name": "Mk2: Decode LED String",
        "func": "var leds = Array();\n\nleds[0] = {\n\tname : 'Mains',\n\tstatus : 0\n}\nleds[1] = {\n\tname : 'Absorpion',\n\tstatus : 0\n}\nleds[2] ={\n\tname : 'Bulk',\n\tstatus : 0\n}\nleds[3] = {\n\tname : 'Float',\n\tstatus : ''\n}\nleds[4] = {\n\tname : 'Inverter',\n\tstatus : ''\n}\nleds[5] = {\n\tname : 'Overload',\n\tstatus : ''\n}\nleds[6] = {\n\tname : 'Low Battery',\n\tstatus : ''\n}\nleds[7] = {\n\tname : 'Temperature',\n\tstatus : ''\n}\n\ndecode_on_off (msg.value[0])\ndecode_blinking(msg.value[1])\n\n//Assign LED array\nmsg.leds = leds;\n\n\n//Return\nreturn msg;\n\n\n/*\n* Decode LED on Off\n* \n*/\nfunction decode_on_off(value){\n\n\tfor(i=0;i<8;i++){\n\t\tleds[i]['status'] = (value & 1<<i)?'On':'Off';\n\t\tleds[i]['status_id'] = (value & 1<<i)?1:0;\n\t}\t\t\t\n\n\t\n}\n\n/*\n* Decode Blinking State\n*/\nfunction decode_blinking(value){\n\n\tfor(i=0;i<8;i++){\n\t\n\t\t (value & 1<<i) ? (leds[i]['status'] = 'Blinking'):'';\n\t\t (value & 1<<i) ? (leds[i]['status_id'] = 2):'';\t\t\n\t}\t\t\t\n\n}\n",
        "outputs": 1,
        "noerr": 0,
        "x": 1594.3333930969238,
        "y": 1084.8729858398438,
        "wires": [
            [
                "6dbbc983.924438",
                "c9bc57e0.3643a8"
            ]
        ]
    },
    {
        "id": "6447337c.9bb8cc",
        "type": "inject",
        "z": "d9f7633c.2608a",
        "name": "Get AC/DC/LED Info State",
        "topic": "0",
        "payload": "F",
        "payloadType": "str",
        "repeat": "0.2",
        "crontab": "",
        "once": false,
        "x": 1034.8094673156738,
        "y": 850.2539672851562,
        "wires": [
            [
                "39065a99.c6f9a6"
            ]
        ]
    },
    {
        "id": "2683cbc2.d97c34",
        "type": "inject",
        "z": "d9f7633c.2608a",
        "name": "Get MasterLED State",
        "topic": "5",
        "payload": "F",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 1015.809497833252,
        "y": 642.5396881103516,
        "wires": [
            [
                "fc938237.036c8"
            ]
        ]
    },
    {
        "id": "e54d59c0.1ab2a8",
        "type": "debug",
        "z": "d9f7633c.2608a",
        "name": "Unkown Frame",
        "active": false,
        "console": "false",
        "complete": "true",
        "x": 1451.5714302062988,
        "y": 1146.1428833007812,
        "wires": []
    },
    {
        "id": "5899724a.a7668c",
        "type": "debug",
        "z": "d9f7633c.2608a",
        "name": "",
        "active": false,
        "console": "false",
        "complete": "true",
        "x": 1774.5714302062988,
        "y": 1177.1428833007812,
        "wires": []
    },
    {
        "id": "c9bc57e0.3643a8",
        "type": "function",
        "z": "d9f7633c.2608a",
        "name": "LED to emoncms",
        "func": "var bla = {};\nvar newMsg = {};\nnewMsg.values = make_emoncms(msg.leds)\n\n//bla.nodegroup = \"ab\";\n//msg = bla;\nnewMsg.node = 0;\nnewMsg.packet_type = 3;\n\nreturn newMsg;\n\nfunction make_emoncms(leds){\n\t//var payload = \"1\";\n\tvar payload = {};\n\t//payload2 = {};\n\t\n\tleds.forEach(function (byte,index) {\n\t\t\n\t\tvar color = 10;\n\t\tswitch (byte.status_id)\n\t\t{\n\t\t\tcase 0: //off\n\t\t\t color = 10 //green\n\t\t\t break;\n\t\t\tcase 1://on\n\t\t\t  color=1\n\t\t\t break;\n\t\t\tcase 2://blink\n\t\t\t  color = 4\n\t\t\t  break\n\t\t\tdefault:\n\t\t\t color = 5\n\t\t\t break;\n\t\t}\n     // payload += ','+[byte.name]+':'+color\n\t  payload[byte.name] = color\n\t  \n\t})\n\treturn payload;\n\t//return JSON.stringify(payload);\n}",
        "outputs": 1,
        "x": 1647.5714302062988,
        "y": 1239.1428833007812,
        "wires": [
            [
                "5899724a.a7668c",
                "4f2a6984.b0d598"
            ]
        ]
    },
    {
        "id": "790f20e3.86f0e",
        "type": "function",
        "z": "d9f7633c.2608a",
        "name": "Decode Info Frame",
        "func": "try{\nvar packet = Array();\nvar phase = msg.payload[2+4];\n\nswitch (phase){\n\tcase 0x0C: //DC\n\t\t//msg.values = decode_dc();\n\t\tmsg.type = 1;\n\t\tmsg.run = 'DC';\n\tbreak;\n\tcase 0x08: //AC L1\n\t\t//msg.values = decode_ac();\n\t\tmsg.run = 'ac';\n\t\tmsg.type = 2;\n\tbreak;\n\tdefault:\n\t\tmsg.run = 'Unkown packet'+ phase.charCodeAt(0);\n\tbreak;\n}\n\nreturn msg;\n\n\n}catch(e){\n\tconsole.log(e);\n\treturn msg;\n}",
        "outputs": 1,
        "x": 1258.28568649292,
        "y": 1388.0000324249268,
        "wires": [
            [
                "bb20f119.44df1",
                "2fcf215d.d030de"
            ]
        ]
    },
    {
        "id": "bb20f119.44df1",
        "type": "switch",
        "z": "d9f7633c.2608a",
        "name": "",
        "property": "type",
        "rules": [
            {
                "t": "eq",
                "v": "1"
            },
            {
                "t": "eq",
                "v": "2"
            }
        ],
        "checkall": "true",
        "outputs": 2,
        "x": 1439.1428337097168,
        "y": 1386.571434020996,
        "wires": [
            [
                "c019d3de.3fe63"
            ],
            [
                "46782443.b987dc"
            ]
        ]
    },
    {
        "id": "46782443.b987dc",
        "type": "function",
        "z": "d9f7633c.2608a",
        "name": "Decode AC Frame",
        "func": "try {  \n\nmsg.values = decode_ac(msg.payload);\nmsg.type = 'Inverter AC'\nmsg.node = 1;\nmsg.packet_type = 2;\nreturn msg;\nfunction decode_ac(packet){\n\tvar ac = {\t\n\t\tbf_factor: packet.readInt8(2+0)\n\t    ,inverter_factor: packet.readUInt8(2+1)\n\t    ,mains_volt: packet.readInt16LE(2+5)/100\n\t\t,mains_current : packet.readInt16LE(2+7)/100 //((packet[2+7])+(packet[2+8]*255))/100\n\t\t,inverter_voltage : packet.readInt16LE(2+9)/100 //((packet[2+9])+(packet[2+10]*255))/100\n\t\t,inverter_current : packet.readInt16LE(2+11)/100 // ((packet[2+11])+(packet[2+12]*255))/100\n\t\t,mains_period : 10/(packet.readUInt8(2+13)*0.0010235414534288639)\n\t\t\n\t}\n\t\n\tac['mains_watts'] = (ac.mains_current * ac.mains_volt * ac.bf_factor);\n\tac['inverter_watts'] = (ac.inverter_voltage * ac.inverter_current * ac.inverter_factor);\n\tac['InverterWattsOut'] = ac['inverter_watts'] \n\t\n\treturn ac;\n}\n}catch(e){\nconsole.log(e)\n}",
        "outputs": 1,
        "x": 1647.1428413391113,
        "y": 1497.5714111328125,
        "wires": [
            [
                "4f2a6984.b0d598",
                "83ee2495.7c11d8"
            ]
        ]
    },
    {
        "id": "c019d3de.3fe63",
        "type": "function",
        "z": "d9f7633c.2608a",
        "name": "Decode DC Frame",
        "func": "try {\n\n\n\nmsg.values = decode_dc(msg.payload)\nmsg.type = 'Inverter DC'\nmsg.node = 1;\nmsg.packet_type = 1;\nreturn msg;\n\nfunction decode_dc(packet){\n\tvar dc = {\n\t\t\n\t\tbat_volt: packet.readInt16LE(2+5)/100 //cket[2+5])+packet[2+6]*255)/100\n\t\t,bat_current_used :  ((packet[2+7])+(packet[2+8]*255)+(packet[2+9]*255*255))/10\n\t\t,bat_current_charge : ((packet[2+10])+(packet[2+11]*255)+(packet[2+12]*255*255))/10\n\t\t,bat_inverter_period : 10/((packet.readUInt8(2+13)+256)*0.0005099)\n\t\t\n\t}\n\t\n\tdc['bat_watts'] = (dc.bat_current_used * dc.bat_volt);\n\tdc['bat_charge_watts'] = (dc.bat_current_charge * dc.bat_volt);\n\t\n\treturn dc;\n}\n\n\n\n}\ncatch(e){\nconsole.log(e)\n}\n",
        "outputs": 1,
        "x": 1645.1428413391113,
        "y": 1315.5714111328125,
        "wires": [
            [
                "2d0a201f.d2f5e",
                "4f2a6984.b0d598"
            ]
        ]
    },
    {
        "id": "2fcf215d.d030de",
        "type": "debug",
        "z": "d9f7633c.2608a",
        "name": "",
        "active": false,
        "console": "false",
        "complete": "true",
        "x": 1418.28568649292,
        "y": 1507.4285488128662,
        "wires": []
    },
    {
        "id": "ad1cb270.52e35",
        "type": "function",
        "z": "d9f7633c.2608a",
        "name": "Build EmonCMS url",
        "func": "// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n//   console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n//   context = {};\n\n//expects JSON payload and destination specified in topic\nmsg2 = {};\nvar diff = 0;\nif(context.lastrun !== undefined){\n\n\tdiff = (new Date()/1000) - context.lastrun;\n\n\tif(diff < 10)\n\t{\n\t\tbla = \"diff = \" + diff;\n\t\tmsg2.payload = bla;\n\t\treturn [null,msg2];\n\t}\n}\n\ncontext.lastrun = new Date()/1000;\n\nvar key = \"paste here your write api key\";\n\n//destination will be last part node of topic\nvar values = JSON.stringify(msg.values);\nvar node = msg.node;\n//console.log(values);\n\nif(isNaN(node))\n{\n//not a valid destination\nreturn null;\n}\n\nmsg.url =\"https://url-to-emoncmr-or-your-local-setup/input/post.json?node=\";\nmsg.url += node;\nmsg.url += \"&json=\";\nmsg.url += values;\nmsg.url += \"&apikey=\";\nmsg.url += key;\n\nif(msg.timestamp !== undefined){\n\tmsg.url += \"&time=\"+msg.timestamp;\n}else{\n\tmsg.url += \"&time=\"+Math.floor(Date.now() / 1000);\n}\n//console.log(msg.url);\n\nmsg2.payload = \"posted: \" +diff;\nreturn [msg ,msg2];",
        "outputs": "2",
        "noerr": 0,
        "x": 2143.8928413391113,
        "y": 1319.0714721679688,
        "wires": [
            [
                "eb4ce22d.14b32",
                "36251881.c9dae8"
            ],
            [
                "e83d8634.17c278"
            ]
        ]
    },
    {
        "id": "eb4ce22d.14b32",
        "type": "http request",
        "z": "d9f7633c.2608a",
        "name": "HTTP GET to EmonCMS.org",
        "method": "GET",
        "ret": "txt",
        "url": "",
        "tls": "",
        "x": 2394.8095893859863,
        "y": 1240.8214721679688,
        "wires": [
            [
                "657028a.f9a8fd8"
            ]
        ]
    },
    {
        "id": "657028a.f9a8fd8",
        "type": "debug",
        "z": "d9f7633c.2608a",
        "name": "EmonCMS HTTP Request Result",
        "active": false,
        "console": "false",
        "complete": "true",
        "x": 2704.8095703125,
        "y": 1246.6548461914062,
        "wires": []
    },
    {
        "id": "2d0a201f.d2f5e",
        "type": "debug",
        "z": "d9f7633c.2608a",
        "name": "",
        "active": false,
        "console": "false",
        "complete": "true",
        "x": 1686.1428413391113,
        "y": 1386.3214721679688,
        "wires": []
    },
    {
        "id": "77a966f1.885698",
        "type": "debug",
        "z": "d9f7633c.2608a",
        "name": "EmonCMS URL",
        "active": false,
        "console": "false",
        "complete": "true",
        "x": 2745.392822265625,
        "y": 1329.3214721679688,
        "wires": []
    },
    {
        "id": "36251881.c9dae8",
        "type": "function",
        "z": "d9f7633c.2608a",
        "name": "Debug EmonCMS URL",
        "func": "// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n//   console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n//   context = {};\n\n\nmsg.payload = msg.url;\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "x": 2440.142822265625,
        "y": 1332.0714721679688,
        "wires": [
            [
                "77a966f1.885698"
            ]
        ]
    },
    {
        "id": "1dd9ef7e.e22611",
        "type": "serial out",
        "z": "d9f7633c.2608a",
        "name": "Mk2_out",
        "serial": "37f5231a.c80adc",
        "x": 1950.8571434020996,
        "y": 606.1428508758545,
        "wires": []
    },
    {
        "id": "12b0c6b0.ed4f39",
        "type": "debug",
        "z": "d9f7633c.2608a",
        "name": "",
        "active": false,
        "console": "false",
        "complete": "true",
        "x": 1882.698398590088,
        "y": 673.7460517883301,
        "wires": []
    },
    {
        "id": "fc938237.036c8",
        "type": "function",
        "z": "d9f7633c.2608a",
        "name": "Make Command",
        "func": "\ncmd = msg.payload;\ncmd = cmd.charCodeAt(0);\ndata = msg.topic\n\nvar packet = [];\npacket.push(0xff);\npacket.push(cmd);\nif(data !==''){\n\tpacket.push(data);\n}\n\nlength = packet.length;\n//Add Length to begining\npacket.unshift(length)\n//Calculate Checksum\nchecksum = 0;\n\npacket.forEach(function (byte) {\n  checksum -= byte;\n}) \n\n//checksum = 0xB3;\n\n\n//Add Checksum to end\npacket.push(checksum);\n\n\n//Make it a Buffer and assign to payload\nmsg.payload = new Buffer(packet,'hex');\n\n\nreturn [msg];",
        "outputs": "1",
        "noerr": 0,
        "x": 1679.0000190734863,
        "y": 629.4285621643066,
        "wires": [
            [
                "12b0c6b0.ed4f39",
                "1dd9ef7e.e22611"
            ]
        ]
    },
    {
        "id": "b4aeee51.4b511",
        "type": "change",
        "z": "d9f7633c.2608a",
        "name": "DC",
        "action": "replace",
        "property": "topic",
        "from": "",
        "to": "0",
        "reg": false,
        "x": 1186.3968391418457,
        "y": 716.5079498291016,
        "wires": [
            [
                "d57794bd.2a8868"
            ]
        ]
    },
    {
        "id": "d57794bd.2a8868",
        "type": "delay",
        "z": "d9f7633c.2608a",
        "name": "",
        "pauseType": "delay",
        "timeout": "150",
        "timeoutUnits": "milliseconds",
        "rate": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 1328.1111030578613,
        "y": 715.7936553955078,
        "wires": [
            [
                "fc938237.036c8"
            ]
        ]
    },
    {
        "id": "515b4a43.aea4b4",
        "type": "change",
        "z": "d9f7633c.2608a",
        "name": "AC",
        "action": "replace",
        "property": "topic",
        "from": "",
        "to": "1",
        "reg": false,
        "x": 1185.5396614074707,
        "y": 674.6508102416992,
        "wires": [
            [
                "fc938237.036c8"
            ]
        ]
    },
    {
        "id": "583c106a.a7c3f",
        "type": "debug",
        "z": "d9f7633c.2608a",
        "name": "",
        "active": false,
        "console": "false",
        "complete": "checksum",
        "x": 1306.2856636047363,
        "y": 1298,
        "wires": []
    },
    {
        "id": "769f27b5.8960d8",
        "type": "change",
        "z": "d9f7633c.2608a",
        "name": "LED",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "L",
                "tot": "str"
            }
        ],
        "x": 1184.3967475891113,
        "y": 762.2222290039062,
        "wires": [
            [
                "4896dcd.fb76924"
            ]
        ]
    },
    {
        "id": "4896dcd.fb76924",
        "type": "delay",
        "z": "d9f7633c.2608a",
        "name": "",
        "pauseType": "delay",
        "timeout": "350",
        "timeoutUnits": "milliseconds",
        "rate": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 1327.3967475891113,
        "y": 763.2222290039062,
        "wires": [
            [
                "fc938237.036c8"
            ]
        ]
    },
    {
        "id": "4f2a6984.b0d598",
        "type": "function",
        "z": "d9f7633c.2608a",
        "name": "Merge Packets",
        "func": "\n//Set defaults if not set yet\nif(context.dc === undefined){\n\tcontext.dc = false;\n}\nif(context.led === undefined){\n\tcontext.ac = false;\n}\nif(context.packet === undefined){\n\tcontext.packet = {};\n}\nif(context.led === undefined){\n\tcontext.led = false;\n}\n\nif(msg.packet_type === 1){\n\n\tcontext.dc = true;\n}\n\nif (msg.packet_type === 2){\n\tcontext.ac = true;\n}\nif (msg.packet_type === 3){\n\tcontext.led = true;\n}\n\n\nObject.keys(msg.values).forEach(function(key) {\n  \t\tcontext.packet[key] = msg.values[key];\n\n});\n\n\n\nif(context.dc && context.ac && context.led){\n\t//var newMsg = { values: context.packet }\n    msg.values = context.packet;\n    context.ac = false;\n    context.dc = false;\n    delete context.packet;\n    \n\treturn msg;\n}else {\n\treturn [null]\n}\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 2010.2856636047363,
        "y": 1441,
        "wires": [
            [
                "9a0c1da9.65f3e",
                "ad1cb270.52e35"
            ]
        ]
    },
    {
        "id": "9a0c1da9.65f3e",
        "type": "debug",
        "z": "d9f7633c.2608a",
        "name": "",
        "active": false,
        "console": "false",
        "complete": "true",
        "x": 2182.2856636047363,
        "y": 1443,
        "wires": []
    },
    {
        "id": "e83d8634.17c278",
        "type": "debug",
        "z": "d9f7633c.2608a",
        "name": "",
        "active": false,
        "console": "false",
        "complete": "true",
        "x": 2357.2856636047363,
        "y": 1409,
        "wires": []
    },
    {
        "id": "39065a99.c6f9a6",
        "type": "function",
        "z": "d9f7633c.2608a",
        "name": "Next Packet",
        "func": "delete msg.payload;\nif(context.count == undefined || context.count > 3){\n\tcontext.count = 1\n}\nif(context.running == undefined){\n\tcontext.running = false;\n}\n//if already running, return .\nif(context.running === true){\n\treturn [null]\n}\ncontext.running = true;\n// AC\nif(context.count === 1){\n\tmsg.topic = 1;\n\tmsg.payload = \"F\";\n\t\n}\n//DC\nif(context.count === 2){\n\tmsg.topic = 0;\n\tmsg.payload = \"F\";\n\t\n}\nif(context.count === 3){\n\tmsg.topic = '';\n\tmsg.payload = \"L\";\n\t\n}\n\ncontext.count += 1\ncontext.running = false;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 1266.5078620910645,
        "y": 849.2221984863281,
        "wires": [
            [
                "467105fb.b98efc",
                "fc938237.036c8"
            ]
        ]
    },
    {
        "id": "467105fb.b98efc",
        "type": "debug",
        "z": "d9f7633c.2608a",
        "name": "",
        "active": false,
        "console": "false",
        "complete": "true",
        "x": 1428.5078926086426,
        "y": 849.1111145019531,
        "wires": []
    },
    {
        "id": "38441961.c7bbe6",
        "type": "inject",
        "z": "d9f7633c.2608a",
        "name": "Manual Trigger",
        "topic": "",
        "payload": "F",
        "payloadType": "string",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 1005.2856636047363,
        "y": 723,
        "wires": [
            [
                "515b4a43.aea4b4",
                "b4aeee51.4b511",
                "769f27b5.8960d8"
            ]
        ]
    },
    {
        "id": "83ee2495.7c11d8",
        "type": "debug",
        "z": "d9f7633c.2608a",
        "name": "",
        "active": false,
        "console": "false",
        "complete": "true",
        "x": 1681.2856636047363,
        "y": 1436,
        "wires": []
    },
    {
        "id": "37f5231a.c80adc",
        "type": "serial-port",
        "serialport": "/dev/ttyUSB0",
        "serialbaud": "2400",
        "databits": "8",
        "parity": "none",
        "stopbits": "1",
        "newline": "85",
        "bin": "bin",
        "out": "time",
        "addchar": true
    }
]
liaan commented 8 years ago

Morning

Glad you got sorted, i've not been online for bit :)

L: