Order serial data for csv

I think you can see for yourself that it is better, as it has values for the individual columns. The query generator in the chart panel in grafana should let you select which columns to chart. For each line on the chart you should have something like this (tydwr is the measurement name).

It's blank!

Screenshot 2020-02-16 at 22.03.13|690x166

Can you suggest where I should look?

What do you see if you click on the Data Source dropdown? By the way, you can just paste an image in directly rather than attaching a file.

Since my last post I have deleted the "Data Sources" and re-selected which has changed things slightly. Here the images, (copy and paste isn't working for me.
Screenshot 2020-02-16 at 22.21.29

That's ok then. Is it working?
You should see the fields if you click on the Select box

No.

Should there be anything in the "Where" or should I type in the field name?

As you can see from the one I posted I have not added a where clause, it is not needed for simple cases like yours. As I said, click on the Select box drop down and it should show you a list of fields. You need one query for each line on the graph (well actually you may not but start off doing it that way).

Thanks for all your help, all sorted now. I just need to learn what can be done with Grafana.

Below it a copy from terminal "SELECT * FROM Victron LIMIT nn" gives the this.
1581918895227702529 0 0 0 0 0 0.01 0 0 0
1581918895243752644 0 0 0 0 0 0.01 0 0 0
1581918955241515082 0 0 0 0 0 0.01 0 0 0
1581918955378653890 OFF
0
13.511 0 0 0 13.506 100 -1
1581919015438002085 OFF
0
13.512 0 0 0 13.506 100 -1
1581919015484108316 OFF
0
13.512 0 0 0 13.506 100 -1
1581919075521957964 OFF
0
13.511 0 0 0 13.506 100 -1
1581919075567413570 OFF
0
13.511 0 0 0 13.506 100 -1
1581919135617935999 OFF
0
13.513 0 0 0 13.506 100 -1
1581919135673100099 OFF
0
13.513 0 0 0 13.506 100 -1
1581919195725658205 0 0 0 0 0 0.01 0 0 0
1581919195735040453 0 0 0 0 0 0.01 0 0 0

I would have expected it to be displayed in one line starting with the timestamp and followed by all the collected data. But mine appears to be a on a number of lines. Also it doesn't appear to alternate between the two usb devices.

Am I correct?

I've attached my code with the latest changes.

[{"id":"43fa7db7.c87434","type":"tab","label":"ChargerLogger","disabled":false,"info":""},{"id":"d086478.7242db8","type":"function","z":"43fa7db7.c87434","name":"ExtractDataBMV712","func":"var data = msg.payload.split(\"\\t\");\nswitch(data[0]) { \n        case    'V':\n            MainBatVoltage = parseFloat(data[1]/1000);\n            break;\n        case    'VS':\n            AuxBatVoltage = parseFloat(data[1]/1000);\n            break;\n        case    'I':\n            BatteryCurrent = parseFloat(data[1]/1000);\n            break;\n        case    'P':\n            InstantaneousPower = parseInt(data[1]);\n            break;\n        case    'CE':\n            ConsumedAmpHours = parseFloat(data[1]/1000);\n            break;\n        case    'SOC':\n            SOC = parseFloat(data[1]/10);\n            break;\n        case    'TTG':\n            TimeToGo = parseFloat(data[1]);\n            break;\n        case    'Alarm':\n            AlarmCon = String(data[1]);\n            break;\n        case    'AR':\n            AlarmReason = String(data[1]);\n            break;\n            \n                }\nreturn  [\n    {\n        payload: {\n                MainBatVoltage: MainBatVoltage,\n                AuxBatVoltage: AuxBatVoltage,\n                BatteryCurrent: BatteryCurrent,\n                InstantaneousPower: InstantaneousPower,\n                ConsumedAmpHours: ConsumedAmpHours,\n                SOC: SOC,\n                TimeToGo: TimeToGo,\n                AlarmCon: AlarmCon,\n                AlarmReason: AlarmReason\n                    }\n    }\n]\n","outputs":1,"noerr":0,"x":200,"y":620,"wires":[["8fb36d9c.7c8ed","8145b8ea.f30008"]]},{"id":"948b01ce.c3bc6","type":"ui_text","z":"43fa7db7.c87434","group":"3fcc4874.77b7f8","order":3,"width":0,"height":0,"name":"Leisure Battery SOC (BMV)","label":"SOC %","format":"{{msg.payload.SOC | number:0}}","layout":"col-center","x":840,"y":120,"wires":[]},{"id":"92e69817.387bf8","type":"ui_text","z":"43fa7db7.c87434","group":"3fcc4874.77b7f8","order":1,"width":0,"height":0,"name":"Leisure Battery Volts (BMV)","label":"Volts","format":"{{msg.payload.MainBatVoltage | number:2}}","layout":"col-center","x":840,"y":40,"wires":[]},{"id":"c3bb298b.e9ab58","type":"ui_text","z":"43fa7db7.c87434","group":"3fcc4874.77b7f8","order":2,"width":0,"height":0,"name":"Leisure Battery Amps (BMV)","label":"Amps","format":"{{msg.payload.BatteryCurrent | number:2}}","layout":"col-center","x":840,"y":80,"wires":[]},{"id":"25c4feea.0d0ad2","type":"ui_text","z":"43fa7db7.c87434","group":"5f89a742.c39168","order":1,"width":0,"height":0,"name":"Starter Battery Volts (BMV)","label":"Volts","format":"{{msg.payload.AuxBatVoltage | number:2}}","layout":"col-center","x":840,"y":240,"wires":[]},{"id":"f0fb7a2d.18c178","type":"ui_text","z":"43fa7db7.c87434","group":"3fcc4874.77b7f8","order":3,"width":0,"height":0,"name":"Leisure Battery TTG (BMV)","label":"TTG","format":"{{msg.payload.TimeToGo}}","layout":"col-center","x":840,"y":160,"wires":[]},{"id":"3ed3337c.597fdc","type":"ui_chart","z":"43fa7db7.c87434","name":"Leisure Battery V (Web)","group":"ba16cc09.e9994","order":1,"width":0,"height":0,"label":"Volts","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"Some text","dot":false,"ymin":"10","ymax":"16","removeOlder":"6","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":830,"y":380,"wires":[[]]},{"id":"3aaf9cef.f6a0f4","type":"function","z":"43fa7db7.c87434","name":"Leisure Battery V extract","func":"msg.payload = msg.payload.MainBatVoltage;\nreturn msg;\n","outputs":1,"noerr":0,"x":830,"y":340,"wires":[["3ed3337c.597fdc"]]},{"id":"709276ea.6d2418","type":"function","z":"43fa7db7.c87434","name":"Leisure Battery A extract","func":"msg.payload = msg.payload.BatteryCurrent;\nreturn msg;","outputs":1,"noerr":0,"x":830,"y":420,"wires":[["a31433d2.b0e57"]]},{"id":"a31433d2.b0e57","type":"ui_chart","z":"43fa7db7.c87434","name":"Leisure Battery Amps (Web)","group":"ba16cc09.e9994","order":2,"width":0,"height":0,"label":"Amps","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"","dot":false,"ymin":"-50","ymax":"50","removeOlder":"6","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":840,"y":460,"wires":[[]]},{"id":"40d23927.6759a8","type":"ui_chart","z":"43fa7db7.c87434","name":"Leisure Battery SOC (Web)","group":"ba16cc09.e9994","order":3,"width":0,"height":0,"label":"SOC","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"110","removeOlder":"6","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":840,"y":540,"wires":[[]]},{"id":"9c4ad4ff.7d1518","type":"function","z":"43fa7db7.c87434","name":"Leisure Battery SOC extract","func":"msg.payload = msg.payload.SOC;\nreturn msg;","outputs":1,"noerr":0,"x":840,"y":500,"wires":[["40d23927.6759a8"]]},{"id":"11544f9c.8844","type":"function","z":"43fa7db7.c87434","name":"Starter Battery V extract","func":"msg.payload = msg.payload.AuxBatVoltage;\nreturn msg;","outputs":1,"noerr":0,"x":830,"y":580,"wires":[["9cd68c23.f3cd"]]},{"id":"9cd68c23.f3cd","type":"ui_chart","z":"43fa7db7.c87434","name":"Starter Battery Volts (Web)","group":"5ca09b48.127554","order":1,"width":0,"height":0,"label":"Volts","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"","dot":false,"ymin":"10","ymax":"16","removeOlder":"6","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":840,"y":620,"wires":[[]]},{"id":"ddea5ea0.f3cd9","type":"function","z":"43fa7db7.c87434","name":"ExtractDataMPPT","func":"var data = msg.payload.split(\"\\t\");\nswitch(data[0]) { \n        case    'CS':\n            StateOfOperation = parseFloat(data[1]);\n            break;\n        case    'VPV':\n            PanelVoltage = parseFloat(data[1]/1000);\n            break;\n        case    'PPV':\n            PanelPower = parseFloat(data[1]);\n            break;\n        case    'I':\n            BatteryAmps = parseInt(data[1]/1000);\n            break;\n        /*case    'Relay':\n            RelayState = parseFloat(data[1]);\n            break;*/\n        case    'H20':\n            YieldToday = parseFloat(data[1]/100);\n            break;\n        case    'H21':\n            MaxPtoday = parseInt(data[1]);\n            break;\n        case    'H22':\n            YieldYesterday = parseFloat(data[1]/100);\n            break;\n        case    'H23':\n            MaxPyesterday = parseFloat(data[1]);\n            break;\n        case    'ERR':\n            ErrorCode = parseFloat(data[1]);\n            break;\n                }\nreturn  [\n    {\n        payload: {\n                StateOfOperation: StateOfOperation,\n                PanelVoltage: PanelVoltage,\n                PanelPower: PanelPower,\n                BatteryAmps: BatteryAmps,\n                //RelayState: RelayState,\n                YieldToday: YieldToday,\n                MaxPtoday: MaxPtoday,\n                YieldYesterday: YieldYesterday,\n                MaxPyesterday: MaxPyesterday,\n                ErrorCode: ErrorCode\n                    }\n    }\n]","outputs":1,"noerr":0,"x":210,"y":820,"wires":[["46ae670c.baa078","7663bfc6.41668","8975da95.e31b78","8145b8ea.f30008"]]},{"id":"ef00795c.8a1668","type":"function","z":"43fa7db7.c87434","name":"State of operation","func":"if(msg.payload.StateOfOperation === 0)\n    {msg.payload = \"OFF\"}\nelse if(msg.payload.StateOfOperation === 1)\n    {msg.payload = \"FAULT\"}\nelse if(msg.payload.StateOfOperation === 3)\n    {msg.payload = \"Bulk\"}\nelse if(msg.payload.StateOfOperation === 4)\n    {msg.payload = \"Absorption\"}\nelse if(msg.payload.StateOfOperation === 5)\n    {msg.payload = \"Float\"}\nelse\n    {msg.payload = \"\"}    //do nothing\nreturn msg;","outputs":1,"noerr":0,"x":810,"y":880,"wires":[["f4a08d8c.a0c5e","3f10599b.02e1c6"]]},{"id":"f4a08d8c.a0c5e","type":"ui_text","z":"43fa7db7.c87434","group":"7595a526.d16c9c","order":1,"width":0,"height":0,"name":"State of Operation (Web)","label":"State","format":"{{msg.payload}}","layout":"row-spread","x":830,"y":920,"wires":[]},{"id":"cec0dfaa.f18c4","type":"ui_text","z":"43fa7db7.c87434","group":"7595a526.d16c9c","order":2,"width":0,"height":0,"name":"Panel Voltage (Web)","label":"Panel Voltage","format":"{{msg.payload.PanelVoltage | number:2}}","layout":"row-spread","x":820,"y":1000,"wires":[]},{"id":"3eb1c80a.645c88","type":"ui_text","z":"43fa7db7.c87434","group":"7595a526.d16c9c","order":5,"width":0,"height":0,"name":"Panel Power W (Web)","label":"Panel Power W","format":"{{msg.payload.PanelPower}}","layout":"row-spread","x":820,"y":1080,"wires":[]},{"id":"e844d230.83367","type":"ui_text","z":"43fa7db7.c87434","group":"7595a526.d16c9c","order":6,"width":0,"height":0,"name":"Yield Today kWh (Web)","label":"Yield Today kWh","format":"{{msg.payload.YieldToday}}","layout":"row-spread","x":830,"y":1220,"wires":[]},{"id":"21458ff0.40b79","type":"ui_text","z":"43fa7db7.c87434","group":"7595a526.d16c9c","order":7,"width":0,"height":0,"name":"Max Power Today W (Web)","label":"Max Power Today W","format":"{{msg.payload.MaxPtoday}}","layout":"row-spread","x":840,"y":1260,"wires":[]},{"id":"fdf49e69.ed59d","type":"ui_text","z":"43fa7db7.c87434","group":"7595a526.d16c9c","order":8,"width":0,"height":0,"name":"Yield Yesterday (Web)","label":"Yield Yesterday","format":"{{msg.payload.YieldYesterday}}","layout":"row-spread","x":820,"y":1300,"wires":[]},{"id":"37914dd7.08d312","type":"ui_text","z":"43fa7db7.c87434","group":"7595a526.d16c9c","order":9,"width":0,"height":0,"name":"Max Power Yesterday (Web)","label":"Max Power Yesterday","format":"{{msg.payload.MaxPyesterday}}","layout":"row-spread","x":840,"y":1340,"wires":[]},{"id":"c15eaa16.b4da78","type":"ui_text","z":"43fa7db7.c87434","group":"7595a526.d16c9c","order":10,"width":0,"height":0,"name":"MPPT Error Code (Web)","label":"Error Code","format":"{{msg.payload}}","layout":"row-spread","x":1070,"y":1540,"wires":[]},{"id":"b97d829f.aabe9","type":"function","z":"43fa7db7.c87434","name":"MPPT Error Code","func":"if(msg.payload.ErrorCode === 0)\n    {msg.payload = \"NONE\"}\nelse if(msg.payload.ErrorCode === 2)\n    {msg.payload = \"Battery voltage too high\"}\nelse if(msg.payload.ErrorCode === 17)\n    {msg.payload = \"Charger temperature too high\"}\nelse if(msg.payload.ErrorCode === 18)\n    {msg.payload = \"Charger over current\"}\nelse if(msg.payload.StateOfOperation === 19)\n    {msg.payload = \"Charger current reversed\"}\nelse if(msg.payload.ErrorCode === 20)\n    {msg.payload = \"Bulk time limit exceeded\"}\nelse if(msg.payload.ErrorCode === 21)\n    {msg.payload = \"Current sensor issue (sensor bias/sensor broken)\"}\nelse if(msg.payload.ErrorCode === 26)\n    {msg.payload = \"Terminals overheated\"}\nelse if(msg.payload.ErrorCode === 33)\n    {msg.payload = \"Input voltage too high (solar panel)\"}\nelse if(msg.payload.ErrorCode === 34)\n    {msg.payload = \"Input current too high (solar panel)\"}\nelse if(msg.payload.ErrorCode === 38)\n    {msg.payload = \"Input shutdown (due to excessive battery voltage)\"}\nelse if(msg.payload.ErrorCode === 116)\n    {msg.payload = \"Factory calibration data lost\"}\nelse if(msg.payload.ErrorCode === 117)\n    {msg.payload = \"Invalid/incompatible firmware\"}\nelse if(msg.payload.ErrorCode === 119)\n    {msg.payload = \"User settings invalid\"}\nelse\n    {msg.payload = \"\"}    //do nothing\nreturn msg;","outputs":1,"noerr":0,"x":810,"y":1500,"wires":[["c15eaa16.b4da78","9115109.e3a33f"]]},{"id":"9d45cbcb.307928","type":"ui_text","z":"43fa7db7.c87434","group":"5f89a742.c39168","order":2,"width":0,"height":0,"name":"BMV Alarm (BMV)","label":"BMV Alarm","format":"{{msg.payload}}","layout":"row-spread","x":810,"y":280,"wires":[]},{"id":"93ff3a1e.c0abe8","type":"function","z":"43fa7db7.c87434","name":"Alarm Reason","func":"if(msg.payload.AlarmReason >= 1)\n    {msg.payload = \"See manual \" + AlarmReason}\nelse\n    {msg.payload = \"No Alarm\"}\n/*if(msg.payload.AlarmReason === 1)\n    {msg.payload = \"Low Voltage\"}\nelse if(msg.payload.AlarmReason === 2)\n    {msg.payload = \"High Voltage\"}\nelse if(msg.payload.AlarmReason === 4)\n    {msg.payload = \"Low SOC\"}\nelse if(msg.payload.AlarmReason === 8)\n    {msg.payload = \"Low Starter Voltage\"}\nelse if(msg.payload.AlarmReason === 16)\n    {msg.payload = \"High Starter Voltage\"}\nelse if(msg.payload.AlarmReason === 32)\n    {msg.payload = \"Low Temperature\"}\nelse if(msg.payload.AlarmReason === 64)\n    {msg.payload = \"High Temperature\"}\nelse if(msg.payload.AlarmReason === 128)\n    {msg.payload = \"Mid Voltage\"}\nelse\n    {msg.payload = \"\"}    //do nothing\n    */\nreturn msg;","outputs":1,"noerr":0,"x":440,"y":240,"wires":[["9d45cbcb.307928"]]},{"id":"61cfe391.8216bc","type":"function","z":"43fa7db7.c87434","name":"TTG infinite","func":"if(msg.payload.TimeToGo === -1)\n    {msg.payload.TimeToGo = \"Infinite\"}\nelse if(msg.payload.TimeToGo === \"---\")\n    {msg.payload.TimeToGo = \"---\"}\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":160,"wires":[["f0fb7a2d.18c178"]]},{"id":"3f10599b.02e1c6","type":"ui_text","z":"43fa7db7.c87434","group":"b3c06fb5.d8985","order":1,"width":0,"height":0,"name":"State of Operation (BMV)","label":"State","format":"{{msg.payload}}","layout":"row-spread","x":870,"y":960,"wires":[]},{"id":"59b8eb7.829c214","type":"ui_text","z":"43fa7db7.c87434","group":"b3c06fb5.d8985","order":5,"width":0,"height":0,"name":"Panel Power W (BMV)","label":"Panel Watts","format":"{{msg.payload.PanelPower}}","layout":"row-spread","x":860,"y":1120,"wires":[]},{"id":"88fcc365.65155","type":"ui_text","z":"43fa7db7.c87434","group":"b3c06fb5.d8985","order":2,"width":0,"height":0,"name":"Panel Voltage (BMV)","label":"Panel Voltage","format":"{{msg.payload.PanelVoltage | number:2}}","layout":"row-spread","x":860,"y":1040,"wires":[]},{"id":"9115109.e3a33f","type":"ui_text","z":"43fa7db7.c87434","group":"b3c06fb5.d8985","order":5,"width":0,"height":0,"name":"MPPT Error Code (BMV)","label":"Error Code","format":"{{msg.payload}}","layout":"row-spread","x":1070,"y":1500,"wires":[]},{"id":"6b090dd6.5eb584","type":"serial in","z":"43fa7db7.c87434","name":"","serial":"b90a2efa.d1c1e","x":150,"y":680,"wires":[["d086478.7242db8","dacd5295.cfc12"]]},{"id":"a3b2bb83.b1f9d8","type":"serial in","z":"43fa7db7.c87434","name":"","serial":"ee60460c.fb5fc8","x":150,"y":760,"wires":[["ddea5ea0.f3cd9"]]},{"id":"9086c4b0.e9a658","type":"ui_text","z":"43fa7db7.c87434","group":"b3c06fb5.d8985","order":3,"width":0,"height":0,"name":"Panel Amps (BMV)","label":"Panel Amps","format":"{{msg.payload | number:2}}","layout":"row-spread","x":310,"y":1240,"wires":[]},{"id":"f4b05d8f.13c5a","type":"function","z":"43fa7db7.c87434","name":"Panel A = W / V","func":"var panelAmps = msg.payload.PanelPower / msg.payload.PanelVoltage;\n{msg.payload = panelAmps}\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":1180,"wires":[["9086c4b0.e9a658","d9d08b7b.f27038"]]},{"id":"d9d08b7b.f27038","type":"ui_text","z":"43fa7db7.c87434","group":"7595a526.d16c9c","order":3,"width":0,"height":0,"name":"Panel Amps (Web)","label":"Panel Amps","format":"{{msg.payload | number:2}}","layout":"row-spread","x":240,"y":1360,"wires":[]},{"id":"dacd5295.cfc12","type":"debug","z":"43fa7db7.c87434","name":"BMV Data","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":340,"y":480,"wires":[]},{"id":"f16ad309.7178c","type":"delay","z":"43fa7db7.c87434","d":true,"name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"5","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":280,"y":400,"wires":[[]]},{"id":"54fd14a5.62926c","type":"ui_text","z":"43fa7db7.c87434","group":"b3c06fb5.d8985","order":4,"width":0,"height":0,"name":"MPPT O/P Amps to LB (BMV)","label":"Battery Amps","format":"{{msg.payload.BatteryAmps | number:2}}","layout":"row-spread","x":850,"y":1420,"wires":[]},{"id":"21bc5b5f.733e24","type":"ui_text","z":"43fa7db7.c87434","group":"7595a526.d16c9c","order":4,"width":0,"height":0,"name":"MPPT O/P Amps to LB (Web)","label":"Battery Amps","format":"{{msg.payload.BatteryAmps | number:2}}","layout":"row-spread","x":850,"y":1460,"wires":[]},{"id":"6ddd1b32.0d6dc4","type":"ui_chart","z":"43fa7db7.c87434","name":"MPPT State (Web)","group":"5ca09b48.127554","order":3,"width":0,"height":0,"label":"MPPT State","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"10","removeOlder":"6","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":470,"y":1480,"wires":[[]]},{"id":"caf3b593.8ba728","type":"function","z":"43fa7db7.c87434","name":"MPPT State","func":"if(msg.payload.StateOfOperation === 0) //OFF\n    {msg.payload = 2.5} \nelse if(msg.payload.StateOfOperation === 1) //Fault\n    {msg.payload = 0}\nelse if(msg.payload.StateOfOperation === 3) //Bulk\n    {msg.payload = 10}\nelse if(msg.payload.StateOfOperation === 4) //Absorbtion\n    {msg.payload = 7.5}\nelse if(msg.payload.StateOfOperation === 5) //Float\n    {msg.payload = 5}\nelse\n    {}    //do nothing\nreturn msg;","outputs":1,"noerr":0,"x":270,"y":1480,"wires":[["6ddd1b32.0d6dc4"]]},{"id":"bf275376.b9e51","type":"debug","z":"43fa7db7.c87434","name":"influxdb","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1300,"y":640,"wires":[]},{"id":"46ae670c.baa078","type":"trigger","z":"43fa7db7.c87434","op1":"","op2":"","op1type":"pay","op2type":"payl","duration":"1","extend":false,"units":"min","reset":"","bytopic":"all","name":"","x":210,"y":920,"wires":[["c86cfa61.b0a998","cec0dfaa.f18c4","3eb1c80a.645c88","e844d230.83367","21458ff0.40b79","fdf49e69.ed59d","37914dd7.08d312","21bc5b5f.733e24","b97d829f.aabe9","caf3b593.8ba728","54fd14a5.62926c"]]},{"id":"c86cfa61.b0a998","type":"debug","z":"43fa7db7.c87434","name":"MPPT Trigger","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":520,"y":880,"wires":[]},{"id":"7663bfc6.41668","type":"debug","z":"43fa7db7.c87434","name":"MPPT Direst","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":460,"y":720,"wires":[]},{"id":"b76a8cd3.549f9","type":"ui_template","z":"43fa7db7.c87434","group":"aa8a48ee.ad1e98","name":"Clock Toolbar","order":6,"width":"0","height":"0","format":"<script id=\"titleScript\" type=\"text/javascript\">\n    $('#clock').remove();\n    var toolbar = $('.md-toolbar-tools');\n    var div = $('<div/>');\n    var p = $('<p/ id=\"clock\">');\n    \n    $('#titleScript').parent().hide();\n    div.append(p);\n    div[0].style.margin = '5px 5px 5px auto';\n    toolbar.append(div);\n\n    function displayTitle(lh) {\n        p.text(lh); \n    }\n    \n    function upTime() {\n        var d = new Date();\n        p.text(d.toLocaleTimeString('de-AT'));\n    }\n\n    \n\n    // Watch the payload and update the title\n    (function(scope) {\n        scope.$watch('msg.payload', function(data) {\n            displayTitle(data);\n        });\n        setInterval(upTime,1000);\n    })(scope);\n</script>","storeOutMessages":false,"fwdInMessages":false,"templateScope":"local","x":180,"y":80,"wires":[[]]},{"id":"8fb36d9c.7c8ed","type":"trigger","z":"43fa7db7.c87434","op1":"","op2":"","op1type":"pay","op2type":"payl","duration":"1","extend":false,"units":"min","reset":"","bytopic":"all","name":"","x":250,"y":340,"wires":[["93ff3a1e.c0abe8","61cfe391.8216bc","11544f9c.8844","9c4ad4ff.7d1518","709276ea.6d2418","3aaf9cef.f6a0f4","25c4feea.0d0ad2","948b01ce.c3bc6","c3bb298b.e9ab58","92e69817.387bf8"]]},{"id":"8145b8ea.f30008","type":"trigger","z":"43fa7db7.c87434","op1":"","op2":"","op1type":"pay","op2type":"payl","duration":"1","extend":false,"units":"min","reset":"","bytopic":"all","name":"","x":890,"y":760,"wires":[["bf275376.b9e51","587672f2.13820c"]]},{"id":"8975da95.e31b78","type":"trigger","z":"43fa7db7.c87434","op1":"","op2":"","op1type":"pay","op2type":"payl","duration":"2","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":200,"y":980,"wires":[["59b8eb7.829c214","88fcc365.65155","ef00795c.8a1668","f4b05d8f.13c5a"]]},{"id":"c81922d9.c51df","type":"influxdb out","z":"43fa7db7.c87434","influxdb":"68a1df0d.8acb3","name":"Victron","measurement":"Victron","precision":"","retentionPolicy":"","x":1310,"y":760,"wires":[]},{"id":"587672f2.13820c","type":"json","z":"43fa7db7.c87434","name":"","property":"payload","action":"obj","pretty":false,"x":1130,"y":760,"wires":[["c81922d9.c51df","d7efd698.fdb1f8"]]},{"id":"d7efd698.fdb1f8","type":"debug","z":"43fa7db7.c87434","name":"Json Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1380,"y":860,"wires":[]},{"id":"3fcc4874.77b7f8","type":"ui_group","z":"","name":"Leisure Battery","tab":"74303f63.b1427","order":1,"disp":true,"width":"3","collapse":false},{"id":"5f89a742.c39168","type":"ui_group","z":"","name":"Starter Battery","tab":"74303f63.b1427","order":2,"disp":true,"width":"3","collapse":false},{"id":"ba16cc09.e9994","type":"ui_group","z":"","name":"Leisure Battery","tab":"3eec4b14.be2bf4","order":2,"disp":true,"width":6,"collapse":false},{"id":"5ca09b48.127554","type":"ui_group","z":"","name":"Starter Battery","tab":"3eec4b14.be2bf4","order":2,"disp":true,"width":"6","collapse":false},{"id":"7595a526.d16c9c","type":"ui_group","z":"","name":"MPPT Charger","tab":"3eec4b14.be2bf4","order":2,"disp":true,"width":"3","collapse":false},{"id":"b3c06fb5.d8985","type":"ui_group","z":"","name":"MPPT Charger","tab":"74303f63.b1427","order":3,"disp":true,"width":"3","collapse":false},{"id":"b90a2efa.d1c1e","type":"serial-port","z":"","serialport":"/dev/ttyUSB1","serialbaud":"19200","databits":"8","parity":"none","stopbits":"1","newline":"\\n","bin":"false","out":"char","addchar":false,"responsetimeout":"10000"},{"id":"ee60460c.fb5fc8","type":"serial-port","z":"","serialport":"/dev/ttyUSB0","serialbaud":"19200","databits":"8","parity":"none","stopbits":"1","newline":"\\n","bin":"false","out":"char","addchar":false,"responsetimeout":"10000"},{"id":"aa8a48ee.ad1e98","type":"ui_group","z":"","name":"Garage","tab":"74303f63.b1427","order":8,"disp":false,"width":"10"},{"id":"68a1df0d.8acb3","type":"influxdb","z":"","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"ChargerLogger3","name":"ChargerLogger3","usetls":false,"tls":""},{"id":"74303f63.b1427","type":"ui_tab","z":"","name":"BMV-700","icon":"MPPT","order":1,"disabled":false,"hidden":false},{"id":"3eec4b14.be2bf4","type":"ui_tab","z":"","name":"Web Portal","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

Some of the new lines may be due to folding, does it change if you change the width of the terminal. There will be gaps across the line for fields that are not provided for that timestamp. Also I notice that OFF always seems to be followed by a new line, perhaps the string you are writing has a newline on the end.
When trying to check all the data are there it might be easier to select just one of two fields and make sure they are there when they should be. In fact you should be able to see that from your graph.
When you say it is not alternating do you mean one set of data are missing?

Removing carriage returns from the two string results have improved things.

The terminal output looks better. I think it shows the data
1581953390605889487 OFF 0 13.554 0 0 0 13.563 100 -1
1581953450630017274 OFF 0 13.554 0 0 0 13.563 100 -1
1581953450695893192 OFF 0 13.554 0 0 0 13.563 100 -1
1581953510723110491 OFF 0 13.554 0 0 0 13.563 100 -1
1581953510816383193 OFF 0 13.554 0 0 0 13.563 100 -1
1581953570826934976 OFF 0 13.554 0 0 0 13.563 100 -1
1581953570897896819 OFF 0 13.554 0 0 0 13.563 100 -1
1581953630962184132 OFF 0 13.554 0 0 0 13.565 100 -1
1581953630983879268 OFF 0 13.554 0 0 0 13.565 100 -1
1581953691011715496 OFF 0 13.554 0 0 0 13.563 100 -1
1581953691035540313 1 0 37 0 23 17.41 4 0.04 0
1581953751041265437 1 0 37 0 23 17.99 4 0.04 0
1581953751046387295 1 0 37 0 23 17.99 4 0.04 0
1581953811044153452 1 0 37 0 23 18.13 4 0.04 0
1581953811064283073 1 0 37 0 23 18.13 4 0.04 0
1581953871061145203 1 0 37 0 23 17.99 4 0.05 0
1581953871381607279 OFF 0 13.554 0 0 0 13.563 100 -1
1581953931453000954 OFF 0 13.553 0 0 0 13.564 100 -1
1581953931538208020 OFF 0 13.553 0 0 0 13.564 100 -1

By alternating data I mean, data from USB0 followed by data from the USB1. Then there should be a 1 minute gap, then the next lot of data from USB0 - USB1. This image shows data from the two USB's and the times they were sent.

As you can see from the debug output that is not an influx issue, the problem is with the data coming in. They are not coming in pairs. So for example at 15:27:48 and 49 you have two of the StateOfOperation messages.

I suspect it is down to the Trigger node, you are sending both messages through that but because you have set Handling to All Messages it will not distinguish between the two streams. If you set Handling to treat each msg.topic independently, and make sure the two streams have different topics, then that might fix it. Alternatively, if they don't already have different topics, then feed them through separate triggers before joining them. In fact I notice you already have what appear to be identical trigger nodes separately on the two inputs so I think you could just feed those direct to the Influx node.

Also I notice that the two Extract function nodes are returning objects not JSON strings so you don't need the JSON node after the trigger.

1 Like

Firstly I would like to thank Colin and Karlbo for their help, it was much appreciated and helped in my first node-red project.

I now have node-red working with influxdb and Grafana. It's not finished and will grow with time.

The idea is to collect data from two Victron Energy products (yes they have their own web portal) and later an Ablemail B2B charger. I can now display the data I want on an LCD display and later review the data once again a thanks to Colin.

I have attached my code for others in the future. It's not the best but a good start for another beginner perhaps.

[{"id":"43fa7db7.c87434","type":"tab","label":"ChargerLogger","disabled":false,"info":""},{"id":"d086478.7242db8","type":"function","z":"43fa7db7.c87434","name":"ExtractDataBMV712","func":"var data = msg.payload.split(\"\\t\");\nswitch(data[0]) { \n        case    'V':\n            MainBatVoltage = parseFloat(data[1]/1000);\n            break;\n        case    'VS':\n            AuxBatVoltage = parseFloat(data[1]/1000);\n            break;\n        case    'I':\n            BatteryCurrent = parseFloat(data[1]/1000);\n            break;\n        case    'P':\n            InstantaneousPower = parseInt(data[1]);\n            break;\n        case    'CE':\n            ConsumedAmpHours = parseFloat(data[1]/1000);\n            break;\n        case    'SOC':\n            SOC = parseInt(data[1]/10);\n            break;\n        case    'TTG':\n            TimeToGo = parseFloat(data[1]);\n            break;\n        case    'Alarm':\n            AlarmCon = String(data[1]).replace( /[\\r\\n]+/gm, \"\" );\n            break;\n        case    'AR':\n            AlarmReason = String(data[1]).replace( /[\\r\\n]+/gm, \"\" );\n            break;\n            \n                }\nreturn  [\n    {\n        payload: {\n                MainBatVoltage: MainBatVoltage,\n                AuxBatVoltage: AuxBatVoltage,\n                BatteryCurrent: BatteryCurrent,\n                InstantaneousPower: InstantaneousPower,\n                ConsumedAmpHours: ConsumedAmpHours,\n                SOC: SOC,\n                TimeToGo: TimeToGo,\n                AlarmCon: AlarmCon,\n                AlarmReason: AlarmReason\n                    }\n    }\n]\n","outputs":1,"noerr":0,"x":200,"y":620,"wires":[["b5def214.4ef7b","f16ad309.7178c"]]},{"id":"948b01ce.c3bc6","type":"ui_text","z":"43fa7db7.c87434","group":"3fcc4874.77b7f8","order":3,"width":0,"height":0,"name":"Leisure Battery SOC (BMV)","label":"SOC %","format":"{{msg.payload.SOC | number:0}}","layout":"col-center","x":840,"y":120,"wires":[]},{"id":"92e69817.387bf8","type":"ui_text","z":"43fa7db7.c87434","group":"3fcc4874.77b7f8","order":1,"width":0,"height":0,"name":"Leisure Battery Volts (BMV)","label":"Volts","format":"{{msg.payload.MainBatVoltage | number:2}}","layout":"col-center","x":840,"y":40,"wires":[]},{"id":"c3bb298b.e9ab58","type":"ui_text","z":"43fa7db7.c87434","group":"3fcc4874.77b7f8","order":2,"width":0,"height":0,"name":"Leisure Battery Amps (BMV)","label":"Amps","format":"{{msg.payload.BatteryCurrent | number:2}}","layout":"col-center","x":840,"y":80,"wires":[]},{"id":"25c4feea.0d0ad2","type":"ui_text","z":"43fa7db7.c87434","group":"5f89a742.c39168","order":1,"width":0,"height":0,"name":"Starter Battery Volts (BMV)","label":"Volts","format":"{{msg.payload.AuxBatVoltage | number:2}}","layout":"col-center","x":840,"y":240,"wires":[]},{"id":"f0fb7a2d.18c178","type":"ui_text","z":"43fa7db7.c87434","group":"3fcc4874.77b7f8","order":3,"width":0,"height":0,"name":"Leisure Battery TTG (BMV)","label":"TTG","format":"{{msg.payload.TimeToGo}}","layout":"col-center","x":840,"y":160,"wires":[]},{"id":"3ed3337c.597fdc","type":"ui_chart","z":"43fa7db7.c87434","name":"Leisure Battery V (Web)","group":"ba16cc09.e9994","order":1,"width":0,"height":0,"label":"Volts","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"Some text","dot":false,"ymin":"10","ymax":"16","removeOlder":"6","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":830,"y":380,"wires":[[]]},{"id":"3aaf9cef.f6a0f4","type":"function","z":"43fa7db7.c87434","name":"Leisure Battery V extract","func":"msg.payload = msg.payload.MainBatVoltage;\nreturn msg;\n","outputs":1,"noerr":0,"x":830,"y":340,"wires":[["3ed3337c.597fdc"]]},{"id":"709276ea.6d2418","type":"function","z":"43fa7db7.c87434","name":"Leisure Battery A extract","func":"msg.payload = msg.payload.BatteryCurrent;\nreturn msg;","outputs":1,"noerr":0,"x":830,"y":420,"wires":[["a31433d2.b0e57"]]},{"id":"a31433d2.b0e57","type":"ui_chart","z":"43fa7db7.c87434","name":"Leisure Battery Amps (Web)","group":"ba16cc09.e9994","order":2,"width":0,"height":0,"label":"Amps","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"","dot":false,"ymin":"-50","ymax":"50","removeOlder":"6","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":840,"y":460,"wires":[[]]},{"id":"40d23927.6759a8","type":"ui_chart","z":"43fa7db7.c87434","name":"Leisure Battery SOC (Web)","group":"ba16cc09.e9994","order":3,"width":0,"height":0,"label":"SOC","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"110","removeOlder":"6","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":840,"y":540,"wires":[[]]},{"id":"9c4ad4ff.7d1518","type":"function","z":"43fa7db7.c87434","name":"Leisure Battery SOC extract","func":"msg.payload = msg.payload.SOC;\nreturn msg;","outputs":1,"noerr":0,"x":840,"y":500,"wires":[["40d23927.6759a8"]]},{"id":"11544f9c.8844","type":"function","z":"43fa7db7.c87434","name":"Starter Battery V extract","func":"msg.payload = msg.payload.AuxBatVoltage;\nreturn msg;","outputs":1,"noerr":0,"x":830,"y":580,"wires":[["9cd68c23.f3cd"]]},{"id":"9cd68c23.f3cd","type":"ui_chart","z":"43fa7db7.c87434","name":"Starter Battery Volts (Web)","group":"5ca09b48.127554","order":1,"width":0,"height":0,"label":"Volts","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"","dot":false,"ymin":"10","ymax":"16","removeOlder":"6","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":840,"y":620,"wires":[[]]},{"id":"ddea5ea0.f3cd9","type":"function","z":"43fa7db7.c87434","name":"ExtractDataMPPT","func":"var data = msg.payload.split(\"\\t\");\nswitch(data[0]) { \n        case    'CS':\n            StateOfOperation = parseFloat(data[1]);\n            break;\n        case    'VPV':\n            PanelVoltage = parseFloat(data[1]/1000);\n            break;\n        case    'PPV':\n            PanelPower = parseFloat(data[1]);\n            break;\n        case    'I':\n            BatteryAmps = parseInt(data[1]/1000);\n            break;\n        /*case    'Relay':\n            RelayState = parseFloat(data[1]);\n            break;*/\n        case    'H20':\n            YieldToday = parseFloat(data[1]/100);\n            break;\n        case    'H21':\n            MaxPtoday = parseInt(data[1]);\n            break;\n        case    'H22':\n            YieldYesterday = parseFloat(data[1]/100);\n            break;\n        case    'H23':\n            MaxPyesterday = parseFloat(data[1]);\n            break;\n        case    'ERR':\n            ErrorCode = parseFloat(data[1]);\n            break;\n                }\nreturn  [\n    {\n        payload: {\n                StateOfOperation: StateOfOperation,\n                PanelVoltage: PanelVoltage,\n                PanelPower: PanelPower,\n                BatteryAmps: BatteryAmps,\n                //RelayState: RelayState,\n                YieldToday: YieldToday,\n                MaxPtoday: MaxPtoday,\n                YieldYesterday: YieldYesterday,\n                MaxPyesterday: MaxPyesterday,\n                ErrorCode: ErrorCode\n                    }\n    }\n]","outputs":1,"noerr":0,"x":210,"y":820,"wires":[["7663bfc6.41668","d20d04e9.6ee458","89e38e3c.cbe4b","40f7c400.676fac"]]},{"id":"ef00795c.8a1668","type":"function","z":"43fa7db7.c87434","name":"State of operation","func":"if(msg.payload.StateOfOperation === 0)\n    {msg.payload = \"OFF\"}\nelse if(msg.payload.StateOfOperation === 1)\n    {msg.payload = \"FAULT\"}\nelse if(msg.payload.StateOfOperation === 3)\n    {msg.payload = \"Bulk\"}\nelse if(msg.payload.StateOfOperation === 4)\n    {msg.payload = \"Absorption\"}\nelse if(msg.payload.StateOfOperation === 5)\n    {msg.payload = \"Float\"}\nelse\n    {msg.payload = \"\"}    //do nothing\nreturn msg;","outputs":1,"noerr":0,"x":810,"y":880,"wires":[["f4a08d8c.a0c5e","3f10599b.02e1c6"]]},{"id":"f4a08d8c.a0c5e","type":"ui_text","z":"43fa7db7.c87434","group":"7595a526.d16c9c","order":1,"width":0,"height":0,"name":"State of Operation (Web)","label":"State","format":"{{msg.payload}}","layout":"row-spread","x":830,"y":920,"wires":[]},{"id":"cec0dfaa.f18c4","type":"ui_text","z":"43fa7db7.c87434","group":"7595a526.d16c9c","order":2,"width":0,"height":0,"name":"Panel Voltage (Web)","label":"Panel Voltage","format":"{{msg.payload.PanelVoltage | number:2}}","layout":"row-spread","x":820,"y":1000,"wires":[]},{"id":"3eb1c80a.645c88","type":"ui_text","z":"43fa7db7.c87434","group":"7595a526.d16c9c","order":5,"width":0,"height":0,"name":"Panel Power W (Web)","label":"Panel Power W","format":"{{msg.payload.PanelPower}}","layout":"row-spread","x":820,"y":1080,"wires":[]},{"id":"e844d230.83367","type":"ui_text","z":"43fa7db7.c87434","group":"7595a526.d16c9c","order":6,"width":0,"height":0,"name":"Yield Today kWh (Web)","label":"Yield Today kWh","format":"{{msg.payload.YieldToday}}","layout":"row-spread","x":830,"y":1220,"wires":[]},{"id":"21458ff0.40b79","type":"ui_text","z":"43fa7db7.c87434","group":"7595a526.d16c9c","order":7,"width":0,"height":0,"name":"Max Power Today W (Web)","label":"Max Power Today W","format":"{{msg.payload.MaxPtoday}}","layout":"row-spread","x":840,"y":1260,"wires":[]},{"id":"fdf49e69.ed59d","type":"ui_text","z":"43fa7db7.c87434","group":"7595a526.d16c9c","order":8,"width":0,"height":0,"name":"Yield Yesterday (Web)","label":"Yield Yesterday","format":"{{msg.payload.YieldYesterday}}","layout":"row-spread","x":820,"y":1300,"wires":[]},{"id":"37914dd7.08d312","type":"ui_text","z":"43fa7db7.c87434","group":"7595a526.d16c9c","order":9,"width":0,"height":0,"name":"Max Power Yesterday (Web)","label":"Max Power Yesterday","format":"{{msg.payload.MaxPyesterday}}","layout":"row-spread","x":840,"y":1340,"wires":[]},{"id":"c15eaa16.b4da78","type":"ui_text","z":"43fa7db7.c87434","group":"7595a526.d16c9c","order":10,"width":0,"height":0,"name":"MPPT Error Code (Web)","label":"Error Code","format":"{{msg.payload}}","layout":"row-spread","x":1070,"y":1540,"wires":[]},{"id":"b97d829f.aabe9","type":"function","z":"43fa7db7.c87434","name":"MPPT Error Code","func":"if(msg.payload.ErrorCode === 0)\n    {msg.payload = \"NONE\"}\nelse if(msg.payload.ErrorCode === 2)\n    {msg.payload = \"Battery voltage too high\"}\nelse if(msg.payload.ErrorCode === 17)\n    {msg.payload = \"Charger temperature too high\"}\nelse if(msg.payload.ErrorCode === 18)\n    {msg.payload = \"Charger over current\"}\nelse if(msg.payload.StateOfOperation === 19)\n    {msg.payload = \"Charger current reversed\"}\nelse if(msg.payload.ErrorCode === 20)\n    {msg.payload = \"Bulk time limit exceeded\"}\nelse if(msg.payload.ErrorCode === 21)\n    {msg.payload = \"Current sensor issue (sensor bias/sensor broken)\"}\nelse if(msg.payload.ErrorCode === 26)\n    {msg.payload = \"Terminals overheated\"}\nelse if(msg.payload.ErrorCode === 33)\n    {msg.payload = \"Input voltage too high (solar panel)\"}\nelse if(msg.payload.ErrorCode === 34)\n    {msg.payload = \"Input current too high (solar panel)\"}\nelse if(msg.payload.ErrorCode === 38)\n    {msg.payload = \"Input shutdown (due to excessive battery voltage)\"}\nelse if(msg.payload.ErrorCode === 116)\n    {msg.payload = \"Factory calibration data lost\"}\nelse if(msg.payload.ErrorCode === 117)\n    {msg.payload = \"Invalid/incompatible firmware\"}\nelse if(msg.payload.ErrorCode === 119)\n    {msg.payload = \"User settings invalid\"}\nelse\n    {msg.payload = \"\"}    //do nothing\nreturn msg;","outputs":1,"noerr":0,"x":810,"y":1500,"wires":[["c15eaa16.b4da78","9115109.e3a33f"]]},{"id":"9d45cbcb.307928","type":"ui_text","z":"43fa7db7.c87434","group":"5f89a742.c39168","order":2,"width":0,"height":0,"name":"BMV Alarm (BMV)","label":"BMV Alarm","format":"{{msg.payload}}","layout":"row-spread","x":810,"y":280,"wires":[]},{"id":"93ff3a1e.c0abe8","type":"function","z":"43fa7db7.c87434","name":"Alarm Reason","func":"if(msg.payload.AlarmReason >= 1)\n    {msg.payload = \"See manual \" + AlarmReason}\nelse\n    {msg.payload = \"No Alarm\"}\n/*if(msg.payload.AlarmReason === 1)\n    {msg.payload = \"Low Voltage\"}\nelse if(msg.payload.AlarmReason === 2)\n    {msg.payload = \"High Voltage\"}\nelse if(msg.payload.AlarmReason === 4)\n    {msg.payload = \"Low SOC\"}\nelse if(msg.payload.AlarmReason === 8)\n    {msg.payload = \"Low Starter Voltage\"}\nelse if(msg.payload.AlarmReason === 16)\n    {msg.payload = \"High Starter Voltage\"}\nelse if(msg.payload.AlarmReason === 32)\n    {msg.payload = \"Low Temperature\"}\nelse if(msg.payload.AlarmReason === 64)\n    {msg.payload = \"High Temperature\"}\nelse if(msg.payload.AlarmReason === 128)\n    {msg.payload = \"Mid Voltage\"}\nelse\n    {msg.payload = \"\"}    //do nothing\n    */\nreturn msg;","outputs":1,"noerr":0,"x":440,"y":240,"wires":[["9d45cbcb.307928"]]},{"id":"61cfe391.8216bc","type":"function","z":"43fa7db7.c87434","name":"TTG infinite","func":"if(msg.payload.TimeToGo === -1)\n    {msg.payload.TimeToGo = \"Infinite\"}\nelse if(msg.payload.TimeToGo === \"---\")\n    {msg.payload.TimeToGo = \"---\"}\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":160,"wires":[["f0fb7a2d.18c178"]]},{"id":"3f10599b.02e1c6","type":"ui_text","z":"43fa7db7.c87434","group":"b3c06fb5.d8985","order":1,"width":0,"height":0,"name":"State of Operation (BMV)","label":"State","format":"{{msg.payload}}","layout":"row-spread","x":870,"y":960,"wires":[]},{"id":"59b8eb7.829c214","type":"ui_text","z":"43fa7db7.c87434","group":"b3c06fb5.d8985","order":5,"width":0,"height":0,"name":"Panel Power W (BMV)","label":"Panel Watts","format":"{{msg.payload.PanelPower}}","layout":"row-spread","x":860,"y":1120,"wires":[]},{"id":"88fcc365.65155","type":"ui_text","z":"43fa7db7.c87434","group":"b3c06fb5.d8985","order":2,"width":0,"height":0,"name":"Panel Voltage (BMV)","label":"Panel Voltage","format":"{{msg.payload.PanelVoltage | number:2}}","layout":"row-spread","x":860,"y":1040,"wires":[]},{"id":"9115109.e3a33f","type":"ui_text","z":"43fa7db7.c87434","group":"b3c06fb5.d8985","order":5,"width":0,"height":0,"name":"MPPT Error Code (BMV)","label":"Error Code","format":"{{msg.payload}}","layout":"row-spread","x":1070,"y":1500,"wires":[]},{"id":"6b090dd6.5eb584","type":"serial in","z":"43fa7db7.c87434","name":"","serial":"b90a2efa.d1c1e","x":150,"y":680,"wires":[["d086478.7242db8","dacd5295.cfc12"]]},{"id":"a3b2bb83.b1f9d8","type":"serial in","z":"43fa7db7.c87434","name":"","serial":"ee60460c.fb5fc8","x":150,"y":760,"wires":[["ddea5ea0.f3cd9"]]},{"id":"9086c4b0.e9a658","type":"ui_text","z":"43fa7db7.c87434","group":"b3c06fb5.d8985","order":3,"width":0,"height":0,"name":"Panel Amps (BMV)","label":"Panel Amps","format":"{{msg.payload | number:2}}","layout":"row-spread","x":310,"y":1240,"wires":[]},{"id":"f4b05d8f.13c5a","type":"function","z":"43fa7db7.c87434","name":"Panel A = W / V","func":"var panelAmps = msg.payload.PanelPower / msg.payload.PanelVoltage;\n{msg.payload = panelAmps}\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":1180,"wires":[["9086c4b0.e9a658","d9d08b7b.f27038"]]},{"id":"d9d08b7b.f27038","type":"ui_text","z":"43fa7db7.c87434","group":"7595a526.d16c9c","order":3,"width":0,"height":0,"name":"Panel Amps (Web)","label":"Panel Amps","format":"{{msg.payload | number:2}}","layout":"row-spread","x":240,"y":1360,"wires":[]},{"id":"dacd5295.cfc12","type":"debug","z":"43fa7db7.c87434","name":"BMV Data","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":340,"y":480,"wires":[]},{"id":"f16ad309.7178c","type":"delay","z":"43fa7db7.c87434","name":"2min Faster update for Dashboard","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"2","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":240,"y":380,"wires":[["93ff3a1e.c0abe8","61cfe391.8216bc","92e69817.387bf8","c3bb298b.e9ab58","948b01ce.c3bc6","3aaf9cef.f6a0f4","709276ea.6d2418","9c4ad4ff.7d1518","11544f9c.8844","25c4feea.0d0ad2"]]},{"id":"54fd14a5.62926c","type":"ui_text","z":"43fa7db7.c87434","group":"b3c06fb5.d8985","order":4,"width":0,"height":0,"name":"MPPT O/P Amps to LB (BMV)","label":"Battery Amps","format":"{{msg.payload.BatteryAmps | number:2}}","layout":"row-spread","x":850,"y":1420,"wires":[]},{"id":"21bc5b5f.733e24","type":"ui_text","z":"43fa7db7.c87434","group":"7595a526.d16c9c","order":4,"width":0,"height":0,"name":"MPPT O/P Amps to LB (Web)","label":"Battery Amps","format":"{{msg.payload.BatteryAmps | number:2}}","layout":"row-spread","x":850,"y":1460,"wires":[]},{"id":"6ddd1b32.0d6dc4","type":"ui_chart","z":"43fa7db7.c87434","name":"MPPT State (Web)","group":"5ca09b48.127554","order":3,"width":0,"height":0,"label":"MPPT State","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"10","removeOlder":"6","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":470,"y":1480,"wires":[[]]},{"id":"caf3b593.8ba728","type":"function","z":"43fa7db7.c87434","name":"MPPT State","func":"if(msg.payload.StateOfOperation === 0) //OFF\n    {msg.payload = 2.5} \nelse if(msg.payload.StateOfOperation === 1) //Fault\n    {msg.payload = 0}\nelse if(msg.payload.StateOfOperation === 3) //Bulk\n    {msg.payload = 10}\nelse if(msg.payload.StateOfOperation === 4) //Absorbtion\n    {msg.payload = 7.5}\nelse if(msg.payload.StateOfOperation === 5) //Float\n    {msg.payload = 5}\nelse\n    {}    //do nothing\nreturn msg;","outputs":1,"noerr":0,"x":270,"y":1480,"wires":[["6ddd1b32.0d6dc4"]]},{"id":"c86cfa61.b0a998","type":"debug","z":"43fa7db7.c87434","name":"MPPT Trigger","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":520,"y":880,"wires":[]},{"id":"7663bfc6.41668","type":"debug","z":"43fa7db7.c87434","name":"MPPT Direst","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":460,"y":720,"wires":[]},{"id":"b76a8cd3.549f9","type":"ui_template","z":"43fa7db7.c87434","group":"aa8a48ee.ad1e98","name":"Clock Toolbar","order":6,"width":"0","height":"0","format":"<script id=\"titleScript\" type=\"text/javascript\">\n    $('#clock').remove();\n    var toolbar = $('.md-toolbar-tools');\n    var div = $('<div/>');\n    var p = $('<p/ id=\"clock\">');\n    \n    $('#titleScript').parent().hide();\n    div.append(p);\n    div[0].style.margin = '5px 5px 5px auto';\n    toolbar.append(div);\n\n    function displayTitle(lh) {\n        p.text(lh); \n    }\n    \n    function upTime() {\n        var d = new Date();\n        p.text(d.toLocaleTimeString('de-AT'));\n    }\n\n    \n\n    // Watch the payload and update the title\n    (function(scope) {\n        scope.$watch('msg.payload', function(data) {\n            displayTitle(data);\n        });\n        setInterval(upTime,1000);\n    })(scope);\n</script>","storeOutMessages":false,"fwdInMessages":false,"templateScope":"local","x":180,"y":80,"wires":[[]]},{"id":"c81922d9.c51df","type":"influxdb out","z":"43fa7db7.c87434","influxdb":"68a1df0d.8acb3","name":"Victron","measurement":"Victron","precision":"","retentionPolicy":"","x":1190,"y":780,"wires":[]},{"id":"587672f2.13820c","type":"json","z":"43fa7db7.c87434","name":"","property":"payload","action":"obj","pretty":false,"x":1010,"y":740,"wires":[["c81922d9.c51df","d7efd698.fdb1f8"]]},{"id":"d7efd698.fdb1f8","type":"debug","z":"43fa7db7.c87434","name":"Json Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1210,"y":700,"wires":[]},{"id":"b5def214.4ef7b","type":"delay","z":"43fa7db7.c87434","name":"BMV data limiter","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":800,"y":680,"wires":[["587672f2.13820c"]]},{"id":"d20d04e9.6ee458","type":"delay","z":"43fa7db7.c87434","name":"MPPT data limiter","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":810,"y":820,"wires":[["587672f2.13820c"]]},{"id":"89e38e3c.cbe4b","type":"delay","z":"43fa7db7.c87434","name":"2 sec update for Dashboard","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":180,"y":1040,"wires":[["ef00795c.8a1668","88fcc365.65155","59b8eb7.829c214","f4b05d8f.13c5a"]]},{"id":"40f7c400.676fac","type":"delay","z":"43fa7db7.c87434","name":"1 min update for Dashboard","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":180,"y":960,"wires":[["c86cfa61.b0a998","cec0dfaa.f18c4","3eb1c80a.645c88","e844d230.83367","21458ff0.40b79","fdf49e69.ed59d","37914dd7.08d312","54fd14a5.62926c","21bc5b5f.733e24","b97d829f.aabe9","caf3b593.8ba728"]]},{"id":"3fcc4874.77b7f8","type":"ui_group","z":"","name":"Leisure Battery","tab":"74303f63.b1427","order":1,"disp":true,"width":"3","collapse":false},{"id":"5f89a742.c39168","type":"ui_group","z":"","name":"Starter Battery","tab":"74303f63.b1427","order":2,"disp":true,"width":"3","collapse":false},{"id":"ba16cc09.e9994","type":"ui_group","z":"","name":"Leisure Battery","tab":"3eec4b14.be2bf4","order":2,"disp":true,"width":6,"collapse":false},{"id":"5ca09b48.127554","type":"ui_group","z":"","name":"Starter Battery","tab":"3eec4b14.be2bf4","order":2,"disp":true,"width":"6","collapse":false},{"id":"7595a526.d16c9c","type":"ui_group","z":"","name":"MPPT Charger","tab":"3eec4b14.be2bf4","order":2,"disp":true,"width":"3","collapse":false},{"id":"b3c06fb5.d8985","type":"ui_group","z":"","name":"MPPT Charger","tab":"74303f63.b1427","order":3,"disp":true,"width":"3","collapse":false},{"id":"b90a2efa.d1c1e","type":"serial-port","z":"","serialport":"/dev/ttyUSB1","serialbaud":"19200","databits":"8","parity":"none","stopbits":"1","newline":"\\n","bin":"false","out":"char","addchar":false,"responsetimeout":"10000"},{"id":"ee60460c.fb5fc8","type":"serial-port","z":"","serialport":"/dev/ttyUSB0","serialbaud":"19200","databits":"8","parity":"none","stopbits":"1","newline":"\\n","bin":"false","out":"char","addchar":false,"responsetimeout":"10000"},{"id":"aa8a48ee.ad1e98","type":"ui_group","z":"","name":"Garage","tab":"74303f63.b1427","order":8,"disp":false,"width":"10"},{"id":"68a1df0d.8acb3","type":"influxdb","z":"","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"ChargerLogger3","name":"ChargerLogger3","usetls":false,"tls":""},{"id":"74303f63.b1427","type":"ui_tab","z":"","name":"BMV-700","icon":"MPPT","order":1,"disabled":false,"hidden":false},{"id":"3eec4b14.be2bf4","type":"ui_tab","z":"","name":"Web Portal","icon":"dashboard","order":2,"disabled":false,"hidden":false}]
2 Likes

A couple of minor points you might like to consider.
It is good practice to reuse the same message rather than making a new one to return, so rather than

return  [
    {
        payload: {
                StateOfOperation: StateOfOperation,
                PanelVoltage: PanelVoltage,
                PanelPower: PanelPower,
                BatteryAmps: BatteryAmps,
                //RelayState: RelayState,
                YieldToday: YieldToday,
                MaxPtoday: MaxPtoday,
                YieldYesterday: YieldYesterday,
                MaxPyesterday: MaxPyesterday,
                ErrorCode: ErrorCode
                    }
    }
]

I suggest

msg.payload = {
                StateOfOperation: StateOfOperation,
                PanelVoltage: PanelVoltage,
                PanelPower: PanelPower,
                BatteryAmps: BatteryAmps,
                //RelayState: RelayState,
                YieldToday: YieldToday,
                MaxPtoday: MaxPtoday,
                YieldYesterday: YieldYesterday,
                MaxPyesterday: MaxPyesterday,
                ErrorCode: ErrorCode
}
return msg

Also I see you still have the JSON node before the influx node. I don't think it is necessary, the payload is already a javascript object so a JSON node set to Allways Convert To Javascript Object does nothing.

Thanks Colin.

I have removed the JSON node as I see it wasn't doing anything.

I do admit to not understanding how the return msg part makes a difference but it works, more reading!

msg.payload object contains { StateOfOperation: 0,

Is it possible to read the object with something like an 'if else' function and change the value to StateOfOperation: 4 and keeping the rest of the msg.payload the same?

There are 'function' and 'change' nodes but I haven't managed to work it out.

Start by reading through the node red docs page on Working With Messages. That should show you how to do it.

Thank you, all working now. I must have tried a hundreds searches but not "working with messages"!

So simple.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.