Join several dataloggers and calculate values in Node-Red Topic is solved

Moderator: leecollings

User avatar
FireWizard
Posts: 1771
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Join several dataloggers and calculate values in Node-Red

Post by FireWizard »

Hello @PieterS,

Yesterday you wrote:
After that part I configured two importnodes: The Growatt and the SMA.
Status is connected but each of them give and error... I don't understand why.
The Growatt should have the right valuenames pvpowerout and pvenergytoday and values in its JSON-message of the manual inject node.
But I get this error in the right pane.
Image
The error you see (3 times) is NaN. NaN stands for Not a Number. I'm not 100% sure, where the error comes from, but I think probably the "Change" node, which sets the flow.context. The reason is that it has received data of the wrong type.

To be sure and in order to solve it, can you connect a (green) Debug node to the output of the MQTT Out node, so that we can see, what has been sent to the "Change" node. Open the "tree" as much as possible by clicking all arrows.
I do not understand why there is no output. Maybe you can explain this to me?
Is it possible that you tested it after 20:36? That is the time that (in my case sunset + 30 mins) the switch goes from the upper output to the lower output.
So during the programmed time (day) the input is directed to the upper output and during the night the input goes to the lower output.
However, I noted from your flow, that you use a different date/time switch. So that might work in a different way.

This explains, why you don't get any data after 20:36 (yesterday) and receive NaN. But I would like to see the data received by MQTT during night as well.
In my opinion the data stream on daytime is Node named Growatt MQTT In 1 -> Store Data 1 -> 5 Min Tick -> Day Time switch -> Function.
My questions:
1: is this thought correct?
2: the data is temporarily stored in the memory of Node-Red?
Yes, this is correct. The function collects the stored data (flow.get)
This morning the flow is reading input from the Growatt-inverter and now I got the first results from the Function-node:
Probably, because the date/time switch has been activated.

The Omnik inverter uses a Python script and more or less every Python script, that wants the communicate with a MQTT broker, uses the Paho library.
So that means you have to install Paho.

Yes, that it looks different, does not surprise me.

To be compatible with the GroWatt and SMA (pvpowerout and pvenergytoday), I think you will need p_ac1 (or ac_power) and e_today. Your inverter is a 1 phase inverter and not a 3 phase inverter.
If you agree we can change that. It is not a problem, that it is different.

Can you send me a screenshot of the Output of the MQTT node (Omnik)? Do not hide any data. If there is sensitive data, send it in a PM.

Regards
PieterS
Posts: 197
Joined: Wednesday 31 May 2017 16:06
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: NL
Contact:

Re: Join several dataloggers and calculate values in Node-Red

Post by PieterS »

thomasbaetge wrote: Wednesday 30 March 2022 14:24 Hi,

seems that your MQTT message comes as unformatted as raw data. Actually it is key - value pairs, separated by ':'.
This also explains your NaN error from earlier (NaN = not a number. A numeric format was expected, but a string or smth else was delivered). That can be solved by a simple ParseFloat(YOURVALUE) conversion in a function node.

you may want to run your data through a JSON node (standard) and set it to 'always convert to Json Object'.
Try that and see if it gets better ;)

don't give up...we will get you there... ;)
Thanks thomasbaetge for your reply. I build in a JSON node. Hope it helps. No results up till now. Maybe because of the long the topicname? Or do I have to specify the Property?
Image
pic code
Image
I can see there are messages passing by in MQTT Explorer at this moment, but they seem not to be picked up in Node-Red any more.. I have to figure that out first.
Synology with Domoticz build (V2024.7) in Docker
PieterS
Posts: 197
Joined: Wednesday 31 May 2017 16:06
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: NL
Contact:

Re: Join several dataloggers and calculate values in Node-Red

Post by PieterS »

FireWizard wrote: Wednesday 30 March 2022 14:28
The Omnik inverter uses a Python script and more or less every Python script, that wants the communicate with a MQTT broker, uses the Paho library.
So that means you have to install Paho.

Yes, that it looks different, does not surprise me.

To be compatible with the GroWatt and SMA (pvpowerout and pvenergytoday), I think you will need p_ac1 (or ac_power) and e_today. Your inverter is a 1 phase inverter and not a 3 phase inverter.
If you agree we can change that. It is not a problem, that it is different.

Can you send me a screenshot of the Output of the MQTT node (Omnik)? Do not hide any data. If there is sensitive data, send it in a PM.

Regards
H Firewizard,
Lots to discuss about this project. I spent time to change the flow to extract data from the messages of my tree different inverters.

At the end I only recieve the result of the calculation in the Function Node and I read the pvenergytoday1 of Growatt. That number is correct. I do not read pvpowerout from any inverter...

I have my doubts about the nodes Store Data 2 (SMA) and Store Data 3 (Omnik) which should extract PAC1 from SMA and ac_power from Omnik..
I am wondering why the show no actual power.
This is my flow at this moment.

Code: Select all

[{"id":"b23a181c.6db8c8","type":"tab","label":"GroWatt Firewizard2","disabled":false,"info":""},{"id":"e16df0af.e84e4","type":"inject","z":"b23a181c.6db8c8","name":"Manual Inject Growatt","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"energy/growatt","payload":"{\"device\": \"FPH1B0001\", \"time\": \"2022-03-25T12:49:27\", \"buffered\": \"no\", \"values\": {\"datalogserial\": \"XGD2AAAAAA\", \"pvserial\": \"FPH1B0001\", \"pvstatus\": 1, \"pvpowerin\": 15401, \"pv1voltage\": 2286, \"pv1current\": 69, \"pv1watt\": 15401, \"pv2voltage\": 0, \"pv2current\": 0, \"pv2watt\": 0, \"pvpowerout\": 15093, \"pvfrequentie\": 5000, \"pvgridvoltage\": 2334, \"pvgridcurrent\": 64, \"pvgridpower\": 15120, \"pvgridvoltage2\": 0, \"pvgridcurrent2\": 0, \"pvgridpower2\": 0, \"pvgridvoltage3\": 0, \"pvgridcurrent3\": 0, \"pvgridpower3\": 0, \"totworktime\": 17713903, \"pvenergytoday\": 56, \"pvenergytotal\": 7419, \"epvtotal\": 7507, \"epv1today\": 56, \"epv1total\": 7507, \"epv2today\": 0, \"epv2total\": 0, \"pvtemperature\": 458, \"pvipmtemperature\": 479}}","payloadType":"json","x":300,"y":60,"wires":[["629bed59.838554"]]},{"id":"629bed59.838554","type":"mqtt out","z":"b23a181c.6db8c8","name":"MQTT Out Growatt","topic":"energy/growatt","qos":"0","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"7fb3e06.2d91f2","x":590,"y":60,"wires":[]},{"id":"e75b8555.13ec58","type":"inject","z":"b23a181c.6db8c8","name":"Manual Inject SMA","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"energy/sma","payload":"{\"OperTm\":49071.288,\"InvStatus\":\"Ok\",\"InvTemperature\":44.63,\"InvGridRelay\":\"Closed\",\"BTSignal\":69.02,\"GridFreq\":49.99,\"EToday\":12.262,\"ETotal\":43314.82,\"PACTot\":1152,\"PDCTot\":1174,\"FeedTm\":47424.07,\"PAC1\":1152,\"UAC1\":233.54,\"IAC1\":4.935,\"UDC1\":346.01,\"UDC2\":342.28,\"IDC1\":1.7,\"IDC2\":1.714,\"PDC1\":588,\"PDC2\":586}","payloadType":"json","x":290,"y":120,"wires":[["19a3af2a.04c389"]]},{"id":"19a3af2a.04c389","type":"mqtt out","z":"b23a181c.6db8c8","name":"MQTT Out SMA","topic":"energy/sma","qos":"0","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"7fb3e06.2d91f2","x":580,"y":120,"wires":[]},{"id":"d9a4226a.6ddf1","type":"inject","z":"b23a181c.6db8c8","name":"Manual Inject Omnik","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"energy/omnik","payload":"{\"e_today\":3.65}","payloadType":"json","x":290,"y":180,"wires":[["52e8c134.a85f1"]]},{"id":"52e8c134.a85f1","type":"mqtt out","z":"b23a181c.6db8c8","name":"MQTT Out Omnik","topic":"energy/omnik","qos":"0","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"7fb3e06.2d91f2","x":590,"y":180,"wires":[]},{"id":"ac7e1b02.f0dc6","type":"mqtt in","z":"b23a181c.6db8c8","name":"Growatt MQTT In 1","topic":"energy/growatt","qos":"0","datatype":"json","broker":"7fb3e06.2d91f2","nl":false,"rap":true,"rh":0,"x":270,"y":280,"wires":[["ded18253.8caeb"]]},{"id":"304485db.9c561a","type":"mqtt in","z":"b23a181c.6db8c8","name":"SMA MQTT In 2","topic":"energy/sma","qos":"2","datatype":"json","broker":"7fb3e06.2d91f2","nl":false,"rap":true,"rh":0,"x":260,"y":420,"wires":[["e3f550c.f4147b"]]},{"id":"51fb39a.911c7c8","type":"mqtt in","z":"b23a181c.6db8c8","name":"Omnik MQTT In 3","topic":"energy/omnik","qos":"2","datatype":"base64","broker":"7fb3e06.2d91f2","nl":false,"rap":true,"rh":0,"x":270,"y":560,"wires":[["60d61dfa.b941cc","888730ac.10a97"]]},{"id":"ded18253.8caeb","type":"change","z":"b23a181c.6db8c8","name":"Store Data 1 (Growatt)","rules":[{"t":"set","p":"pvpowerout1","pt":"flow","to":"payload.values.pvpowerout","tot":"msg"},{"t":"set","p":"pvenergytoday1","pt":"flow","to":"payload.values.pvenergytoday","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":320,"wires":[["faa20c31.1efaf"]]},{"id":"e3f550c.f4147b","type":"change","z":"b23a181c.6db8c8","name":"Store Data 2 (SMA)","rules":[{"t":"set","p":"pvpowerout2","pt":"flow","to":"payload.PAC1","tot":"msg"},{"t":"set","p":"pvenergytoday2","pt":"flow","to":"payload.values.EToday","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":460,"wires":[["af837345.043f2"]]},{"id":"6791e283.1d7fac","type":"change","z":"b23a181c.6db8c8","name":"Store Data 3 (Omnik)","rules":[{"t":"set","p":"pvpowerout3","pt":"flow","to":"payload.ac_power","tot":"msg"},{"t":"set","p":"pvenergytoday3","pt":"flow","to":"payload.e_today","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":600,"wires":[["9c232821.45937"]]},{"id":"c212a3fa.058d78","type":"inject","z":"b23a181c.6db8c8","name":"5 Min Tick","props":[{"p":"payload"}],"repeat":"300","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":250,"y":760,"wires":[["bbfbcf75.3efa08"]]},{"id":"9a094e69.733838","type":"function","z":"b23a181c.6db8c8","name":"Function","func":"msg.payload = flow.get(\"pvpowerout1\") + flow.get(\"pvpowerout2\") + flow.get(\"pvpowerout3\");\nmsg.payload = flow.get(\"pvenergytoday1\") + flow.get(\"pvenergytoday2\") + flow.get(\"pvenergytoday3\");\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":640,"y":760,"wires":[["f4d48b2e.e485e8"]]},{"id":"f4d48b2e.e485e8","type":"debug","z":"b23a181c.6db8c8","name":"Total results","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":830,"y":760,"wires":[]},{"id":"f1a542b4.138358","type":"inject","z":"b23a181c.6db8c8","name":"Set to 0","props":[{"p":"payload.values.pvpowerout","v":"0","vt":"num"},{"p":"payload.values.pvenergytoday","v":"0","vt":"num"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":240,"y":340,"wires":[["ded18253.8caeb"]]},{"id":"f05d9e3e.f2af28","type":"inject","z":"b23a181c.6db8c8","name":"Set to 0","props":[{"p":"payload.values.pvpowerout","v":"0","vt":"num"},{"p":"payload.values.pvenergytoday","v":"0","vt":"num"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":240,"y":480,"wires":[["e3f550c.f4147b"]]},{"id":"a5559973.746878","type":"inject","z":"b23a181c.6db8c8","name":"Set to 0","props":[{"p":"payload.values.pvpowerout","v":"0","vt":"num"},{"p":"payload.values.pvenergytoday","v":"0","vt":"num"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","x":240,"y":640,"wires":[["60d61dfa.b941cc"]]},{"id":"bbfbcf75.3efa08","type":"time-range-switch","z":"b23a181c.6db8c8","name":"Day Time switch","lat":"51.3202409","lon":"5.4581819","startTime":"sunrise","endTime":"sunset","startOffset":"-30","endOffset":"+30","x":440,"y":760,"wires":[["9a094e69.733838"],[]]},{"id":"faa20c31.1efaf","type":"debug","z":"b23a181c.6db8c8","name":"Result Growatt","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":770,"y":320,"wires":[]},{"id":"af837345.043f2","type":"debug","z":"b23a181c.6db8c8","name":"Result SMA","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":770,"y":460,"wires":[]},{"id":"9c232821.45937","type":"debug","z":"b23a181c.6db8c8","name":"Result Omnik","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":840,"y":600,"wires":[]},{"id":"60d61dfa.b941cc","type":"json","z":"b23a181c.6db8c8","name":"","property":"payload","action":"str","pretty":false,"x":450,"y":600,"wires":[["6791e283.1d7fac"]]},{"id":"888730ac.10a97","type":"debug","z":"b23a181c.6db8c8","name":"Check Omnik","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":480,"y":560,"wires":[]},{"id":"7fb3e06.2d91f2","type":"mqtt-broker","name":"","broker":"192.168.1.18","port":"1883","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]
And some results from the debug nodes
Image
Synology with Domoticz build (V2024.7) in Docker
User avatar
FireWizard
Posts: 1771
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Join several dataloggers and calculate values in Node-Red

Post by FireWizard »

hello PieterS,

You wrote:
At the end I only recieve the result of the calculation in the Function Node and I read the pvenergytoday1 of Growatt. That number is correct. I do not read pvpowerout from any inverter...
So can we conclude that the Growatt shows the correct data? Is the value of 81 correct?

That the SMA and the Omnik isn't showing anything is normal. It is not configured correct. My flow was an example of 3 Growatt converters and not
1 Growatt + 1 SMA + 1 Omnik

Can you connect a debug node to the output of the MQTT Input node of the SMA inverter, but open the tree (press the triangle at the beginning)
This is similar as with the Omnik inverter.

From both inverters can you send a screenshot of the right pane?

I also see that you have added a json node (recommended by Thomas). This is unnecessary as the MQTT is already configured to output a parsed JSON object. The JSON node is useless.

If I have the screenshots I'm able to make the flow for SMA and Omnik.

Regards
PieterS
Posts: 197
Joined: Wednesday 31 May 2017 16:06
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: NL
Contact:

Re: Join several dataloggers and calculate values in Node-Red

Post by PieterS »

H Firewizard,
So can we conclude that the Growatt shows the correct data? Is the value of 81 correct?
Yes. That value is "raw" data from the inverter. In reality it has to be devided by 10 to get the real number of kWh for today. But that is for later on.
Can you connect a debug node to the output of the MQTT Input node of the SMA inverter, but open the tree (press the triangle at the beginning)
This is similar as with the Omnik inverter.

From both inverters can you send a screenshot of the right pane?
I added a Debug node at the input node for the SMA (called Check input SMA) and show you the output:
Image

At this moment I do not receive data in Node-Red from the Omnik. In MQTT Explorer the topicname shows energy/omnik/NLDN1020138B1009

Image
And when I click at the triangel:
Image
I tried several settings in mqtt-in node but no results. The inverter is still up at this moment but nothing passing by in the debug pane..
Image

Hope you can help me out.

Pieter
Synology with Domoticz build (V2024.7) in Docker
User avatar
FireWizard
Posts: 1771
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Join several dataloggers and calculate values in Node-Red

Post by FireWizard »

Hello @PieterS,

Thank you very much for the various screenshots.

I have created a new flow, which adds the various values. I know it is RAW data and if this is what you think is correct we can customize this data.
Probably we have to multiply or divide some values, so that they are in the same range. So all Watt or kiloWatt and also Wh and KWh,

I suggest you play with it, and I like to hear your thoughts.

Please find the flow below:

Code: Select all

[{"id":"328f573d7ea7bb89","type":"tab","label":"GroWatt","disabled":false,"info":"","env":[]},{"id":"8f8b00a16cdd4b74","type":"inject","z":"328f573d7ea7bb89","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"energy/growatt1","payload":"{\"device\": \"FPH1B0001\", \"time\": \"2022-03-25T12:49:27\", \"buffered\": \"no\", \"values\": {\"datalogserial\": \"XGD2AAAAAA\", \"pvserial\": \"FPH1B0001\", \"pvstatus\": 1, \"pvpowerin\": 15401, \"pv1voltage\": 2286, \"pv1current\": 69, \"pv1watt\": 15401, \"pv2voltage\": 0, \"pv2current\": 0, \"pv2watt\": 0, \"pvpowerout\": 15093, \"pvfrequentie\": 5000, \"pvgridvoltage\": 2334, \"pvgridcurrent\": 64, \"pvgridpower\": 15120, \"pvgridvoltage2\": 0, \"pvgridcurrent2\": 0, \"pvgridpower2\": 0, \"pvgridvoltage3\": 0, \"pvgridcurrent3\": 0, \"pvgridpower3\": 0, \"totworktime\": 17713903, \"pvenergytoday\": 56, \"pvenergytotal\": 7419, \"epvtotal\": 7507, \"epv1today\": 56, \"epv1total\": 7507, \"epv2today\": 0, \"epv2total\": 0, \"pvtemperature\": 458, \"pvipmtemperature\": 479}}","payloadType":"json","x":250,"y":60,"wires":[["d2cbb1c1fb15c5cf"]]},{"id":"d2cbb1c1fb15c5cf","type":"mqtt out","z":"328f573d7ea7bb89","name":"MQTT Out Growatt","topic":"energy/growatt","qos":"0","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"f9f13036.e28b58","x":450,"y":60,"wires":[]},{"id":"2bceddb4bb0da304","type":"inject","z":"328f573d7ea7bb89","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"energy/sma","payload":"{\"OperTM\": 49075.622, \"InvStatus\": \"Ok\", \"EToday\": 15.823, \"PAC1\": 125}","payloadType":"json","x":250,"y":120,"wires":[["3569a94ec7a98621"]]},{"id":"3569a94ec7a98621","type":"mqtt out","z":"328f573d7ea7bb89","name":"MQTT Out  SMA","topic":"energy/sma","qos":"0","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"f9f13036.e28b58","x":440,"y":120,"wires":[]},{"id":"0a78e441cee47090","type":"inject","z":"328f573d7ea7bb89","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"energy/omnik/NLDN1020138B1009","payload":"{\"e_total\": 5245.4, \"e_today\": 4.49, \"ac_power\": 25}","payloadType":"json","x":250,"y":180,"wires":[["c738888f27ae9eb1"]]},{"id":"c738888f27ae9eb1","type":"mqtt out","z":"328f573d7ea7bb89","name":"MQTT Out Omnik","topic":"energy/omnik/NLDN1020138B1009","qos":"0","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"f9f13036.e28b58","x":450,"y":180,"wires":[]},{"id":"f459f57f0c5746e9","type":"mqtt in","z":"328f573d7ea7bb89","name":"MQTT In Growatt","topic":"energy/growatt","qos":"0","datatype":"json","broker":"f9f13036.e28b58","nl":false,"rap":true,"rh":0,"inputs":0,"x":270,"y":280,"wires":[["93a6265c9704e392"]]},{"id":"78923483c2aa04c6","type":"mqtt in","z":"328f573d7ea7bb89","name":"MQTT In SMA","topic":"energy/sma","qos":"2","datatype":"json","broker":"f9f13036.e28b58","nl":false,"rap":true,"rh":0,"inputs":0,"x":260,"y":420,"wires":[["fc15b7c977b0244f"]]},{"id":"757f32fc9dcba9fc","type":"mqtt in","z":"328f573d7ea7bb89","name":"MQTT In Omnik","topic":"energy/omnik/NLDN1020138B1009","qos":"0","datatype":"json","broker":"f9f13036.e28b58","nl":false,"rap":true,"rh":0,"inputs":0,"x":260,"y":560,"wires":[["7c2c907eac473fde"]]},{"id":"93a6265c9704e392","type":"change","z":"328f573d7ea7bb89","name":"Store Data 1","rules":[{"t":"set","p":"growatt_power","pt":"flow","to":"payload.values.pvpowerout","tot":"msg"},{"t":"set","p":"growatt_energy","pt":"flow","to":"payload.values.pvenergytoday","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":320,"wires":[["646239bb4e28e2a3"]]},{"id":"fc15b7c977b0244f","type":"change","z":"328f573d7ea7bb89","name":"Store Data 2","rules":[{"t":"set","p":"sma_power","pt":"flow","to":"payload.PAC1","tot":"msg"},{"t":"set","p":"sma_energy","pt":"flow","to":"payload.EToday","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":460,"wires":[["a14f389999ff4f13"]]},{"id":"7c2c907eac473fde","type":"change","z":"328f573d7ea7bb89","name":"Store Data 3","rules":[{"t":"set","p":"omnik_power","pt":"flow","to":"payload.ac_power","tot":"msg"},{"t":"set","p":"omnik_energy","pt":"flow","to":"payload.e_today","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":600,"wires":[["ca0f1675abc53316"]]},{"id":"85bda728286247c9","type":"inject","z":"328f573d7ea7bb89","name":"5 Min Tick","props":[{"p":"payload"}],"repeat":"300","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":250,"y":760,"wires":[["16dc6bc6e7313a27"]]},{"id":"a6399e43a4a46139","type":"function","z":"328f573d7ea7bb89","name":"Function","func":"var msg1 = {};\nvar msg2 = {};\n\nlet growatt_power = flow.get(\"growatt_power\");\nlet sma_power = flow.get(\"sma_power\");\nlet omnik_power = flow.get(\"omnik_power\");\n\nlet growatt_energy = flow.get(\"growatt_energy\");\nlet sma_energy = flow.get(\"sma_energy\");\nlet omnik_energy = flow.get(\"omnik_energy\");\n\nmsg1.payload = growatt_power + sma_power + omnik_power;\nmsg2.payload = growatt_energy + sma_energy + omnik_energy;\n\nreturn [[msg1,msg2]];","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":760,"wires":[["8d0bce4ab027b9f6"]]},{"id":"8d0bce4ab027b9f6","type":"debug","z":"328f573d7ea7bb89","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":890,"y":760,"wires":[]},{"id":"16dc6bc6e7313a27","type":"time-switch","z":"328f573d7ea7bb89","name":"Day Time switch","lat":"52.179281","lon":"5.606528","startTime":"sunrise","endTime":"sunset","startOffset":"-30","endOffset":"+30","x":500,"y":760,"wires":[["a6399e43a4a46139"],[]]},{"id":"b7a1b8f0930a8cb4","type":"inject","z":"328f573d7ea7bb89","name":"Set to 0","props":[{"p":"payload.values.pvpowerout","v":"0","vt":"num"},{"p":"payload.values.pvenergytoday","v":"0","vt":"num"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","x":240,"y":360,"wires":[["93a6265c9704e392"]]},{"id":"5aa2c2b741e69c78","type":"inject","z":"328f573d7ea7bb89","name":"Set to 0","props":[{"p":"payload.PAC1","v":"0","vt":"num"},{"p":"payload.EToday","v":"0","vt":"num"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","x":240,"y":500,"wires":[["fc15b7c977b0244f"]]},{"id":"33a0ff3c796d3e4a","type":"inject","z":"328f573d7ea7bb89","name":"Set to 0","props":[{"p":"payload.ac_power","v":"0","vt":"num"},{"p":"payload.e_today","v":"0","vt":"num"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","x":240,"y":640,"wires":[["7c2c907eac473fde"]]},{"id":"646239bb4e28e2a3","type":"debug","z":"328f573d7ea7bb89","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":320,"wires":[]},{"id":"a14f389999ff4f13","type":"debug","z":"328f573d7ea7bb89","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":460,"wires":[]},{"id":"ca0f1675abc53316","type":"debug","z":"328f573d7ea7bb89","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":600,"wires":[]},{"id":"f9f13036.e28b58","type":"mqtt-broker","name":"localhost","broker":"127.0.0.1","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]
Regards
PieterS
Posts: 197
Joined: Wednesday 31 May 2017 16:06
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: NL
Contact:

Re: Join several dataloggers and calculate values in Node-Red

Post by PieterS »

H @Firewizard,

Thanks a lot for all your efforts up till now! Very happy with it.

We are almost there. A little problem in the format of the output of the Omnik, I think. In the beginning I got a NaN-error.

Image

So I changed the function node. I added only the values of the Growatt and SMA. That helped.. :D

Image

Looking at what could be the cause: This are the settings of the input node of the Omnik:

Image

I checked all syntaxes of the change node. The are simular to the code of the Omnik in MQTT Explorer...

Image

As the format is the problem, the solution will be that I try to rewrite the Python-script which sends 20 (separate) topics at once to Mosquitto... :roll: Just the 2 values I need, in the same format as the Growatt or SMA, should be enough.

Or do you have another solution?

Pieter
Synology with Domoticz build (V2024.7) in Docker
User avatar
FireWizard
Posts: 1771
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Join several dataloggers and calculate values in Node-Red

Post by FireWizard »

hello @PieterS,

You wrote:
We are almost there. A little problem in the format of the output of the Omnik, I think. In the beginning I got a NaN-error.
Indeed the problem was the output of the Omnik. I assumed it was a JSON, but it was not. It was just a simple string.
So I changed the function node. I added only the values of the Growatt and SMA. That helped..
I understand, because these two are correct. The problem is the Omnik and if you delete that one ....
As the format is the problem, the solution will be that I try to rewrite the Python-script which sends 20 (separate) topics at once to Mosquitto...
That was the problem. We do not get a JSON object with 20 values but 20 topics, which each one value.
You should not rewrite the script (That would be a waste of time) but just capture the two topics , you need, e_today and ac_power. Agree?

In this case, I suggest to use two MQTT input nodes and not using a Wildcard in the MQTT topic, as we will receive in that case all 20 topics.
These two values we feed to the "Join" node and the result is stored in the flow.context store.

I created a new flow and I send you the modified Omnik stream and the General one.
Let me know your thoughts.

Code: Select all

[{"id":"757f32fc9dcba9fc","type":"mqtt in","z":"328f573d7ea7bb89","name":"MQTT In Omnik (Power)","topic":"energy/omnik/NLDN1020138B1009/ac_power","qos":"0","datatype":"auto","broker":"f9f13036.e28b58","nl":false,"rap":true,"rh":0,"inputs":0,"x":290,"y":660,"wires":[["233ead4f9fa70e29"]]},{"id":"7c2c907eac473fde","type":"change","z":"328f573d7ea7bb89","name":"Store Data 3","rules":[{"t":"set","p":"omnik_power","pt":"flow","to":"payload[\"energy/omnik/NLDN1020138B1009/ac_power\"]","tot":"msg"},{"t":"set","p":"omnik_energy","pt":"flow","to":"payload[\"energy/omnik/NLDN1020138B1009/e_today\"]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":700,"wires":[["ca0f1675abc53316"]]},{"id":"85bda728286247c9","type":"inject","z":"328f573d7ea7bb89","name":"5 Min Tick","props":[{"p":"payload"}],"repeat":"300","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":250,"y":840,"wires":[["16dc6bc6e7313a27"]]},{"id":"a6399e43a4a46139","type":"function","z":"328f573d7ea7bb89","name":"Function","func":"var msg1 = {};\nvar msg2 = {};\n\nlet growatt_power = flow.get(\"growatt_power\");\nlet sma_power = flow.get(\"sma_power\");\nlet omnik_power = parseFloat(flow.get(\"omnik_power\"));\n\nlet growatt_energy = flow.get(\"growatt_energy\");\nlet sma_energy = flow.get(\"sma_energy\");\nlet omnik_energy = parseFloat(flow.get(\"omnik_energy\"));\n\nmsg1.payload = growatt_power + sma_power + omnik_power;\nmsg2.payload = growatt_energy + sma_energy + omnik_energy;\n\nreturn [[msg1,msg2]];","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":840,"wires":[["8d0bce4ab027b9f6"]]},{"id":"8d0bce4ab027b9f6","type":"debug","z":"328f573d7ea7bb89","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":890,"y":840,"wires":[]},{"id":"16dc6bc6e7313a27","type":"time-switch","z":"328f573d7ea7bb89","name":"Day Time switch","lat":"52.179281","lon":"5.606528","startTime":"sunrise","endTime":"sunset","startOffset":"-30","endOffset":"+30","x":480,"y":840,"wires":[["a6399e43a4a46139"],[]]},{"id":"33a0ff3c796d3e4a","type":"inject","z":"328f573d7ea7bb89","name":"Set to 0","props":[{"p":"payload[\"energy/omnik/NLDN1020138B1009/ac_power\"]","v":"0","vt":"num"},{"p":"payload[\"energy/omnik/NLDN1020138B1009/e_today\"]","v":"0","vt":"num"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","x":540,"y":760,"wires":[["7c2c907eac473fde"]]},{"id":"ca0f1675abc53316","type":"debug","z":"328f573d7ea7bb89","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":930,"y":700,"wires":[]},{"id":"233ead4f9fa70e29","type":"join","z":"328f573d7ea7bb89","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":510,"y":700,"wires":[["7c2c907eac473fde","8056cdde9be201d2"]]},{"id":"5e509b8e055839bc","type":"mqtt in","z":"328f573d7ea7bb89","name":"MQTT In Omnik (Energy)","topic":"energy/omnik/NLDN1020138B1009/e_today","qos":"0","datatype":"auto","broker":"f9f13036.e28b58","nl":false,"rap":true,"rh":0,"inputs":0,"x":290,"y":740,"wires":[["233ead4f9fa70e29"]]},{"id":"8056cdde9be201d2","type":"debug","z":"328f573d7ea7bb89","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":660,"wires":[]},{"id":"f9f13036.e28b58","type":"mqtt-broker","name":"localhost","broker":"127.0.0.1","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]
Regards
PieterS
Posts: 197
Joined: Wednesday 31 May 2017 16:06
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: NL
Contact:

Re: Join several dataloggers and calculate values in Node-Red

Post by PieterS »

H @Firewizard,

Thanks again for all your input to get results. I made progress but did not succeed to get the correct sum of Actual Power and EnergyToday at every interval.. I expect that there has to be an error in the calculation of the function node.

Some output of the inverters has to be multiplied and one value (of the Growatt) has to be divided..

Code: Select all

              Power           Energy
Growatt        /10               * 100
SMA            *1                *1
Omnik          *100              *100
So I tried to change the syntax of the function node.
I disabled the input nodes of the inverters set values of variables to 0 and changed the values of the manual inject nodes but no luck..

Maybe you can give me a hint?

I tried to make another step to upload the sumarized values to PVoutput... And it seemed to me that the variables are not recognized in that node.. That brought me to the problem of calculations with the variables... So still lots of troubles... :?

So I played a lot with (and changed a bit to) your flow.

Code: Select all

[{"id":"256d3e3f.5e5012","type":"tab","label":"GroWatt Firewizard v3","disabled":false,"info":""},{"id":"3b9063a1.85cfbc","type":"mqtt out","z":"256d3e3f.5e5012","name":"MQTT Out Growatt","topic":"energy/growatt","qos":"0","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"7fb3e06.2d91f2","x":450,"y":60,"wires":[]},{"id":"a66b148f.8e7e88","type":"inject","z":"256d3e3f.5e5012","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"energy/sma","payload":"{\"EToday\":10,\"PAC1\":100}","payloadType":"json","x":250,"y":120,"wires":[["27593b75.4b9eb4"]]},{"id":"27593b75.4b9eb4","type":"mqtt out","z":"256d3e3f.5e5012","name":"MQTT Out  SMA","topic":"energy/sma","qos":"0","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"7fb3e06.2d91f2","x":440,"y":120,"wires":[]},{"id":"ca69e69d.798228","type":"inject","z":"256d3e3f.5e5012","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"energy/omnik/NLDN1020138B1009","payload":"{\"e_today\":10,\"ac_power\":20}","payloadType":"json","x":250,"y":180,"wires":[["7aad5ce8.5398d4","7d5a8326.75f45c"]]},{"id":"7aad5ce8.5398d4","type":"mqtt out","z":"256d3e3f.5e5012","name":"MQTT Out Omnik","topic":"energy/omnik/NLDN1020138B1009","qos":"0","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"7fb3e06.2d91f2","x":450,"y":180,"wires":[]},{"id":"507dc42.4d6a53c","type":"mqtt in","z":"256d3e3f.5e5012","name":"MQTT In Growatt","topic":"energy/growatt","qos":"0","datatype":"json","broker":"7fb3e06.2d91f2","nl":false,"rap":true,"rh":0,"x":260,"y":280,"wires":[["676bc2e7.12644c"]]},{"id":"1199e89e.d89787","type":"mqtt in","z":"256d3e3f.5e5012","name":"MQTT In SMA","topic":"energy/sma","qos":"2","datatype":"json","broker":"7fb3e06.2d91f2","nl":false,"rap":true,"rh":0,"x":250,"y":420,"wires":[["691975d2.20a76c"]]},{"id":"676bc2e7.12644c","type":"change","z":"256d3e3f.5e5012","name":"Store Data 1","rules":[{"t":"set","p":"growatt_power","pt":"flow","to":"payload.values.pvpowerout","tot":"msg"},{"t":"set","p":"growatt_energy","pt":"flow","to":"payload.values.pvenergytoday","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":320,"wires":[["51358934.ccf2f"]]},{"id":"691975d2.20a76c","type":"change","z":"256d3e3f.5e5012","name":"Store Data 2","rules":[{"t":"set","p":"sma_power","pt":"flow","to":"payload.PAC1","tot":"msg"},{"t":"set","p":"sma_energy","pt":"flow","to":"payload.EToday","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":460,"wires":[["3b3a415b.b5e9c6"]]},{"id":"d96fe62b.d22818","type":"inject","z":"256d3e3f.5e5012","name":"Set to 0","props":[{"p":"payload.values.pvpowerout","v":"0","vt":"num"},{"p":"payload.values.pvenergytoday","v":"0","vt":"num"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","x":260,"y":360,"wires":[["676bc2e7.12644c"]]},{"id":"6eac2783.835a7","type":"inject","z":"256d3e3f.5e5012","name":"Set to 0","props":[{"p":"payload.PAC1","v":"0","vt":"num"},{"p":"payload.EToday","v":"0","vt":"num"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","x":260,"y":500,"wires":[["691975d2.20a76c"]]},{"id":"51358934.ccf2f","type":"debug","z":"256d3e3f.5e5012","name":"Stored Growatt","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":700,"y":320,"wires":[]},{"id":"3b3a415b.b5e9c6","type":"debug","z":"256d3e3f.5e5012","name":"Stored SMA","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":690,"y":460,"wires":[]},{"id":"152deb3.d079295","type":"mqtt in","z":"256d3e3f.5e5012","name":"MQTT In Omnik (Power)","topic":"energy/omnik/NLDN1020138B1009/ac_power","qos":"0","datatype":"auto","broker":"7fb3e06.2d91f2","nl":false,"rap":true,"rh":0,"x":290,"y":560,"wires":[["8d04baf7.f4aaf"]]},{"id":"fc0b26a0.f5a738","type":"change","z":"256d3e3f.5e5012","name":"Store Data 3","rules":[{"t":"set","p":"omnik_power","pt":"flow","to":"payload[\"energy/omnik/NLDN1020138B1009/ac_power\"]","tot":"msg"},{"t":"set","p":"omnik_energy","pt":"flow","to":"payload[\"energy/omnik/NLDN1020138B1009/e_today\"]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":620,"wires":[["5c8292e1.110a9c"]]},{"id":"a3f73431.7a97c","type":"inject","z":"256d3e3f.5e5012","name":"5 Min Tick","props":[{"p":"payload"}],"repeat":"300","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":270,"y":820,"wires":[["d102f361.22ef2"]]},{"id":"1a57e1ba.3c9096","type":"function","z":"256d3e3f.5e5012","name":"Function","func":"var msg1 = {};\nvar msg2 = {};\n\nlet growatt_power = flow.get(\"growatt_power\");\nlet sma_power = flow.get(\"sma_power\");\nlet omnik_power = parseFloat(flow.get(\"omnik_power\"));\n\nlet growatt_energy = flow.get(\"growatt_energy\");\nlet sma_energy = flow.get(\"sma_energy\");\nlet omnik_energy = parseFloat(flow.get(\"omnik_energy\"));\n\nmsg1.payload = (growatt_power/10) + sma_power + (omnik_power*100);\nmsg2.payload = (growatt_energy*100) + sma_energy + (omnik_energy*100);\n\nreturn [[msg1,msg2]];","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":720,"y":820,"wires":[["4c670e12.5fb4c","d5011b8c.26d638"]]},{"id":"4c670e12.5fb4c","type":"debug","z":"256d3e3f.5e5012","name":"Results Function","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":930,"y":860,"wires":[]},{"id":"d102f361.22ef2","type":"time-switch","z":"256d3e3f.5e5012","name":"Day Time switch","lat":"52.179281","lon":"5.606528","startTime":"sunrise","endTime":"sunset","startOffset":"-30","endOffset":"+30","x":500,"y":820,"wires":[["1a57e1ba.3c9096"],[]]},{"id":"9cd871dd.6a3bb","type":"inject","z":"256d3e3f.5e5012","name":"Set to 0","props":[{"p":"payload[\"energy/omnik/NLDN1020138B1009/ac_power\"]","v":"0","vt":"num"},{"p":"payload[\"energy/omnik/NLDN1020138B1009/e_today\"]","v":"0","vt":"num"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","x":540,"y":660,"wires":[["fc0b26a0.f5a738"]]},{"id":"5c8292e1.110a9c","type":"debug","z":"256d3e3f.5e5012","name":"Stored Omnik","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":920,"y":620,"wires":[]},{"id":"8d04baf7.f4aaf","type":"join","z":"256d3e3f.5e5012","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":510,"y":600,"wires":[["fc0b26a0.f5a738"]]},{"id":"a12a20da.67e128","type":"mqtt in","z":"256d3e3f.5e5012","name":"MQTT In Omnik (Energy)","topic":"energy/omnik/NLDN1020138B1009/e_today","qos":"0","datatype":"auto","broker":"7fb3e06.2d91f2","nl":false,"rap":true,"rh":0,"x":290,"y":640,"wires":[["8d04baf7.f4aaf"]]},{"id":"fb78a4d5.ce393","type":"http request","z":"256d3e3f.5e5012","d":true,"name":"PVOUTPUT.ORG","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://pvoutput.org/service/r2/addstatus.jsp","tls":"","persist":false,"proxy":"","authType":"","x":1210,"y":780,"wires":[["a6a3937b.a97898"]]},{"id":"d5011b8c.26d638","type":"function","z":"256d3e3f.5e5012","name":"Create message PVOUTPUT ","func":"//Create PVOUTPUT Message ;\nmsg.headers={};\n//Create time\nvar date = new Date();\nday = date.getDate();\nif (day < 10) {day = \"0\" + day} \nmonth = date.getMonth()+1;\nif (month < 10) {month = \"0\" + month}\nyear = date.getFullYear();\n//node.warn(year);\nhour = date.getHours();\nif (hour < 10) {hour = \"0\" + hour}\nminute = date.getMinutes();\nif (minute < 10) {minute = \"0\" + minute}\n//Create Headers\nmsg.headers[\"X-Pvoutput-Apikey\"] = \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\";\nmsg.headers[\"X-Pvoutput-SystemId\"] = 00000    //\"your system id\";\nmsg.headers[\"content-type\"]=\"application/x-www-form-urlencoded\"\n//Create Payload ]\nd = \"\"+year+month+day;\nt = hour+\":\"+minute; \n//Growatt publish pvenergytoday in 0.1 KW, PVOUTPUT.ORG expect watt hours.\n//v1 = msg.payload.values.pvenergytoday*100\nv1 = msg.payload.growatt_energy + msg.payload.sma_energy + msg.payload.omnik_energy\n//v2 = msg.payload.values.pvpowerout/10\nv2 = msg.payload.growatt_power + msg.payload.sma_power + msg.payload.omnik_power\n//v5 = msg.payload.values.pvtemperature/10\n//v6 = msg.payload.values.pvgridvoltage/10\nmsg.payload = \"&d=\"+d+\"&t=\"+t+\"&v1=\"+v1+\"&v2=\"+v2;\n//msg.payload = \"&d=\"+d+\"&t=\"+t+\"&v1=\"+v1+\"&v2=\"+v2+\"&v5=\"+v5+\"&v6=\"+v6;\n//optional you can also sent other value to pvoutput.org \n//This can be done in a second flow also\n//the flows will be combined by PVOUTPUT.ORG\n//you have to retrieve value from (smart) energy  meter and outside temperature indicator\n//v3 = 12345     //energy used today (watts)\n//v4 = 1234.5    //energy used currently (watts)\n//v5 = 12.3      //temperature  \n//v6 = 123.4     //voltage\n//msg.payload = \"&d=\"+d+\"&t=\"+t+\"&v3=\"+v3+\"&v4=\"+v4+\"&v5=\"+v5+\"&v6=\"+v6;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":960,"y":780,"wires":[["fb78a4d5.ce393"]]},{"id":"7d5a8326.75f45c","type":"debug","z":"256d3e3f.5e5012","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":550,"y":220,"wires":[]},{"id":"a6a3937b.a97898","type":"debug","z":"256d3e3f.5e5012","name":"Results upload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1420,"y":780,"wires":[]},{"id":"4a332551.31328c","type":"inject","z":"256d3e3f.5e5012","name":"inject","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"energy/growatt","payload":"{\"values\":{\"pvpowerout\":1000,\"pvenergytoday\":10}}","payloadType":"json","x":250,"y":60,"wires":[["3b9063a1.85cfbc"]]},{"id":"7fb3e06.2d91f2","type":"mqtt-broker","name":"","broker":"192.168.1.18","port":"1883","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]
Synology with Domoticz build (V2024.7) in Docker
User avatar
FireWizard
Posts: 1771
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Join several dataloggers and calculate values in Node-Red

Post by FireWizard »

hello @PieterS,

You wrote:
Thanks again for all your input to get results. I made progress but did not succeed to get the correct sum of Actual Power and EnergyToday at every interval.. I expect that there has to be an error in the calculation of the function node.
There is no error in the calculation, as there has not been made any calculation so far.
It is just the RAW value and the flow is just to prove that we can combine these different type of inverters.

March 30 22:13 I wrote:
I have created a new flow, which adds the various values. I know it is RAW data and if this is what you think is correct we can customize this data.
Probably we have to multiply or divide some values, so that they are in the same range. So all Watt or kilo Watt and also Wh and KWh,
The calculations have to be made now, if the end result is positive.

Remember:
Electric

The electric sensor will show the current usage of electricity in Watt and the cumulative usage in kWh. You can add digits after the decimal if needed.

{"command":"udevice", "idx":1234, "svalue":"us;cu"}

where us is usage in Watt and cu is cumulative usage in Wh (even though it is displayed in kWh)
For Growatt:

Power has to be divided by 10. So in my example 15093 is 1509.3 W. (1.5093 kW). Can you confirm?
Energy has to be multiplied with 100. So 56 is 5600 Wh (and 5.6 kWh)? Can you confirm?

For SMA:

Power has to be multiplied by 1. So in my example 125 is 125 W. (0.125 kW). Can you confirm?
Energy has to be multiplied with 1. So 15.823 is 15.823 Wh (and 0.015823 kWh)? Can you confirm? I don't think it is correct.
I believe it should be 15823 Wh = 15.823 kWh

For Omnik:

Power has to be multiplied by 100. So in my example 48 is 48 W. (0.048 kW). Can you confirm?
Energy has to be multiplied with 100. So 0.13 is 130 Wh (and 0.130 kWh)? Can you confirm? I don't think it is correct either.

Let me know, what are the correct multipliers/dividers.
I disabled the input nodes of the inverters set values of variables to 0 and changed the values of the manual inject nodes but no luck..
No idea, what you mean or what you did. The input is fixed, as you get these from your inverters.
Therefor we should change the output, before we send it to Domoticz.
I tried to make another step to upload the summarized values to PVoutput... And it seemed to me that the variables are not recognized in that node.. That brought me to the problem of calculations with the variables... So still lots of troubles...
I have never used PVOutput but I know that Domoticz has native support for PVOutput. Why not use that?

Regards.
PieterS
Posts: 197
Joined: Wednesday 31 May 2017 16:06
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: NL
Contact:

Re: Join several dataloggers and calculate values in Node-Red

Post by PieterS »

Hello @Firewizard,
There is no error in the calculation, as there has not been made any calculation so far.
It is just the RAW value
Forgot that. This info is sometimes a bit overwhelming and there is wishfull thinking too.. The debugpane showed values so it promised to much. And I want to try to solve and learn. But too optimistic, I guess
For Growatt:

Power has to be divided by 10. So in my example 15093 is 1509.3 W. (1.5093 kW). Can you confirm?
Energy has to be multiplied with 100. So 56 is 5600 Wh (and 5.6 kWh)? Can you confirm?
Yes to both questions.
For SMA:

Power has to be multiplied by 1. So in my example 125 is 125 W. (0.125 kW). Can you confirm?
Energy has to be multiplied with 1. So 15.823 is 15.823 Wh (and 0.015823 kWh)? Can you confirm? I don't think it is correct.
I believe it should be 15823 Wh = 15.823 kWh
First question: yes.
About Energy: you stated it as Wh. I think that SMA means kWh. It are undefined numbers, no units..So I agree with your correction.
For Omnik:

Power has to be multiplied by 100. So in my example 48 is 48 W. (0.048 kW). Can you confirm?
Energy has to be multiplied with 100. So 0.13 is 130 Wh (and 0.130 kWh)? Can you confirm? I don't think it is correct either.
About Power I confirm.
About Energy. I am pretty sure that your statement is correct. I think it is correct.
I will check it later at https://pvoutput.org/intraday.jsp?id=46921&sid=42778
I disabled the input nodes of the inverters set values of variables to 0 and changed the values of the manual inject nodes but no luck..

No idea, what you mean or what you did. The input is fixed, as you get these from your inverters.
I tried and played a lot. But was not always able to understand what I did.. :oops:
I have never used PVOutput but I know that Domoticz has native support for PVOutput. Why not use that?
I know that Domoticz has an input-module to retrieve/import data from PVoutput. I have no knowledge about native support... But I will give it a try.

Looking forward to your answer, best regards,

Pieter
Synology with Domoticz build (V2024.7) in Docker
User avatar
FireWizard
Posts: 1771
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Join several dataloggers and calculate values in Node-Red

Post by FireWizard »

Hi @PieterS,

I made a mistake, when I wrote:
For Omnik:

Power has to be multiplied by 100. So in my example 48 is 48 W. (0.048 kW). Can you confirm?
I meant to say:

For Omnik:

Power has to be multiplied by 100. So in my example 48 is 4800 W. (4.8 kW). Can you confirm this correction?

Regards
PieterS
Posts: 197
Joined: Wednesday 31 May 2017 16:06
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: NL
Contact:

Re: Join several dataloggers and calculate values in Node-Red

Post by PieterS »

H @Firewizard,

This is what MQTT Explorer shows at this moment:

Image

The number in MQTT what belongs to actual power is in Watts.

and this is what PVoutput shows at this cloudy morning:

Image

Never a reason to have doubts about that.

Maybe I make the discussion more complicatated: PVoutput shows Energy in kWh and Power in Watts.. I guess I was wrong in my earlier post to use a multiplier..

Pieter
Synology with Domoticz build (V2024.7) in Docker
User avatar
FireWizard
Posts: 1771
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Join several dataloggers and calculate values in Node-Red

Post by FireWizard »

Hello @PieterS,

I have implemented the various multipliers and dividers for the MQTT inputs of the 3 inverters.

Code: Select all

[{"id":"f459f57f0c5746e9","type":"mqtt in","z":"328f573d7ea7bb89","name":"MQTT In Growatt","topic":"energy/growatt","qos":"0","datatype":"json","broker":"f9f13036.e28b58","nl":false,"rap":true,"rh":0,"inputs":0,"x":270,"y":380,"wires":[["93a6265c9704e392"]]},{"id":"78923483c2aa04c6","type":"mqtt in","z":"328f573d7ea7bb89","name":"MQTT In SMA","topic":"energy/sma","qos":"2","datatype":"json","broker":"f9f13036.e28b58","nl":false,"rap":true,"rh":0,"inputs":0,"x":260,"y":520,"wires":[["fc15b7c977b0244f"]]},{"id":"757f32fc9dcba9fc","type":"mqtt in","z":"328f573d7ea7bb89","name":"MQTT In Omnik (Power)","topic":"energy/omnik/NLDN1020138B1009/ac_power","qos":"0","datatype":"auto","broker":"f9f13036.e28b58","nl":false,"rap":true,"rh":0,"inputs":0,"x":290,"y":660,"wires":[["233ead4f9fa70e29"]]},{"id":"93a6265c9704e392","type":"change","z":"328f573d7ea7bb89","name":"Store Data 1","rules":[{"t":"set","p":"growatt_power","pt":"flow","to":"payload.values.pvpowerout","tot":"msg"},{"t":"set","p":"growatt_energy","pt":"flow","to":"payload.values.pvenergytoday","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":420,"wires":[["646239bb4e28e2a3"]]},{"id":"fc15b7c977b0244f","type":"change","z":"328f573d7ea7bb89","name":"Store Data 2","rules":[{"t":"set","p":"sma_power","pt":"flow","to":"payload.PAC1","tot":"msg"},{"t":"set","p":"sma_energy","pt":"flow","to":"payload.EToday","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":560,"wires":[["a14f389999ff4f13"]]},{"id":"7c2c907eac473fde","type":"change","z":"328f573d7ea7bb89","name":"Store Data 3","rules":[{"t":"set","p":"omnik_power","pt":"flow","to":"payload[\"energy/omnik/NLDN1020138B1009/ac_power\"]","tot":"msg"},{"t":"set","p":"omnik_energy","pt":"flow","to":"payload[\"energy/omnik/NLDN1020138B1009/e_today\"]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":700,"wires":[["ca0f1675abc53316"]]},{"id":"85bda728286247c9","type":"inject","z":"328f573d7ea7bb89","name":"5 Min Tick","props":[{"p":"payload"}],"repeat":"300","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":250,"y":840,"wires":[["16dc6bc6e7313a27"]]},{"id":"a6399e43a4a46139","type":"function","z":"328f573d7ea7bb89","name":"Function","func":"var msg1 = {};\nvar msg2 = {};\n\nlet growatt_power = flow.get(\"growatt_power\");\nlet sma_power = flow.get(\"sma_power\");\nlet omnik_power = parseFloat(flow.get(\"omnik_power\"));\n\nlet growatt_energy = flow.get(\"growatt_energy\");\nlet sma_energy = flow.get(\"sma_energy\");\nlet omnik_energy = parseFloat(flow.get(\"omnik_energy\"));\n\nmsg1.payload = growatt_power/10 + sma_power + omnik_power;\nmsg2.payload = growatt_energy*100 + sma_energy*1000 + omnik_energy*1000;\n\nreturn [[msg1,msg2]];","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":840,"wires":[["8d0bce4ab027b9f6"]]},{"id":"8d0bce4ab027b9f6","type":"debug","z":"328f573d7ea7bb89","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":890,"y":840,"wires":[]},{"id":"16dc6bc6e7313a27","type":"time-switch","z":"328f573d7ea7bb89","name":"Day Time switch","lat":"52.179281","lon":"5.606528","startTime":"sunrise","endTime":"sunset","startOffset":"-30","endOffset":"+30","x":480,"y":840,"wires":[["a6399e43a4a46139"],[]]},{"id":"b7a1b8f0930a8cb4","type":"inject","z":"328f573d7ea7bb89","name":"Set to 0","props":[{"p":"payload.values.pvpowerout","v":"0","vt":"num"},{"p":"payload.values.pvenergytoday","v":"0","vt":"num"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","x":240,"y":460,"wires":[["93a6265c9704e392"]]},{"id":"5aa2c2b741e69c78","type":"inject","z":"328f573d7ea7bb89","name":"Set to 0","props":[{"p":"payload.PAC1","v":"0","vt":"num"},{"p":"payload.EToday","v":"0","vt":"num"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","x":240,"y":600,"wires":[["fc15b7c977b0244f"]]},{"id":"33a0ff3c796d3e4a","type":"inject","z":"328f573d7ea7bb89","name":"Set to 0","props":[{"p":"payload[\"energy/omnik/NLDN1020138B1009/ac_power\"]","v":"0","vt":"num"},{"p":"payload[\"energy/omnik/NLDN1020138B1009/e_today\"]","v":"0","vt":"num"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","x":540,"y":760,"wires":[["7c2c907eac473fde"]]},{"id":"646239bb4e28e2a3","type":"debug","z":"328f573d7ea7bb89","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":420,"wires":[]},{"id":"a14f389999ff4f13","type":"debug","z":"328f573d7ea7bb89","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":560,"wires":[]},{"id":"ca0f1675abc53316","type":"debug","z":"328f573d7ea7bb89","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":930,"y":700,"wires":[]},{"id":"233ead4f9fa70e29","type":"join","z":"328f573d7ea7bb89","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":510,"y":700,"wires":[["7c2c907eac473fde"]]},{"id":"5e509b8e055839bc","type":"mqtt in","z":"328f573d7ea7bb89","name":"MQTT In Omnik (Energy)","topic":"energy/omnik/NLDN1020138B1009/e_today","qos":"0","datatype":"auto","broker":"f9f13036.e28b58","nl":false,"rap":true,"rh":0,"inputs":0,"x":290,"y":740,"wires":[["233ead4f9fa70e29"]]},{"id":"f9f13036.e28b58","type":"mqtt-broker","name":"localhost","broker":"127.0.0.1","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]
Can you check that the output is correct? Do not forhet to configure your MQTT server (currently 'localhost").

If it is correct, you can implemnt the output to PVOutput and you have also to decide , what to do with te reset. of the 3 "stores".
Do you want to do that at a fixed time (e.g. 00:00) or at sunset (so it is reset, when the output of the date/time switch changes)?

Or any other idea?

Regards
PieterS
Posts: 197
Joined: Wednesday 31 May 2017 16:06
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: NL
Contact:

Re: Join several dataloggers and calculate values in Node-Red

Post by PieterS »

H @Firewizard,

Today I did an import of your last flow and saw that the results of calculations were correct! Happy with that. We made big steps.
If it is correct, you have also to decide , what to do with te reset. of the 3 "stores".
The reset at midnight is fine.
you can implemnt the output to PVOutput
That turned out to be a big challenge for me.. I have a working sample for the Growatt. So with trial and error, reading Docs at Node-RED.org and looking at Youtube... The syntax is not that easy for me. Implementing and rebuild that flow into this/your flow gave errors which seem to be related to (unknow) values and variables.. (NaN)

And it should be nice to read the results in the dashboard of Domoticz too.. In the past you helped me to realize that for the SMA. See viewtopic.php?p=274352#p274352. Maybe that flow is a good principle?

I didn't spent time today to redirect the data to Domoticz. As you mentioned in an earlier post that Domoticz has native support for that.
To be honest: I would like to send data from the function node to PVoutput as well as another subflow to Domoticz. Reason for me is: when Domoticz is down then PVoutput.org reads the data anyway.

Maybe you will help me with rewriting the syntax in the node which prepares the message to PVoutput.org? Or is your suggestion that it is easier to arrange that in Domoticz?
This is my flow at the moment (with errors in the node to create a message to PVoutput)... :oops:

Code: Select all

[{"id":"d98b2ff3.cbe56","type":"tab","label":"3 inverters samengevoegd","disabled":false,"info":""},{"id":"2548d4af.9f27b4","type":"mqtt in","z":"d98b2ff3.cbe56","name":"MQTT In Growatt","topic":"energy/growatt","qos":"0","datatype":"json","broker":"7fb3e06.2d91f2","nl":false,"rap":true,"rh":0,"x":160,"y":100,"wires":[["6b69eed2.d65ee"]]},{"id":"b507b57d.62864","type":"mqtt in","z":"d98b2ff3.cbe56","name":"MQTT In SMA","topic":"energy/sma","qos":"2","datatype":"json","broker":"7fb3e06.2d91f2","nl":false,"rap":true,"rh":0,"x":150,"y":240,"wires":[["a64fe316.a84c7"]]},{"id":"621a10b7.790328","type":"mqtt in","z":"d98b2ff3.cbe56","name":"MQTT In Omnik (Power)","topic":"energy/omnik/NLDN1020138B1009/ac_power","qos":"0","datatype":"auto","broker":"7fb3e06.2d91f2","nl":false,"rap":true,"rh":0,"x":180,"y":380,"wires":[["994806f5.144a88"]]},{"id":"6b69eed2.d65ee","type":"change","z":"d98b2ff3.cbe56","name":"Store Data 1","rules":[{"t":"set","p":"growatt_power","pt":"flow","to":"payload.values.pvpowerout","tot":"msg"},{"t":"set","p":"growatt_energy","pt":"flow","to":"payload.values.pvenergytoday","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":140,"wires":[["983ddbc8.c038e"]]},{"id":"a64fe316.a84c7","type":"change","z":"d98b2ff3.cbe56","name":"Store Data 2","rules":[{"t":"set","p":"sma_power","pt":"flow","to":"payload.PAC1","tot":"msg"},{"t":"set","p":"sma_energy","pt":"flow","to":"payload.EToday","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":280,"wires":[["51a03403.f43224"]]},{"id":"a527a252.7e8e58","type":"change","z":"d98b2ff3.cbe56","name":"Store Data 3","rules":[{"t":"set","p":"omnik_power","pt":"flow","to":"payload[\"energy/omnik/NLDN1020138B1009/ac_power\"]","tot":"msg"},{"t":"set","p":"omnik_energy","pt":"flow","to":"payload[\"energy/omnik/NLDN1020138B1009/e_today\"]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":420,"wires":[["ed610f4d.37521"]]},{"id":"4ca2c1da.1df37","type":"inject","z":"d98b2ff3.cbe56","name":"5 Min Tick","props":[{"p":"payload"}],"repeat":"300","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":620,"wires":[["a207e710.2ed468"]]},{"id":"c267f54b.9cebd","type":"function","z":"d98b2ff3.cbe56","name":"Function","func":"var msg1 = {};\nvar msg2 = {};\n\nlet growatt_power = flow.get(\"growatt_power\");\nlet sma_power = flow.get(\"sma_power\");\nlet omnik_power = parseFloat(flow.get(\"omnik_power\"));\n\nlet growatt_energy = flow.get(\"growatt_energy\");\nlet sma_energy = flow.get(\"sma_energy\");\nlet omnik_energy = parseFloat(flow.get(\"omnik_energy\"));\n\nmsg1.payload = growatt_power/10 + sma_power + omnik_power;\nmsg2.payload = growatt_energy*100 + sma_energy*1000 + omnik_energy*1000;\n\nreturn [[msg1,msg2]];","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":580,"y":620,"wires":[["92216c2.4f2d21","807966d0.276918"]]},{"id":"92216c2.4f2d21","type":"debug","z":"d98b2ff3.cbe56","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":840,"y":600,"wires":[]},{"id":"a207e710.2ed468","type":"time-switch","z":"d98b2ff3.cbe56","name":"Day Time switch","lat":"51.36471","lon":"5.44811","startTime":"sunrise","endTime":"sunset","startOffset":"-30","endOffset":"+60","x":380,"y":620,"wires":[["c267f54b.9cebd"],[]]},{"id":"f8b1c226.00f138","type":"inject","z":"d98b2ff3.cbe56","name":"Set to 0","props":[{"p":"payload.values.pvpowerout","v":"0","vt":"num"},{"p":"payload.values.pvenergytoday","v":"0","vt":"num"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","x":130,"y":180,"wires":[["6b69eed2.d65ee"]]},{"id":"cecf40ec.c8e4f8","type":"inject","z":"d98b2ff3.cbe56","name":"Set to 0","props":[{"p":"payload.PAC1","v":"0","vt":"num"},{"p":"payload.EToday","v":"0","vt":"num"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","x":130,"y":320,"wires":[["a64fe316.a84c7"]]},{"id":"e197f2a6.fed618","type":"inject","z":"d98b2ff3.cbe56","name":"Set to 0","props":[{"p":"payload[\"energy/omnik/NLDN1020138B1009/ac_power\"]","v":"0","vt":"num"},{"p":"payload[\"energy/omnik/NLDN1020138B1009/e_today\"]","v":"0","vt":"num"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":430,"y":480,"wires":[["a527a252.7e8e58"]]},{"id":"983ddbc8.c038e","type":"debug","z":"d98b2ff3.cbe56","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":580,"y":140,"wires":[]},{"id":"51a03403.f43224","type":"debug","z":"d98b2ff3.cbe56","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":580,"y":280,"wires":[]},{"id":"ed610f4d.37521","type":"debug","z":"d98b2ff3.cbe56","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":820,"y":420,"wires":[]},{"id":"994806f5.144a88","type":"join","z":"d98b2ff3.cbe56","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":400,"y":420,"wires":[["a527a252.7e8e58"]]},{"id":"4c65564a.7d52c","type":"mqtt in","z":"d98b2ff3.cbe56","name":"MQTT In Omnik (Energy)","topic":"energy/omnik/NLDN1020138B1009/e_today","qos":"0","datatype":"auto","broker":"7fb3e06.2d91f2","nl":false,"rap":true,"rh":0,"x":180,"y":460,"wires":[["994806f5.144a88"]]},{"id":"807966d0.276918","type":"function","z":"d98b2ff3.cbe56","name":"Create Message PVOUTPUT ","func":"//Create PVOUTPUT Message ;\nmsg.headers={};\n//Create time\nvar date = new Date();\nday = date.getDate();\nif (day < 10) {day = \"0\" + day} \nmonth = date.getMonth()+1;\nif (month < 10) {month = \"0\" + month}\nyear = date.getFullYear();\n//node.warn(year);\nhour = date.getHours();\nif (hour < 10) {hour = \"0\" + hour}\nminute = date.getMinutes();\nif (minute < 10) {minute = \"0\" + minute}\n//Create Headers\nmsg.headers[\"X-Pvoutput-Apikey\"] = \"xxxxxxxxxxxxxxxxxxxxxxxxxxxx\";\nmsg.headers[\"X-Pvoutput-SystemId\"] = 12345    //\"your system id\";\nmsg.headers[\"content-type\"]=\"application/x-www-form-urlencoded\"\n//Create Payload ]\nd = \"\"+year+month+day;\nt = hour+\":\"+minute; \n//Growatt publish pvenergytoday in 0.1 KW, PVOUTPUT.ORG expext watt hours.\n//v1 = msg.payload.values.pvenergytoday*100\nv1 = msg.payload.growatt_energy*100 + msg.payload.sma_energy*1000 + msg.payload.omnik_energy*1000\n//v2 = msg.payload.values.pvpowerout/10\nv2 = msg.payload.growatt_power/10 + msg.payload.sma_power + msg.payload.omnik_power\n//v5 = msg.payload.values.pvtemperature/10\n//v6 = msg.payload.values.pvgridvoltage/10\n//msg.payload = \"&d=\"+d+\"&t=\"+t+\"&v1=\"+v1+\"&v2=\"+v2+\"&v5=\"+v5+\"&v6=\"+v6;\nmsg.payload = \"&d=\"+d+\"&t=\"+t+\"&v1=\"+v1+\"&v2=\"+v2;\n//optional you can also sent other value to pvoutput.org \n//This can be done in a second flow also\n//the flows will be combined by PVOUTPUT.ORG\n//you have to retrieve value from (smart) energy  meter and outside temperature indicator\n//v3 = 12345     //energy used today (watts)\n//v4 = 1234.5    //energy used currently (watts)\n//v5 = 12.3      //temperature  \n//v6 = 123.4     //voltage\n//msg.payload = \"&d=\"+d+\"&t=\"+t+\"&v3=\"+v3+\"&v4=\"+v4+\"&v5=\"+v5+\"&v6=\"+v6;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":660,"wires":[["5f0f27da.92678"]]},{"id":"5f0f27da.92678","type":"debug","z":"d98b2ff3.cbe56","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1100,"y":660,"wires":[]},{"id":"7fb3e06.2d91f2","type":"mqtt-broker","name":"","broker":"192.168.1.18","port":"1883","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]
Because of privacy I change the API-key and SystemID. If you need them I will send them in a PM.

Thanks a lot for all your help

Best regards,

Pieter
Synology with Domoticz build (V2024.7) in Docker
User avatar
FireWizard
Posts: 1771
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Join several dataloggers and calculate values in Node-Red

Post by FireWizard »

Hello @PieterS,

You wrote:
Today I did an import of your last flow and saw that the results of calculations were correct! Happy with that. We made big steps.
Okay, then we leave it that way.
The reset at midnight is fine.
We are not going to change that either.
And it should be nice to read the results in the dashboard of Domoticz too..
I modified the last "Function" node a little bit, so that the output of the "Function" node can be connected to a MQTT Out node.
I think you are able to configure the configuration of the MQTT yourself ( IP Address, port, username/password (if used))
Do not forget to modify the Domoticz IDX of the sensor, you configured (currently 1234) I have configured it for
Electric

The electric sensor will show the current usage of electricity in Watt and the cumulative usage in kWh. You can add digits after the decimal if needed.
{"command":"udevice", "idx":1234, "svalue":"us;cu"}
where us is usage in Watt and cu is cumulative usage in Wh (even though it is displayed in kWh)
Connect a MQTT Output node to the output of the latest "Function" node and modify it as follows:

Code: Select all

let growatt_power = flow.get("growatt_power");
let sma_power = flow.get("sma_power");
let omnik_power = parseFloat(flow.get("omnik_power"));

let growatt_energy = flow.get("growatt_energy");
let sma_energy = flow.get("sma_energy");
let omnik_energy = parseFloat(flow.get("omnik_energy"));

let total_power = growatt_power/10 + sma_power + omnik_power;
let total_energy = growatt_energy*100 + sma_energy*1000 + omnik_energy*1000;

msg.payload = { "command": "udevice", "idx": 1234, "nvalue": 0, "svalue": total_power + ";" + total_energy };

return msg;
Test this first and check that the Domopticz sensor is updated every 5 minutes with the correct values>
Maybe you will help me with rewriting the syntax in the node which prepares the message to PVoutput.org?
Later I will look to a connection to PVOutput. If I need something for testing, I will make my own account. So no need for sharing your sensitive credentials.

Regards
PieterS
Posts: 197
Joined: Wednesday 31 May 2017 16:06
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: NL
Contact:

Re: Join several dataloggers and calculate values in Node-Red

Post by PieterS »

Hello @Firewizard,

We made it! Another score on the dashboard of Domoticz. The actual power is correct in Domoticz. The total Energy is not realtime at the moment. I don't know why. But I will see tomorrow..

In MQTT Explorer I see the message which send by Node-Red as the right value.

Image

Domoticz doesn't reflect that..

Image

Thank you very much so far!

Best regards,

Pieter
Synology with Domoticz build (V2024.7) in Docker
User avatar
FireWizard
Posts: 1771
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Join several dataloggers and calculate values in Node-Red

Post by FireWizard »

hello @PieterS,

I looked to your flow to PVOutput.org. I saw several issues, but got the idea. I also tried to find a ready "out of the box" flow for Node RED.
Not that easy, but I found something from Home Assistant to Node RED.

See: https://community.home-assistant.io/t/p ... red/144633

I stripped all the HA stuff and also the things I did not need and added the connection to the existing flow.

I send you the relevant part of the complete flow.

Code: Select all

[{"id":"f459f57f0c5746e9","type":"mqtt in","z":"328f573d7ea7bb89","name":"MQTT In Growatt","topic":"energy/growatt","qos":"0","datatype":"json","broker":"f9f13036.e28b58","nl":false,"rap":true,"rh":0,"inputs":0,"x":270,"y":380,"wires":[["93a6265c9704e392"]]},{"id":"78923483c2aa04c6","type":"mqtt in","z":"328f573d7ea7bb89","name":"MQTT In SMA","topic":"energy/sma","qos":"2","datatype":"json","broker":"f9f13036.e28b58","nl":false,"rap":true,"rh":0,"inputs":0,"x":260,"y":520,"wires":[["fc15b7c977b0244f"]]},{"id":"757f32fc9dcba9fc","type":"mqtt in","z":"328f573d7ea7bb89","name":"MQTT In Omnik (Power)","topic":"energy/omnik/NLDN1020138B1009/ac_power","qos":"0","datatype":"auto","broker":"f9f13036.e28b58","nl":false,"rap":true,"rh":0,"inputs":0,"x":290,"y":660,"wires":[["233ead4f9fa70e29"]]},{"id":"93a6265c9704e392","type":"change","z":"328f573d7ea7bb89","name":"Store Data 1","rules":[{"t":"set","p":"growatt_power","pt":"flow","to":"payload.values.pvpowerout","tot":"msg"},{"t":"set","p":"growatt_energy","pt":"flow","to":"payload.values.pvenergytoday","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":420,"wires":[["646239bb4e28e2a3"]]},{"id":"fc15b7c977b0244f","type":"change","z":"328f573d7ea7bb89","name":"Store Data 2","rules":[{"t":"set","p":"sma_power","pt":"flow","to":"payload.PAC1","tot":"msg"},{"t":"set","p":"sma_energy","pt":"flow","to":"payload.EToday","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":560,"wires":[["a14f389999ff4f13"]]},{"id":"7c2c907eac473fde","type":"change","z":"328f573d7ea7bb89","name":"Store Data 3","rules":[{"t":"set","p":"omnik_power","pt":"flow","to":"payload[\"energy/omnik/NLDN1020138B1009/ac_power\"]","tot":"msg"},{"t":"set","p":"omnik_energy","pt":"flow","to":"payload[\"energy/omnik/NLDN1020138B1009/e_today\"]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":700,"wires":[["ca0f1675abc53316"]]},{"id":"85bda728286247c9","type":"inject","z":"328f573d7ea7bb89","name":"5 Min Tick","props":[{"p":"payload"}],"repeat":"300","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":270,"y":1060,"wires":[["16dc6bc6e7313a27","dfbc1db8562a1b2d","9a7747a2f6150e99"]]},{"id":"a6399e43a4a46139","type":"function","z":"328f573d7ea7bb89","name":"Function","func":"var msg1 = {};\nvar msg2 = {};\nvar msg3 = {};\n\n\nlet growatt_power = flow.get(\"growatt_power\");\nlet sma_power = flow.get(\"sma_power\");\nlet omnik_power = parseFloat(flow.get(\"omnik_power\"));\n\nlet growatt_energy = flow.get(\"growatt_energy\");\nlet sma_energy = flow.get(\"sma_energy\");\nlet omnik_energy = parseFloat(flow.get(\"omnik_energy\"));\n\nlet total_power = growatt_power/10 + sma_power + omnik_power; //v2\nlet total_energy = growatt_energy*100 + sma_energy*1000 + omnik_energy*1000; //v1\n\nmsg1.payload = { \"command\": \"udevice\", \"idx\": 16, \"nvalue\": 0, \"svalue\": total_power + \";\" + total_energy };\nmsg2.payload = total_energy;\nmsg3.payload = total_power;\n\nreturn [msg1,msg2,msg3];","outputs":3,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":820,"wires":[["8d0bce4ab027b9f6","1f19337be4e5fdb0"],["e2638ceab6273728"],["42bd2f24e28e6849"]]},{"id":"8d0bce4ab027b9f6","type":"debug","z":"328f573d7ea7bb89","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":890,"y":780,"wires":[]},{"id":"16dc6bc6e7313a27","type":"time-switch","z":"328f573d7ea7bb89","name":"Day Time switch","lat":"52.179281","lon":"5.606528","startTime":"sunrise","endTime":"sunset","startOffset":"-30","endOffset":"+30","x":480,"y":840,"wires":[["a6399e43a4a46139"],[]]},{"id":"b7a1b8f0930a8cb4","type":"inject","z":"328f573d7ea7bb89","name":"Set to 0","props":[{"p":"payload.values.pvpowerout","v":"0","vt":"num"},{"p":"payload.values.pvenergytoday","v":"0","vt":"num"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","x":240,"y":460,"wires":[["93a6265c9704e392"]]},{"id":"5aa2c2b741e69c78","type":"inject","z":"328f573d7ea7bb89","name":"Set to 0","props":[{"p":"payload.PAC1","v":"0","vt":"num"},{"p":"payload.EToday","v":"0","vt":"num"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","x":240,"y":600,"wires":[["fc15b7c977b0244f"]]},{"id":"33a0ff3c796d3e4a","type":"inject","z":"328f573d7ea7bb89","name":"Set to 0","props":[{"p":"payload[\"energy/omnik/NLDN1020138B1009/ac_power\"]","v":"0","vt":"num"},{"p":"payload[\"energy/omnik/NLDN1020138B1009/e_today\"]","v":"0","vt":"num"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","x":540,"y":760,"wires":[["7c2c907eac473fde"]]},{"id":"646239bb4e28e2a3","type":"debug","z":"328f573d7ea7bb89","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":420,"wires":[]},{"id":"a14f389999ff4f13","type":"debug","z":"328f573d7ea7bb89","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":560,"wires":[]},{"id":"ca0f1675abc53316","type":"debug","z":"328f573d7ea7bb89","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":930,"y":700,"wires":[]},{"id":"233ead4f9fa70e29","type":"join","z":"328f573d7ea7bb89","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":510,"y":700,"wires":[["7c2c907eac473fde"]]},{"id":"5e509b8e055839bc","type":"mqtt in","z":"328f573d7ea7bb89","name":"MQTT In Omnik (Energy)","topic":"energy/omnik/NLDN1020138B1009/e_today","qos":"0","datatype":"auto","broker":"f9f13036.e28b58","nl":false,"rap":true,"rh":0,"inputs":0,"x":290,"y":740,"wires":[["233ead4f9fa70e29"]]},{"id":"1f19337be4e5fdb0","type":"mqtt out","z":"328f573d7ea7bb89","name":"To Domoticz","topic":"domoticz/in","qos":"0","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"f9f13036.e28b58","x":890,"y":840,"wires":[]},{"id":"2fc002c2638d7336","type":"join","z":"328f573d7ea7bb89","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"4","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":670,"y":1060,"wires":[["56f118eea5b28066","fb4543e971312205"]]},{"id":"e2638ceab6273728","type":"change","z":"328f573d7ea7bb89","name":"V1","rules":[{"t":"set","p":"topic","pt":"msg","to":"v1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":920,"wires":[["2fc002c2638d7336","6b1e59e9c36465dd"]]},{"id":"42bd2f24e28e6849","type":"change","z":"328f573d7ea7bb89","name":"V2","rules":[{"t":"set","p":"topic","pt":"msg","to":"v2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":980,"wires":[["2fc002c2638d7336","a4d36530bf0d95b1"]]},{"id":"56f118eea5b28066","type":"function","z":"328f573d7ea7bb89","name":"Set API key here !","func":"msg.action = msg.payload;\nmsg.headers = { \n 'X-Pvoutput-Apikey': 'xxxxxxxxxxxxxxxxxxx',\n 'X-Pvoutput-SystemId': 'xxxxxx',\n 'Content-Type': 'application/x-www-form-urlencoded'\n};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":870,"y":1060,"wires":[["ed064d299a17e86a"]]},{"id":"ed064d299a17e86a","type":"function","z":"328f573d7ea7bb89","name":"Set up data","func":"msg.action = msg.payload;\n\nmsg.url = \"http://pvoutput.org/service/r2/addstatus.jsp\";\n\n\n\nreturn msg;\n\n","outputs":1,"noerr":0,"x":1090,"y":1060,"wires":[["6f68c015253b3261"]]},{"id":"6f68c015253b3261","type":"http request","z":"328f573d7ea7bb89","name":"Post","method":"POST","ret":"txt","paytoqs":false,"url":"","tls":"","persist":false,"proxy":"","authType":"","x":1270,"y":1060,"wires":[["3749eb27153bd365"]]},{"id":"3749eb27153bd365","type":"debug","z":"328f573d7ea7bb89","name":"headercheck","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1290,"y":1120,"wires":[]},{"id":"dfbc1db8562a1b2d","type":"moment","z":"328f573d7ea7bb89","name":"Date","topic":"d","input":"","inputType":"date","inTz":"Europe/Amsterdam","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYYMMDD","locale":"C","output":"payload","outputType":"msg","outTz":"Europe/Amsterdam","x":450,"y":1040,"wires":[["2fc002c2638d7336"]]},{"id":"9a7747a2f6150e99","type":"moment","z":"328f573d7ea7bb89","name":"Time","topic":"t","input":"","inputType":"date","inTz":"Europe/Amsterdam","adjAmount":0,"adjType":"days","adjDir":"add","format":"HH:mm","locale":"C","output":"payload","outputType":"msg","outTz":"Europe/Amsterdam","x":450,"y":1080,"wires":[["2fc002c2638d7336"]]},{"id":"6b1e59e9c36465dd","type":"debug","z":"328f573d7ea7bb89","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":890,"y":920,"wires":[]},{"id":"a4d36530bf0d95b1","type":"debug","z":"328f573d7ea7bb89","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":890,"y":980,"wires":[]},{"id":"fb4543e971312205","type":"debug","z":"328f573d7ea7bb89","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":850,"y":1120,"wires":[]},{"id":"f9f13036.e28b58","type":"mqtt-broker","name":"localhost","broker":"127.0.0.1","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]
Do not forget to insert your own PVOutput.org credentials.

Check it, if it works and if this is what you want?

What is the "Energy part" of your sensor showing at the moment? Is it working today?

Regards
PieterS
Posts: 197
Joined: Wednesday 31 May 2017 16:06
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: NL
Contact:

Re: Join several dataloggers and calculate values in Node-Red

Post by PieterS »

H @Firewizard,

What a impressive flow you build! Sorry for my question; I feel a bit uncomfortable with all your effort to solve my problem... I didn't search in my earlier posts what the flow was in which that node was, that created the message for uploading to PVoutput.org.

I imported your last flow but there are 2 unknow nodes.

Image

I installed the new node on top of the list:
Image

Configured the nodes and gave it some time to add the values to the flow. And there it is!!!

Image

Image

What a great feeling! Very happy with the result! No graphic so late in the evening. It is almost dark. But I let you know the results on a sunny day.

You asked:
What is the "Energy part" of your sensor showing at the moment? Is it working today?
This are the results in Domoticz today:

Image

It is running fine! And this is the graphic:

Image

There is small pile (energy generated 65 watt) in the middle of the night... It does not bother me. Related to a sunny day with generated energy of 35 kWh.

In summary: I am very grateful for all the time and effort you spent to solve my question. Thanks a lot. I keep you posted for the results.

Best regards,

Pieter
Synology with Domoticz build (V2024.7) in Docker
User avatar
FireWizard
Posts: 1771
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Join several dataloggers and calculate values in Node-Red

Post by FireWizard »

Hello Pieter (@PieterS)

You said:
What a impressive flow you build!
I said in my previous post, that I found a flow in the Home Assistant forum.
This was not suitable for what we already had, so I modified it.
He also used v3 up to v6. These values we have not available.

So at least a part of the credits should go to the HA user, called Picnic.
I had no experience with PVOutput, so I was happy to use his idea.
I imported your last flow but there are 2 unknown nodes.
Fortunately you found those nodes. The moment node is a very useful node if you want to do things with date and/or time.
Keep it in your mind.

There is one thing, you can make the flow a little bit simpler.
Combine the two "Function" nodes at the end into one.

The "Function" node, called "Set API key here!" will become:

Code: Select all

msg.url = "http://pvoutput.org/service/r2/addstatus.jsp";

msg.action = msg.payload;

msg.headers = { 
 'X-Pvoutput-Apikey': 'xxxxxxxxxxxxxxxxxxx',
 'X-Pvoutput-SystemId': 'xxxxxx',
 'Content-Type': 'application/x-www-form-urlencoded'
};

return msg;
But I let you know the results on a sunny day.
I hope to hear something soon :D

If you are satisfied and everything is working as expected, remove all the (green) debug nodes or, at least, deactivate them.

Regards
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest