Node-red/influxdb/grafana

Hello,
looking for some help on an issue with Boolean values. Please look at the following flow. I am reading a few coils via modbus. I need help understanding why function 54 gives me the Boolean state and why function 55 gives me a result of undefined.

i also would like some guidance on how to use the state of one those values to control when data gets inserted into the influxdb node. the modbus read inject node is set at a 10 second interval but i only want the payload to be sent to the influxdb node when the first coil is true.
thank you
RL

[{"id":"c5d64fde3ae5ebb2","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"ca5e1bf1dcb8f846","type":"modbus-getter","z":"c5d64fde3ae5ebb2","name":"Modbus Read","showStatusActivities":false,"showErrors":false,"showWarnings":true,"logIOActivities":false,"unitid":"1","dataType":"HoldingRegister","adr":"0","quantity":"34","server":"842dfe00ccd6026a","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"delayOnStart":false,"startDelayTime":"","x":360,"y":100,"wires":[["5ff4be2168359b27","ce1d43a6eb03e5bd"],[]]},{"id":"f804879126e95cd9","type":"debug","z":"c5d64fde3ae5ebb2","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":920,"y":120,"wires":[]},{"id":"5ff4be2168359b27","type":"modbus-response","z":"c5d64fde3ae5ebb2","name":"","registerShowMax":20,"x":610,"y":40,"wires":[]},{"id":"ce1d43a6eb03e5bd","type":"function","z":"c5d64fde3ae5ebb2","name":"function 1","func":"msg.payload = {\n\"Reactor1OvenTemp\":msg.payload[0],\n\"Reactor1HeadTemp\":msg.payload[1],\n\"Reactor1Product1Temp\":msg.payload[2],\n\"Reactor1Product2Temp\":msg.payload[3],\n\"Reactor1PSI\":msg.payload[4]/10,\n\"Reactor2OvenTemp\":msg.payload[5],\n\"Reactor2HeadTemp\":msg.payload[6],\n\"Reactor2Product1Temp\":msg.payload[7],\n\"Reactor2Product2Temp\":msg.payload[8],\n\"Reactor2PSI\":msg.payload[9]/10,\n\"Tank1HeadTemp\":msg.payload[10],\n\"Tank1ProductTemp\":msg.payload[11],\n\"Tank1PSI\":msg.payload[12]/10,\n\"Tank1Level\":msg.payload[13]/10,\n\"Tank1ValvePosition\":msg.payload[14],\n\"Tank2HeadTemp\":msg.payload[15],\n\"Tank2ProductTemp\":msg.payload[16],\n\"Tank2PSI\":msg.payload[17]/10,\n\"Tank2Level\":msg.payload[18]/10,\n\"Tank2ValvePosition\":msg.payload[19],\n\"Tank3HeadTemp\":msg.payload[20],\n\"Tank3ProductTemp\":msg.payload[21],\n\"Tank3PSI\":msg.payload[22]/10,\n\"Tank3ValvePosition\":msg.payload[23],\n\"Tank4HeadTemp\":msg.payload[24],\n\"Tank4PSI\":msg.payload[25]/10,\n\"DieselRate\":msg.payload[26],\n\"DieselTotalizer\":msg.payload[27],\n\"GasRate\":msg.payload[28],\n\"GasTotalizer\":msg.payload[29],\n\"LPGRate\":msg.payload[30],\n\"LPGTotalizer\":msg.payload[31],\n\"LPGWRate\":msg.payload[32],\n\"LPGWTotalizer\":msg.payload[33],\n}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":580,"y":160,"wires":[["452ead9b781a1c18","f804879126e95cd9"]]},{"id":"452ead9b781a1c18","type":"influxdb out","z":"c5d64fde3ae5ebb2","influxdb":"a89fde24a47726a7","name":"InfluxDB","measurement":"Test","precision":"","retentionPolicy":"","database":"database","precisionV18FluxV20":"s","retentionPolicyV18Flux":"","org":"Dev","bucket":"SampleCompany","x":800,"y":220,"wires":[]},{"id":"58ed173b64a4e72d","type":"inject","z":"c5d64fde3ae5ebb2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"iso","payloadType":"date","x":160,"y":100,"wires":[["ca5e1bf1dcb8f846"]]},{"id":"a2353dfd4e2f49eb","type":"inject","z":"c5d64fde3ae5ebb2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":420,"wires":[["2bd23a139af31e99"]]},{"id":"2bd23a139af31e99","type":"modbus-getter","z":"c5d64fde3ae5ebb2","name":"","showStatusActivities":false,"showErrors":false,"showWarnings":true,"logIOActivities":false,"unitid":"1","dataType":"Coil","adr":"0","quantity":"10","server":"701a340b0e9a1a28","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"delayOnStart":false,"startDelayTime":"","x":320,"y":420,"wires":[["7225fac87a12b13c"],["a77d2e34f9bf26dc","d5df637a6014a6c1"]]},{"id":"7225fac87a12b13c","type":"modbus-response","z":"c5d64fde3ae5ebb2","name":"","registerShowMax":20,"x":550,"y":340,"wires":[]},{"id":"a77d2e34f9bf26dc","type":"function","z":"c5d64fde3ae5ebb2","name":"function 54","func":"var coils = msg.payload.data //this line stores the modbus data in a variable called coils\nmsg.payload = {\n    'coil': coils,\n}\nreturn msg","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":480,"wires":[["3528b9b491df9887"]]},{"id":"3528b9b491df9887","type":"debug","z":"c5d64fde3ae5ebb2","name":"debug 6","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":720,"y":420,"wires":[]},{"id":"d5df637a6014a6c1","type":"function","z":"c5d64fde3ae5ebb2","name":"function 55","func":"msg.payload = {\n\"SystemStatus\":msg.payload[0],\n\n}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":540,"wires":[["45e8105bd08af917"]]},{"id":"45e8105bd08af917","type":"debug","z":"c5d64fde3ae5ebb2","name":"debug 7","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":740,"y":520,"wires":[]},{"id":"842dfe00ccd6026a","type":"modbus-client","name":"Productivity1000","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"failureLogEnabled":true,"tcpHost":"192.168.0.103","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","serialAsciiResponseStartDelimiter":"0x3A","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true,"showErrors":false,"showWarnings":true,"showLogs":true},{"id":"a89fde24a47726a7","type":"influxdb","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"database","name":"InfluxDB","usetls":false,"tls":"","influxdbVersion":"2.0","url":"https://us-east-1-1.aws.cloud2.influxdata.com/","timeout":"10","rejectUnauthorized":true},{"id":"701a340b0e9a1a28","type":"modbus-client","name":"Productivity1000","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"failureLogEnabled":true,"tcpHost":"192.168.0.103","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","serialAsciiResponseStartDelimiter":"0x3A","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true,"showErrors":false,"showWarnings":true,"showLogs":true}]type or paste code here

Hello, i figured out the first part of my question. now i just need help with the second part of the question.
thanks
RL

Have a look at node-red-contrib-simple-gate. You can use that to block the messages to influx when the coil is false.

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