Hosola inverter readout with Node-Red

Moderator: leecollings

Post Reply
MeAlbert
Posts: 65
Joined: Friday 06 December 2019 14:23
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Contact:

Hosola inverter readout with Node-Red

Post by MeAlbert »

I am using Domoticz on a RaspberryPi ZeroW. It can be done (works for more than one year now but it is hard working for the Pi.
I have some scripts running on Node-Red and not on DzVents. It is nice to learn programming like this but also it makes it possible for me to use Domoticz on one Pi and Node-Red, influx and Grafana on another Pi.

I have a Hosola inverter with 10 solar panels. I readout the inverter by a get statement on IP/js/status.js
I get back a string with the information I need.
The string is like this:
15-6-2021 16:10:21node: 662480c2.0d0d9
msg.payload : string[3694]
"var version="H4.01.36Y2.0.03W1.0.04";var m2mMid="613448090";var wlanMac="AC:CF:23:18:6B:68";var m2mRssi="20%";var wanIp="192.xxx.xxx.xx";var nmac="ACCF23186B6B";var fephy="off";var webData="A0415D0056,V1.10,V1.10,SolarSmart 2.5KW, 2500,928,942,107514,F1f,3,";function initPageText(){var
(the string is longer but this is the beginning where the information is stored)

I want to get the 928,942,107514 part from the string.
I try to split the string to fetch part 6 ,7 and 8 (eg the previous mentioned numbers) but do not have the knowledge to fiddle it out.
How should the function be written? Or can I do it with standard nodes? I have not figured it out yet.

A push in the right direction would be appreciated.
Albert
User avatar
FireWizard
Posts: 1905
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Hosola inverter readout with Node-Red

Post by FireWizard »

Hello @MeAlbert,

You wrote:
I want to get the 928,942,107514 part from the string.
I try to split the string to fetch part 6 ,7 and 8 (eg the previous mentioned numbers) but do not have the knowledge to fiddle it out.
How should the function be written? Or can I do it with standard nodes? I have not figured it out yet.
I do not know what the values 928, 942 and 107514 represents, but it is quite simple to parse them.
Although, I use the "Function" node quite often I have chosen this time for more or less the "Node-Red way" to solve this issue.

The complete string itself has 3694 characters and only a part is visible here. I do not hope, that the invisible part interferes with the solution.

For now I will test with the string below:

Code: Select all

"var version="H4.01.36Y2.0.03W1.0.04";var m2mMid="613448090";var wlanMac="AC:CF:23:18:6B:68";var m2mRssi="20%";var wanIp="192.xxx.xxx.xx";var nmac="ACCF23186B6B";var fephy="off";var webData="A0415D0056,V1.10,V1.10,SolarSmart 2.5KW, 2500,928,942,107514,F1f,3"
This string is injected by the "Inject" node. You should replace this "Inject" node with your node that has as output this complete string.

The flow is as follows:

Screenshot_parse string.png
Screenshot_parse string.png (33.66 KiB) Viewed 533 times
The explanation.

1. "Inject" node in order to inject the string into the flow. This node should be replaced by the output of the node that provides the complete string.

2. If we zoom closer into the received string we see multiple elements, starting with "var" and separated by a semicolon (;)
So the next node is a default "core" node of Node Red, which will split the string in multiple messages. As separator in the "Split" node, we will use the semicolon (;)

3. At the output we receive a lot of messages, but actually we are only interested in the message that starts with var webData, so we filter this one out. The next node is the "Switch" node and as selection criterion, we will use "contains" and "webData".

4. Now as we have only left the message, we are interested in, we will need to split it again. This is the same as the second node, except that as separator, we will use a comma (,) and the result will be ten messages.

5. We will put these ten messages in an array. Therefor we need a non default node, called buffer-array.
This node has to be installed using the Palette or from the command line.
See: https://flows.nodered.org/node/node-red ... ffer-array
This will give you the output, as shown in the picture above.

6. From there it is quite easy to pickup the desired values as they are available as msg.payload[5], msg.payload[6] and msg.payload[7]
To push it to Domoticz, you can use as "svalue" : msg.payload[5]

7. If the buffer of the "buffer array" node is not empty, every incoming message results in an output message. If that is not desired you can use a RBE node, that outputs only a changed value. In order to test, I wanted to be able to reset the RBE node, so an "Inject" node that resets the RBE node has been added as well, but is not necessary.

Please find the complete flow below:

Code: Select all

[{"id":"36978604.a93072","type":"tab","label":"Test","disabled":false,"info":""},{"id":"59bc29e6.8c5428","type":"inject","z":"36978604.a93072","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"var version=\"H4.01.36Y2.0.03W1.0.04\";var m2mMid=\"613448090\";var wlanMac=\"AC:CF:23:18:6B:68\";var m2mRssi=\"20%\";var wanIp=\"192.xxx.xxx.xx\";var nmac=\"ACCF23186B6B\";var fephy=\"off\";var webData=\"A0415D0056,V1.10,V1.10,SolarSmart 2.5KW, 2500,928,942,107514,F1f,3","payloadType":"str","x":250,"y":80,"wires":[["ee915aef.e4b19"]]},{"id":"ee915aef.e4b19","type":"split","z":"36978604.a93072","name":"","splt":";","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":410,"y":80,"wires":[["f43f31d9.7e8348"]]},{"id":"f43f31d9.7e8348","type":"switch","z":"36978604.a93072","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"webData","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":570,"y":80,"wires":[["2b0e3b0c.d6dc1c"]]},{"id":"2b0e3b0c.d6dc1c","type":"split","z":"36978604.a93072","name":"","splt":",","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":730,"y":80,"wires":[["6c83e2d0.80eda4"]]},{"id":"6c83e2d0.80eda4","type":"buffer-array","z":"36978604.a93072","name":"","bufferLen":"10","startWhenFilled":true,"x":910,"y":80,"wires":[["75f8a165.5d781"]]},{"id":"7200c4d1.703654","type":"debug","z":"36978604.a93072","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1270,"y":80,"wires":[]},{"id":"75f8a165.5d781","type":"rbe","z":"36978604.a93072","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":1090,"y":80,"wires":[["7200c4d1.703654"]]},{"id":"2f11dae8.bdea9e","type":"inject","z":"36978604.a93072","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"reset","payloadType":"str","x":910,"y":140,"wires":[["75f8a165.5d781"]]}]
Good luck and best regards.
Last edited by FireWizard on Friday 18 June 2021 9:17, edited 3 times in total.
MeAlbert
Posts: 65
Joined: Friday 06 December 2019 14:23
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Contact:

Re: Hosola inverter readout with Node-Red

Post by MeAlbert »

@fireWizaed
Thans for the explanation. I figured out to use the split function and the switch function but was unable te proces it further.
I will try again tomorrow as at nighttime I can't reach the inverter.
I will let you know the result.

I also try to use the function node but my knowledge of programming is to low yet. But first have it running then I will try further.

Thanks again and best regards.
MeAlbert
Posts: 65
Joined: Friday 06 December 2019 14:23
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Contact:

Re: Hosola inverter readout with Node-Red

Post by MeAlbert »

All works fine. Have now my string with envoy micro inverters and my string with a Hosola inverter in Node-Red.
My third string has a Goodwee inverter. I have to figure out how to get that data in. But other things to do right now.
Thanks for the help.

This is how it looks like now.
Schermafbeelding 2021-06-22 om 15.40.44.png
Schermafbeelding 2021-06-22 om 15.40.44.png (202.47 KiB) Viewed 518 times
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest