Hi all,
I have a flow that seems to work perfectly when freshly deployed, but after 12-18 hours it stops functioning a little bit at a time. I have several MQTT outputs and they slowly stop output to MQTT 1 node at a time.
Every 3 seconds I read from a Sqlite DB, do some calculation and then output multiple values to multiple MQTT topics. I've tried debugging and noticed it's the MQTT output nodes that stop functioning. No errors. I've monitored the MQTT topic and they just stop sending to the topic.
I feel maybe there is a memory leak or some sort since the issue beings after 12 hours and slowly gets worst. I then restart the flow or Node-Red and everything goes back on track. Can anyone see something wrong with the flow that I can't work out?
[{"id":"783a9a31.763adc","type":"tab","label":"Energy Monitoring","disabled":false,"info":""},{"id":"2dacabfa.dd15b4","type":"debug","z":"783a9a31.763adc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":850,"y":480,"wires":[]},{"id":"c1055df0.d5faf","type":"sqlite","z":"783a9a31.763adc","mydb":"c756d476.c7bab8","sqlquery":"fixed","sql":"SELECT * FROM vwOffGridSummary_ForHassIO","name":"SBFspot","x":365,"y":160,"wires":[["673666cc.c19458","a19e2173.aea6d","3d3aaa3a.8cffc6","5c423bde.34ba34","8ef867d5.48cfe8","808021c4.ca15a","b6820e32.8eca6","4fc0f35f.f1ec5c"]]},{"id":"139e72cb.c6518d","type":"inject","z":"783a9a31.763adc","name":"3 sec timer","topic":"Go","payload":"","payloadType":"date","repeat":"3","crontab":"","once":true,"onceDelay":"1","x":175,"y":160,"wires":[["c1055df0.d5faf"]]},{"id":"673666cc.c19458","type":"function","z":"783a9a31.763adc","name":"Separate the Battery SOC","func":"var val = (msg.payload[0].acBatSOC).toFixed(1);\nreturn { payload : val };\n","outputs":1,"noerr":0,"x":590,"y":200,"wires":[["d5171794.b4f9c8"]]},{"id":"d5171794.b4f9c8","type":"mqtt out","z":"783a9a31.763adc","name":"Store SOC in MQTT","topic":"energy/batteries/soc","qos":"2","retain":"true","broker":"13ec852f.ee6993","x":960,"y":200,"wires":[]},{"id":"a19e2173.aea6d","type":"function","z":"783a9a31.763adc","name":"Separate the Battery Voltage","func":"var val = (msg.payload[0].acBatVoltage).toFixed(1);\nreturn { payload : val };\n","outputs":1,"noerr":0,"x":600,"y":240,"wires":[["bc402dfe.bf364"]]},{"id":"bc402dfe.bf364","type":"mqtt out","z":"783a9a31.763adc","name":"Store Battery Voltage in MQTT","topic":"energy/batteries/voltage","qos":"2","retain":"true","broker":"13ec852f.ee6993","x":990,"y":240,"wires":[]},{"id":"3d3aaa3a.8cffc6","type":"function","z":"783a9a31.763adc","name":"Separate the Battery Load Power Kw","func":"var val = -((msg.payload[0].acBatVoltage * msg.payload[0].acBatCurrentTot)/1000).toFixed(2);\nreturn { payload : val };\n","outputs":1,"noerr":0,"x":630,"y":360,"wires":[["2dacabfa.dd15b4","6a77c8ab.5f3d88"]]},{"id":"5c423bde.34ba34","type":"function","z":"783a9a31.763adc","name":"Separate the Battery Temperature","func":"var val = (msg.payload[0].acBatTemperature).toFixed(1);\nreturn { payload : val };\n","outputs":1,"noerr":0,"x":620,"y":320,"wires":[["7c8c4147.d346b"]]},{"id":"f9562e0d.58b26","type":"comment","z":"783a9a31.763adc","name":"Field value deffinitions","info":"vwOffGridSummary_ForHassIO\n--------------------------\ndcTimestamp = Last time the SB reported\ndcName = SB Name\ndcType = SB Type\ndcSerial = SB Serial Number\ndcPowerTot = SB Power in Watts\ndcCurrentTot = SB Current in Amps\ndcEToday = SB Total energy produced Today (Watts)\ndcETotal = SB Total energy produced Ever (Watts)\ndcAC_Frequency = SI AC Frequency\nacTimestamp = Last time the SI reported\nacName = SI Name\nacSerial - SI Serial Number\nacBatTemperature = SI Battery Temperature\nacBatCurrentTot = SI Battery Load (Amps)\nacBatSOC = SI Battery State of Charge in %\nasBatVoltage = SI Battery Voltage","x":340,"y":120,"wires":[]},{"id":"b6820e32.8eca6","type":"function","z":"783a9a31.763adc","name":"Separate the PV Power","func":"var val = (msg.payload[0].dcPowerTot/1000).toFixed(2);\nreturn { payload : val };\n","outputs":1,"noerr":0,"x":590,"y":80,"wires":[["6a27dc13.67f1d4"]]},{"id":"808021c4.ca15a","type":"function","z":"783a9a31.763adc","name":"Separate the PV Current","func":"var val = (msg.payload[0].dcCurrentTot).toFixed(1);\nreturn { payload : val };\n","outputs":1,"noerr":0,"x":590,"y":120,"wires":[["15e8afdc.cc8e"]]},{"id":"8ef867d5.48cfe8","type":"function","z":"783a9a31.763adc","name":"Separate the Battery Load Current (Amp)","func":"var val = msg.payload[0].acBatCurrentTot.toFixed(1);\nreturn { payload : val };\n","outputs":1,"noerr":0,"x":640,"y":280,"wires":[["8a4b3028.41e1c"]]},{"id":"8a4b3028.41e1c","type":"mqtt out","z":"783a9a31.763adc","name":"Store Load Current in MQTT","topic":"energy/batteries/loadCurrent","qos":"2","retain":"true","broker":"13ec852f.ee6993","x":980,"y":280,"wires":[]},{"id":"15e8afdc.cc8e","type":"mqtt out","z":"783a9a31.763adc","name":"Store PV Current in MQTT","topic":"energy/batteries/pvCurrent","qos":"2","retain":"true","broker":"13ec852f.ee6993","x":975,"y":120,"wires":[]},{"id":"6a27dc13.67f1d4","type":"mqtt out","z":"783a9a31.763adc","name":"Store PV Power in MQTT","topic":"energy/batteries/pvPower","qos":"2","retain":"true","broker":"13ec852f.ee6993","x":965,"y":80,"wires":[]},{"id":"4fc0f35f.f1ec5c","type":"function","z":"783a9a31.763adc","name":"Separate the House Load Kw","func":"var valPVPower = (msg.payload[0].dcPowerTot/1000).toFixed(2);\nvar valBatteryLoad = -((msg.payload[0].acBatVoltage * msg.payload[0].acBatCurrentTot)/1000).toFixed(2);\n\nreturn { payload : valPVPower - valBatteryLoad };\n","outputs":1,"noerr":0,"x":600,"y":160,"wires":[["e3841b6d.f03658"]]},{"id":"e3841b6d.f03658","type":"mqtt out","z":"783a9a31.763adc","name":"House Load Current in MQTT","topic":"energy/batteries/houseLoad","qos":"2","retain":"true","broker":"13ec852f.ee6993","x":990,"y":160,"wires":[]},{"id":"6a77c8ab.5f3d88","type":"mqtt out","z":"783a9a31.763adc","name":"Store Load Power in MQTT","topic":"energy/batteries/power","qos":"2","retain":"true","broker":"13ec852f.ee6993","x":980,"y":360,"wires":[]},{"id":"7c8c4147.d346b","type":"mqtt out","z":"783a9a31.763adc","name":"Store Battery Temperatures in MQTT","topic":"energy/batteries/temperature","qos":"2","retain":"true","broker":"13ec852f.ee6993","x":1010,"y":320,"wires":[]},{"id":"2d1ef4d9.0d129c","type":"comment","z":"783a9a31.763adc","name":"These always work fine","info":"","x":580,"y":40,"wires":[]},{"id":"b021d2a3.ebf32","type":"comment","z":"783a9a31.763adc","name":"These stop sending to MQTT after a few hours.","info":"","x":1020,"y":40,"wires":[]},{"id":"470e79f3.bc4b98","type":"comment","z":"783a9a31.763adc","name":"This debug always shows the correct value without missing a beat.","info":"","x":1020,"y":440,"wires":[]},{"id":"c756d476.c7bab8","type":"sqlitedb","z":"","db":"C:\\Users\\Public\\SMAdata\\SBFspot.db","mode":"RWC"},{"id":"13ec852f.ee6993","type":"mqtt-broker","z":"","name":"Surfy","broker":"192.168.1.82","port":"1883","clientid":"Node-Red Surfy","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]