This is my Node-RED flow to listen to “Server B” output from a Solis Inverter monitoring Stick (based on SolarMan so applicable to many others?)
The TCP listener is set to output a single buffer after the connection closes
If it is a “full” message, it is processed and simultaneously resets the “zero at dusk” timer (messages are arriving each minute during operation, but if nothing come for 3 minutes, I want zero sending to some of the sensor values instead of the last value from the inverter before it switched off). Some values, I have added limits before they are passed to the HA sensor entities.
Shorter messages write a timestamp in a file and then 1 second later the (short) buffer is converted to bytes and added to the same file ending with a newline (ready for the next “unknown” message)
[{"id":"e768bff5.d22008","type":"tab","label":"Ginlong Listner","disabled":false,"info":""},{"id":"6b44baba.560034","type":"tcp in","z":"e768bff5.d22008","name":"Listen on tcp:9999","server":"server","host":"","port":"9999","datamode":"single","datatype":"buffer","newline":"","topic":"","base64":false,"x":90,"y":20,"wires":[["d4484a36.76cb98"]]},{"id":"a388b753.9e0fd","type":"buffer-parser","z":"e768bff5.d22008","name":"Extract Data","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint32le","name":"MonitorSN","offset":21,"length":1,"offsetbit":0,"scale":"/1","mask":""},{"type":"uint32le","name":"Uptime","offset":28,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"ascii","name":"InvSN","offset":46,"length":15,"offsetbit":0,"scale":"1","mask":""},{"type":"uint16le","name":"InvTemp","offset":62,"length":1,"offsetbit":0,"scale":"/10","mask":""},{"type":"uint16le","name":"vDC1","offset":64,"length":1,"offsetbit":0,"scale":"/10","mask":""},{"type":"uint16le","name":"vDC2","offset":66,"length":1,"offsetbit":0,"scale":"/10","mask":""},{"type":"uint8","name":"iDC1","offset":68,"length":1,"offsetbit":0,"scale":"/10","mask":""},{"type":"uint8","name":"iDC2","offset":70,"length":1,"offsetbit":0,"scale":"/10","mask":""},{"type":"uint8","name":"iAC","offset":76,"length":1,"offsetbit":0,"scale":"/10","mask":""},{"type":"uint16le","name":"ACVolts","offset":82,"length":1,"offsetbit":0,"scale":"/10","mask":""},{"type":"uint16le","name":"ACFreq","offset":84,"length":1,"offsetbit":0,"scale":"/100","mask":""},{"type":"uint16le","name":"ActiveAC","offset":86,"length":1,"offsetbit":0,"scale":"/1","mask":""},{"type":"uint16le","name":"DailyGen","offset":90,"length":1,"offsetbit":0,"scale":"/100","mask":""},{"type":"uint16le","name":"TotalGen","offset":94,"length":1,"offsetbit":0,"scale":"/10","mask":""},{"type":"uint16le","name":"vDCTotal","offset":122,"length":1,"offsetbit":0,"scale":"/10","mask":""},{"type":"uint16le","name":"PowerDC","offset":130,"length":1,"offsetbit":0,"scale":"/1","mask":""},{"type":"uint32le","name":"MonGen","offset":134,"length":1,"offsetbit":0,"scale":"/1","mask":""},{"type":"uint32le","name":"PrevMonthGen","offset":138,"length":1,"offsetbit":0,"scale":"/1","mask":""},{"type":"uint16le","name":"GridApparent","offset":156,"length":1,"offsetbit":0,"scale":"/1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"value","resultTypeType":"output","multipleResult":true,"fanOutMultipleResult":true,"setTopic":false,"outputs":19,"x":330,"y":300,"wires":[["c9c39dc9.dd9d5"],["e90ba7ca.47439"],["153df06d.3647b"],["e9e8a866.67c818"],["1d60c72b.5f0dd9"],["bbfcab1d.d4b9c"],["27c6ba79.cda9d6"],["8f567510.99ea1"],["ee7bfe0d.a7dee8"],["fbbb2954.ce1eb"],["5ce3f42.ff19a8c"],["c70a2d38.01b33"],["63c633cd.2c3d2c"],["667737ff.8e8178"],["3fdd5462.947934"],["6cccfd33.29133c"],["62b3c499.996fd4"],["533cfa00.4edcc"],["960d90ec.e72b98"]]},{"id":"cbc1b03e.563ec","type":"buffer-parser","z":"e768bff5.d22008","name":"Convert to Bytes","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"byte","name":"RawData","offset":0,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"value","resultTypeType":"output","multipleResult":true,"fanOutMultipleResult":false,"setTopic":false,"outputs":1,"x":330,"y":1120,"wires":[["c49f8a24.bbef7"]],"inputLabels":["buffer"]},{"id":"c49f8a24.bbef7","type":"file","z":"e768bff5.d22008","name":"Save Unknown Messages","filename":"/config/UnknownSolisMessages.csv","appendNewline":true,"createDir":true,"overwriteFile":"false","encoding":"none","x":570,"y":1120,"wires":[[]]},{"id":"1d60c72b.5f0dd9","type":"ha-entity","z":"e768bff5.d22008","name":"Solis_vDC1","server":"5eeae6ca.21b668","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Inverter DC1 Voltage"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"V"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1050,"y":100,"wires":[[]]},{"id":"bbfcab1d.d4b9c","type":"ha-entity","z":"e768bff5.d22008","name":"Solis_vDC2","server":"5eeae6ca.21b668","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Inverter DC2 Voltage"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"V"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1050,"y":160,"wires":[[]]},{"id":"27c6ba79.cda9d6","type":"ha-entity","z":"e768bff5.d22008","name":"Solis_iDC1","server":"5eeae6ca.21b668","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":""},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"A"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1050,"y":220,"wires":[[]]},{"id":"8f567510.99ea1","type":"ha-entity","z":"e768bff5.d22008","name":"Solis_iDC2","server":"5eeae6ca.21b668","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":""},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"A"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1050,"y":280,"wires":[[]]},{"id":"a9e07e74.76688","type":"trigger","z":"e768bff5.d22008","name":"Zero values at dusk","op1":"","op2":"0","op1type":"nul","op2type":"num","duration":"3","extend":true,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":330,"y":80,"wires":[[],["8f567510.99ea1","27c6ba79.cda9d6","bbfcab1d.d4b9c","1d60c72b.5f0dd9","6cccfd33.29133c","e9e8a866.67c818","fbbb2954.ce1eb","5ce3f42.ff19a8c","ee7bfe0d.a7dee8","3fdd5462.947934","960d90ec.e72b98"]]},{"id":"d4484a36.76cb98","type":"switch","z":"e768bff5.d22008","name":"Filter by Length","property":"payload.length","propertyType":"msg","rules":[{"t":"gte","v":"259","vt":"num"},{"t":"lte","v":"258","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":120,"y":320,"wires":[["a388b753.9e0fd","a9e07e74.76688"],["51a57782.604928"]]},{"id":"51a57782.604928","type":"trigger","z":"e768bff5.d22008","name":"","op1":"","op2":"","op1type":"date","op2type":"pay","duration":"1","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":140,"y":1080,"wires":[["c31e65b2.d27e38"],["cbc1b03e.563ec"]]},{"id":"c31e65b2.d27e38","type":"file","z":"e768bff5.d22008","name":"Timestamp Unknown Messages","filename":"/config/UnknownSolisMessages.csv","appendNewline":false,"createDir":true,"overwriteFile":"false","encoding":"none","x":370,"y":1060,"wires":[[]]},{"id":"e90ba7ca.47439","type":"delay","z":"e768bff5.d22008","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"hour","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":870,"y":880,"wires":[["74e64c0f.fa5174"]]},{"id":"153df06d.3647b","type":"delay","z":"e768bff5.d22008","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"day","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":870,"y":940,"wires":[["f75feb19.91fa7"]]},{"id":"667737ff.8e8178","type":"delay","z":"e768bff5.d22008","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"hour","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":870,"y":1000,"wires":[["c153d602.47aee8"]]},{"id":"e9e8a866.67c818","type":"ha-entity","z":"e768bff5.d22008","name":"Solis_invTemp","server":"5eeae6ca.21b668","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Inverter Temperature"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:temperature-celsius"},{"property":"unit_of_measurement","value":"ºC"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1060,"y":40,"wires":[[]]},{"id":"fbbb2954.ce1eb","type":"ha-entity","z":"e768bff5.d22008","name":"Solis_vAC","server":"5eeae6ca.21b668","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Inverter AC Voltage"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"V"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1050,"y":400,"wires":[[]]},{"id":"5ce3f42.ff19a8c","type":"ha-entity","z":"e768bff5.d22008","name":"Solis_fAC","server":"5eeae6ca.21b668","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Inverter Frequency"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:sine-wave"},{"property":"unit_of_measurement","value":"Hz"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1040,"y":460,"wires":[[]]},{"id":"ee7bfe0d.a7dee8","type":"ha-entity","z":"e768bff5.d22008","name":"Solis_iAC","server":"5eeae6ca.21b668","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Inverter AC Current"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:current-ac"},{"property":"unit_of_measurement","value":"A"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1040,"y":340,"wires":[[]]},{"id":"6cccfd33.29133c","type":"ha-entity","z":"e768bff5.d22008","name":"Solis_pDCtotal","server":"5eeae6ca.21b668","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Inverter DC Power Total"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:solar-power"},{"property":"unit_of_measurement","value":"Watts"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1060,"y":580,"wires":[[]]},{"id":"74e64c0f.fa5174","type":"ha-entity","z":"e768bff5.d22008","name":"Solis_MonUptime","server":"5eeae6ca.21b668","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Solar Monitoring Uptime"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:timeline-clock-outline"},{"property":"unit_of_measurement","value":"sec"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1070,"y":880,"wires":[[]]},{"id":"f75feb19.91fa7","type":"ha-entity","z":"e768bff5.d22008","name":"Solis_SN","server":"5eeae6ca.21b668","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Inverter SN"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:numeric"},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1040,"y":940,"wires":[[]]},{"id":"c153d602.47aee8","type":"ha-entity","z":"e768bff5.d22008","name":"Solis_TotalGeneration","server":"5eeae6ca.21b668","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Total Solar Generation"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:solar-power"},{"property":"unit_of_measurement","value":"kWh"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1080,"y":1000,"wires":[[]]},{"id":"62b3c499.996fd4","type":"delay","z":"e768bff5.d22008","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"hour","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":870,"y":1060,"wires":[["370a0708.6ccc48"]]},{"id":"370a0708.6ccc48","type":"ha-entity","z":"e768bff5.d22008","name":"Solis_MonthGeneration","server":"5eeae6ca.21b668","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Monthly Solar Generation"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:solar-power"},{"property":"unit_of_measurement","value":"kWh"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1090,"y":1060,"wires":[[]]},{"id":"c9c39dc9.dd9d5","type":"delay","z":"e768bff5.d22008","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"day","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":870,"y":820,"wires":[["c2a20344.3846b"]]},{"id":"c2a20344.3846b","type":"ha-entity","z":"e768bff5.d22008","name":"Monitor_SN","server":"5eeae6ca.21b668","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Monitor SN"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:numeric"},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1050,"y":820,"wires":[[]]},{"id":"c70a2d38.01b33","type":"ha-entity","z":"e768bff5.d22008","name":"Solis_ActiveAC","server":"5eeae6ca.21b668","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Inverter AC Active Power"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:solar-power"},{"property":"unit_of_measurement","value":"Watts"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1060,"y":520,"wires":[[]]},{"id":"63c633cd.2c3d2c","type":"ha-entity","z":"e768bff5.d22008","name":"Solis_DailyGeneration","server":"5eeae6ca.21b668","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Daily Generation"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:solar-power"},{"property":"unit_of_measurement","value":"kWh"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1080,"y":760,"wires":[[]]},{"id":"3fdd5462.947934","type":"ha-entity","z":"e768bff5.d22008","name":"Solis_vDCtotal","server":"5eeae6ca.21b668","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Inverter DC Voltage"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"V"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1060,"y":640,"wires":[[]]},{"id":"533cfa00.4edcc","type":"delay","z":"e768bff5.d22008","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"day","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":870,"y":1120,"wires":[["ce95f822.00084"]]},{"id":"ce95f822.00084","type":"ha-entity","z":"e768bff5.d22008","name":"Solis_PrevMonthGeneration","server":"5eeae6ca.21b668","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Previous Month Solar Generation"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:solar-power"},{"property":"unit_of_measurement","value":"kWh"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1100,"y":1120,"wires":[[]]},{"id":"960d90ec.e72b98","type":"ha-entity","z":"e768bff5.d22008","name":"Solis_GridApparent","server":"5eeae6ca.21b668","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Grid AC Apparent Power"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:solar-power"},{"property":"unit_of_measurement","value":"VA"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1070,"y":700,"wires":[[]]},{"id":"5eeae6ca.21b668","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]