Read-out of Power production of individual solar panels with Enphase microinverters

Moderator: leecollings

benedict
Posts: 16
Joined: Thursday 16 December 2021 16:05
Target OS: Linux
Domoticz version:
Contact:

Re: Read-out of Power production of individual solar panels with Enphase microinverters

Post by benedict »

FireWizard wrote: Friday 17 December 2021 16:38 No, NodeJS and Node Red are not MQTT brokers, although Node RED has a MQTT broker node, but as far as I have noticed, it is hardly used.

Node RED is a visual programming environment and I used it to convert the data from the Envoy S to the required Domoticz format.
See: https://nodered.org/ It is built on NodeJS. See: https://nodejs.org/en/

You can install Node RED and Mosquitto (MQTT Broker) on the same device under Debian 11.

For Mosquitto see: https://snapcraft.io/install/mosquitto/debian

Node RED, including NodeJS can be installed according to: https://nodered.org/docs/getting-started/raspberrypi
Although it says Raspberry PI, it is the same for any Debian release.

Install that first and then I can support you with the flow.
I've installed mosquitto using snapd now, as instructed there. Not sure if that was really necessary, but OK. I have installed Mosquitto client and broker before without it.
And

Code: Select all

This can take 20-30 minutes on the slower Pi versions - please wait.

  Stop Node-RED                       \u2714
  Remove old version of Node-RED      \u2714
  Remove old version of Node.js       \u2714
  Install Node.js 14 LTS              \u2714   v14.18.2   Npm 6.14.15
  Clean npm cache                     \u2714
  Install Node-RED core               \u2714   2.1.4
  Move global nodes to local          -
  Npm rebuild existing nodes          \u2714
  Install extra Pi nodes              -
  Add shortcut commands               \u2714
  Update systemd script               \u2714


Any errors will be logged to   /var/log/nodered-install.log
All done.
You can now start Node-RED with the command  node-red-start
  or using the icon under   Menu / Programming / Node-RED
Then point your browser to localhost:1880 or http://{your_pi_ip-address}:1880

Started :  Mon Dec 20 17:18:33 CET 2021
Finished:  Mon Dec 20 17:20:25 CET 2021

You may want to run   node-red admin init
to configure your initial options and settings.
I'm totally unfamiliar with node.js and Node Red, so what do I do now, post install?
These are the possible errors logged, I don't think they're significant here:

Code: Select all

# cat /var/log/nodered-install.log
OLD nodejs 0 :
NEW nodejs  :

***************************************

Started : Mon Dec 20 17:18:33 CET 2021
Running for user root at /root
Failed to stop nodered.service: Unit nodered.service not loaded.
Found global nodes:   :

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package nodered
Installing nodejs 14

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
Package 'nodejs-legacy' is not installed, so not removed
Package 'nodejs' is not installed, so not removed
Package 'npm' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
dpkg: warning: ignoring request to remove nodejs which isn't installed
dpkg: warning: ignoring request to remove node which isn't installed

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Grab the LTS bundle

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
curl is already the newest version (7.74.0-1.3+deb11u1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

## Installing the NodeSource Node.js 14.x repo...


## Populating apt-get cache...

+ apt-get update
Hit:1 http://debian.snt.utwente.nl/debian bullseye InRelease
Hit:2 http://debian.snt.utwente.nl/debian bullseye-updates InRelease
Hit:3 http://security.debian.org/debian-security bullseye-security InRelease
Hit:4 http://packages.azlux.fr/debian bullseye InRelease
Ign:5 http://download.webmin.com/download/repository sarge InRelease
Hit:6 http://download.webmin.com/download/repository sarge Release
Reading package lists...

## Confirming "bullseye" is supported...

+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_14.x/dists/bullseye/Release'

## Adding the NodeSource signing key to your keyring...

+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | tee /usr/share/keyrings/nodesource.gpg >/dev/null

## Creating apt sources list file for the NodeSource Node.js 14.x repo...

+ echo 'deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_14.x bullseye main' > /etc/apt/sources.list.d/nodesource.list
+ echo 'deb-src [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_14.x bullseye main' >> /etc/apt/sources.list.d/nodesource.list

## Running `apt-get update` for you...

+ apt-get update
Hit:1 http://security.debian.org/debian-security bullseye-security InRelease
Hit:2 http://debian.snt.utwente.nl/debian bullseye InRelease
Hit:3 http://packages.azlux.fr/debian bullseye InRelease
Hit:4 http://debian.snt.utwente.nl/debian bullseye-updates InRelease
Ign:5 http://download.webmin.com/download/repository sarge InRelease
Get:6 https://deb.nodesource.com/node_14.x bullseye InRelease [4586 B]
Hit:7 http://download.webmin.com/download/repository sarge Release
Get:9 https://deb.nodesource.com/node_14.x bullseye/main amd64 Packages [769 B]
Fetched 5355 B in 2s (2767 B/s)
Reading package lists...

## Run `sudo apt-get install -y nodejs` to install Node.js 14.x and npm
## You may also need development tools to build native addons:
     sudo apt-get install gcc g++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
     echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
     sudo apt-get update && sudo apt-get install yarn



WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
  nodejs
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 25.1 MB of archives.
After this operation, 122 MB of additional disk space will be used.
Get:1 https://deb.nodesource.com/node_14.x bullseye/main amd64 nodejs amd64 14.18.2-deb-1nodesource1 [25.1 MB]
Fetched 25.1 MB in 3s (7180 kB/s)
Selecting previously unselected package nodejs.
(Reading database ... 122369 files and directories currently installed.)
Preparing to unpack .../nodejs_14.18.2-deb-1nodesource1_amd64.deb ...
Unpacking nodejs (14.18.2-deb-1nodesource1) ...
Setting up nodejs (14.18.2-deb-1nodesource1) ...
Processing triggers for man-db (2.9.4-2) ...

Versions: node:v14.18.2 npm:6.14.15
npm WARN using --force I sure hope you know what you are doing.
Now install Node-RED
/usr/bin/node-red -> /usr/lib/node_modules/node-red/red.js
/usr/bin/node-red-pi -> /usr/lib/node_modules/node-red/bin/node-red-pi

> [email protected] install /usr/lib/node_modules/node-red/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build

[bcrypt] Success: "/usr/lib/node_modules/node-red/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node" is installed via remote
+ [email protected]
added 295 packages from 373 contributors in 53.744s
2.1.4
Now create basic package.json for the user and move any global nodes
Running npm rebuild
Now add the shortcut and start/stop/log scripts to the menu
Now add systemd script and configure it for root
ln: failed to create symbolic link '/usr/bin/python': File exists
Now add launcher to top bar, add cpu temp example, make sure ping works
Memory  : 4.3G
Started :  Mon Dec 20 17:18:33 CET 2021
Finished:  Mon Dec 20 17:20:25 CET 2021
User avatar
FireWizard
Posts: 1747
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Read-out of Power production of individual solar panels with Enphase microinverters

Post by FireWizard »

Hello @benedict

You wrote:
I have installed Mosquitto client and broker
Did you test Mosquitto already, as described at https://randomnerdtutorials.com/testing ... pbbery-pi/
See chapter Subscribing to testTopic Topic

Let me know the results, so that we are sure that Mosquitto is properly running.

I do not see any serious error.
Did you already try to Enter the Node RED editor?
From your preferred browser log in to http://localhost:1880
I assume that Node RED and your browser are on the same device. If not, replace localhost by the IP Address of the device, which has Node RED installed.

Let me know.

Regards
benedict
Posts: 16
Joined: Thursday 16 December 2021 16:05
Target OS: Linux
Domoticz version:
Contact:

Re: Read-out of Power production of individual solar panels with Enphase microinverters

Post by benedict »

FireWizard wrote: Monday 20 December 2021 18:44 Did you test Mosquitto already, as described at https://randomnerdtutorials.com/testing ... pbbery-pi/
Yes, and I've uninstalled snapd and reinstalled mosquitto the apt way, because I know this much better. MQTT works.
Did you already try to Enter the Node RED editor?
From your preferred browser log in to http://localhost:1880
Yes, I have it running now. Cool web-based editor, it looks like.

I have it all running on a separate server in the home. Now running pihole+unbound behind nginx TLS proxy, domoticz, mosquitto broker+client, node-red
(I will also try and run domoticz behind another nginx vhost, I don't like all those extra webservers on a server, but that's for later..)

I just created virtual sensors for all panel inverters.

I'm now in the process of switching them to [Return], but I'm a little reluctant to go through with all this. I have to do it all for the large amount of panels we have, but I just read that enphase is updating its firmware in a way that ruins local access the way it's done now. So there's a chance I'll be doing all this for nothing. I'm going to have to reconsider the idea..
User avatar
FireWizard
Posts: 1747
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Read-out of Power production of individual solar panels with Enphase microinverters

Post by FireWizard »

@benedict,
Yes, and I've uninstalled snapd and reinstalled mosquitto the apt way, because I know this much better. MQTT works.
Okay
Yes, I have it running now. Cool web-based editor, it looks like.

I have it all running on a separate server in the home. Now running pihole+unbound behind nginx TLS proxy, domoticz, mosquitto broker+client, node-red
(I will also try and run domoticz behind another nginx vhost, I don't like all those extra webservers on a server, but that's for later..)

I just created virtual sensors for all panel inverters.
Okay perfect.
I'm now in the process of switching them to [Return], but I'm a little reluctant to go through with all this. I have to do it all for the large amount of panels we have, but I just read that enphase is updating its firmware in a way that ruins local access the way it's done now. So there's a chance I'll be doing all this for nothing. I'm going to have to reconsider the idea..
I was not aware of this, but my system is still running at the moment.

Can you currently connect to your Envoy-S (http:// <IP address of Envoy>) and check what your software version is?
Mine is D5.0.34 (6e87e2), dated 26 Jun, 2019 9:36 AM.
Any idea how to prevent that Enphase updates the software, without my knowledge?

Okay,

First check in your browser http://<IP address of Envoy>/api/v1/production.
This should give the more or less the same data as you get from the Enphase hardware.

Second check is to see, if you can get the inverter data, but therefore you need a password.
You can find that as the last 6 digits of your serial number or go with your browser to http://<IP address of Envoy>/info.xml and look to envoy_info, device and then sn.
If you have that, you can try in the browser http://<IP address of Envoy>/api/v1/production/inverters.
The username is "envoy" (without "")and the password are the last 6 digits of the serial number.
If everything is correct you will see the individual inverter data.

Can you check this first, before we put any effort in the Node Red flow.

Let me know.

Regards
benedict
Posts: 16
Joined: Thursday 16 December 2021 16:05
Target OS: Linux
Domoticz version:
Contact:

Re: Read-out of Power production of individual solar panels with Enphase microinverters

Post by benedict »

FireWizard wrote: Thursday 23 December 2021 14:37 Can you currently connect to your Envoy-S (http:// <IP address of Envoy>) and check what your software version is?
Mine is D5.0.34 (6e87e2), dated 26 Jun, 2019 9:36 AM.
Any idea how to prevent that Enphase updates the software, without my knowledge?
Yes, luckily I still have access to them with the installer password. Our envoy 'Software version' is D5.0.62 (5e57a9), from June 2021.
As long as it is connected to enlighten, it seems it will upgrade firmware without even asking users/owners of the Envoy. That's a bit of a PITA, really, because we are somewhat forced to have it internet-connected because the PV installer company wants that info. If that wasn't the case, we could just as well firewall it so it could no longer ask for software updates, since it functions just fine without it..
It's a pretty bad company policy by Enphase, to suddenly upgrade fw and let the users with local API access just dwindle in a void.

Oh how I detest this world of internet connection dependencies that they're introducing into our home networks. Nothing works anymore without it, and this design is really NOT a good idea *at all*. It's asking for exploitability sooner or later.
User avatar
FireWizard
Posts: 1747
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Read-out of Power production of individual solar panels with Enphase microinverters

Post by FireWizard »

Hello @benedict,

You wrote:
Our envoy 'Software version' is D5.0.62 (5e57a9), from June 2021
Well your software is somewhat (2 years) newer than mine. So, in spite of the fact that at least one newer version has been released, my Envoy S has not been updated and probably never will. Let s wait.

As all your software, such as Mosquitto and NOde RED is running, I will publish my flow, I currently use.

It provides:

1. The total solar production. This is similar than the Enphase hardware module, except that it uses another API endpoint.
2. Data of the individual inverters. Username/Password required. Thepassword is presented in the upper stream.
3. Status information of individual inverters and Q-relay (if used).

In the function nodes, you have to replace the inverter serial numbers (these are for privacy reasons random generated and not correct)in the "case" statements. Of course you have to use your own Domoticz idx numbers.

Try it, you will find detailed description is the posts above.
And let me know the result.

Code: Select all

[{"id":"d77c71e3.00c508","type":"http request","z":"7cd95b57.aab664","name":"Envoy-S Production Request","method":"GET","ret":"obj","paytoqs":"ignore","url":"http://192.168.1.1/api/v1/production","tls":"","persist":false,"proxy":"","authType":"","x":680,"y":240,"wires":[["4475eb1a.8ba75c"]]},{"id":"32228b5e.6bbbe4","type":"inject","z":"7cd95b57.aab664","name":"Timer ( 30 seconds)","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"string"}],"repeat":"30","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":240,"wires":[["b2cc3304.b4e51","4709b3cb.376b2c"]]},{"id":"1bf22be8.529d6c","type":"http request","z":"7cd95b57.aab664","name":"Envoy-S Production/Inverter Request","method":"GET","ret":"obj","paytoqs":false,"url":"http://192.168.1.1/api/v1/production/inverters","tls":"","persist":false,"proxy":"","authType":"digest","x":710,"y":300,"wires":[["8bcd8e7e.695e68"]]},{"id":"df136f90.4190e","type":"mqtt out","z":"7cd95b57.aab664","name":"Domoticz In","topic":"domoticz/in","qos":"0","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"2d06e6e96ce54335","x":1550,"y":300,"wires":[]},{"id":"b2cc3304.b4e51","type":"http request","z":"7cd95b57.aab664","name":"Envoy-S Inventory Request","method":"GET","ret":"obj","paytoqs":false,"url":"http://192.168.1.1/inventory.json","tls":"","proxy":"","x":680,"y":440,"wires":[["82d26dc0.154b1"]]},{"id":"a28e474b.bd602","type":"switch","z":"7cd95b57.aab664","name":"PCU/NSRB","property":"payload.type","propertyType":"msg","rules":[{"t":"eq","v":"PCU","vt":"str"},{"t":"eq","v":"NSRB","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1130,"y":440,"wires":[["2781e2d4.9e00ce"],["230846f0.9cc62a"]]},{"id":"2781e2d4.9e00ce","type":"split","z":"7cd95b57.aab664","name":"PCU/Objects","splt":"\\n","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":1330,"y":400,"wires":[["ad8308fd.9f2c4"]]},{"id":"ad8308fd.9f2c4","type":"split","z":"7cd95b57.aab664","name":"Split Inverters","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":1540,"y":400,"wires":[["c68c28ef.b161d8"]]},{"id":"4475eb1a.8ba75c","type":"function","z":"7cd95b57.aab664","name":"Solar Production to Domoticz","func":"var msg1 ={};\nvar msg2 ={};\nvar msg3 ={};\nif ((msg.payload.wattsNow) < 0) (msg.payload.wattsNow) = 0;\nmsg1.payload = {\"command\":\"udevice\",\"idx\":279,\"nvalue\":0,\"svalue\":(msg.payload.wattsNow.toString()) + \";\" + (msg.payload.wattHoursLifetime.toString())};\nmsg2.payload = {\"command\":\"udevice\",\"idx\":280,\"nvalue\":0,\"svalue\":(((msg.payload.wattHoursSevenDays)/1000).toString())};\nmsg3.payload = {\"command\":\"udevice\",\"idx\":281,\"nvalue\":0,\"svalue\":(((msg.payload.wattHoursLifetime)/1000).toString())};\nreturn [[msg1,msg2,msg3]];","outputs":1,"noerr":0,"x":1050,"y":240,"wires":[["df136f90.4190e"]]},{"id":"82d26dc0.154b1","type":"splitter","z":"7cd95b57.aab664","name":"Split Objects","property":"payload","x":930,"y":440,"wires":[["a28e474b.bd602"]]},{"id":"230846f0.9cc62a","type":"split","z":"7cd95b57.aab664","name":"NSRB/Object","splt":"\\n","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":1330,"y":480,"wires":[["de90b27c.8778f8"]]},{"id":"de90b27c.8778f8","type":"split","z":"7cd95b57.aab664","name":"Split Q Relay","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":1530,"y":480,"wires":[["191a77ab.81ecd"]]},{"id":"c68c28ef.b161d8","type":"function","z":"7cd95b57.aab664","name":"Solar Inverter Status to Domoticz","func":"if (msg.payload == \"PCU\"){\n    msg.topic = \"PCU\";\n    return [null,msg]\n} else {\n\nswitch (msg.payload.serial_num) {\n    \n    case \"121123456789\": //Solar Panel 1\n        if (msg.payload.producing & msg.payload.communicating & msg.payload.provisioned & msg.payload.operating === true)\n        msg.payload = {\"command\":\"udevice\",\"idx\":288,\"nvalue\":1,\"svalue\":\"OK\"};\n        if ((msg.payload.communicating || msg.payload.provisioned || msg.payload.operating === false) && (msg.payload.producing === true))\n        msg.payload = {\"command\":\"udevice\",\"idx\":288,\"nvalue\":2,\"svalue\":\"Fault\"};\n        if (msg.payload.producing === false)\n        msg.payload = {\"command\":\"udevice\",\"idx\":288,\"nvalue\":4,\"svalue\":\"No Production\"};\n        msg.topic = \"Zonnepaneel 1\";\n    break;\n\n    case \"121234567891\": //Solar Panel 2\n        if (msg.payload.producing & msg.payload.communicating & msg.payload.provisioned & msg.payload.operating === true)\n        msg.payload = {\"command\":\"udevice\",\"idx\":289,\"nvalue\":1,\"svalue\":\"OK\"};\n        if ((msg.payload.communicating || msg.payload.provisioned || msg.payload.operating === false) && (msg.payload.producing === true))\n        msg.payload = {\"command\":\"udevice\",\"idx\":289,\"nvalue\":2,\"svalue\":\"Fault\"};\n        if (msg.payload.producing === false)\n        msg.payload = {\"command\":\"udevice\",\"idx\":289,\"nvalue\":4,\"svalue\":\"No Production\"};\n        msg.topic = \"Zonnepaneel 2\";\n    break;\n\n    case \"1213456789012\": //Solar Panel 3\n        if (msg.payload.producing & msg.payload.communicating & msg.payload.provisioned & msg.payload.operating === true)\n        msg.payload = {\"command\":\"udevice\",\"idx\":290,\"nvalue\":1,\"svalue\":\"OK\"};\n        if ((msg.payload.communicating || msg.payload.provisioned || msg.payload.operating === false) && (msg.payload.producing === true))\n        msg.payload = {\"command\":\"udevice\",\"idx\":290,\"nvalue\":2,\"svalue\":\"Fault\"};\n        if (msg.payload.producing === false)\n        msg.payload = {\"command\":\"udevice\",\"idx\":290,\"nvalue\":4,\"svalue\":\"No Production\"};\n        msg.topic = \"Zonnepaneel 3\";\n    break;\n\n    case \"1215678901234\": //Solar Panel 4\n        if (msg.payload.producing & msg.payload.communicating & msg.payload.provisioned & msg.payload.operating === true)\n        msg.payload = {\"command\":\"udevice\",\"idx\":291,\"nvalue\":1,\"svalue\":\"OK\"};\n        if ((msg.payload.communicating || msg.payload.provisioned || msg.payload.operating === false) && (msg.payload.producing === true))\n        msg.payload = {\"command\":\"udevice\",\"idx\":291,\"nvalue\":2,\"svalue\":\"Fault\"};\n        if (msg.payload.producing === false)\n        msg.payload = {\"command\":\"udevice\",\"idx\":291,\"nvalue\":4,\"svalue\":\"No Production\"};\n        msg.topic = \"Zonnepaneel 4\";\n    break;\n\n    case \"1216789012345\": //Solar Panel 5\n        if (msg.payload.producing & msg.payload.communicating & msg.payload.provisioned & msg.payload.operating === true)\n        msg.payload = {\"command\":\"udevice\",\"idx\":292,\"nvalue\":1,\"svalue\":\"OK\"};\n        if ((msg.payload.communicating || msg.payload.provisioned || msg.payload.operating === false) && (msg.payload.producing === true))\n        msg.payload = {\"command\":\"udevice\",\"idx\":292,\"nvalue\":2,\"svalue\":\"Fault\"};\n        if (msg.payload.producing === false)\n        msg.payload = {\"command\":\"udevice\",\"idx\":292,\"nvalue\":4,\"svalue\":\"No Production\"};\n        msg.topic = \"Zonnepaneel 5\";\n    break;\n\n    case \"121890123456\": //Solar Panel 6\n        if (msg.payload.producing & msg.payload.communicating & msg.payload.provisioned & msg.payload.operating === true)\n        msg.payload = {\"command\":\"udevice\",\"idx\":293,\"nvalue\":1,\"svalue\":\"OK\"};\n        if ((msg.payload.communicating || msg.payload.provisioned || msg.payload.operating === false) && (msg.payload.producing === true))\n        msg.payload = {\"command\":\"udevice\",\"idx\":293,\"nvalue\":2,\"svalue\":\"Fault\"};\n        if (msg.payload.producing === false)\n        msg.payload = {\"command\":\"udevice\",\"idx\":293,\"nvalue\":4,\"svalue\":\"No Production\"};\n        msg.topic = \"Zonnepaneel 6\";\n    break;\n\n    case \"121098765432\": //Solar Panel 7\n        if (msg.payload.producing & msg.payload.communicating & msg.payload.provisioned & msg.payload.operating === true)\n        msg.payload = {\"command\":\"udevice\",\"idx\":294,\"nvalue\":1,\"svalue\":\"OK\"};\n        if ((msg.payload.communicating || msg.payload.provisioned || msg.payload.operating === false) && (msg.payload.producing === true))\n        msg.payload = {\"command\":\"udevice\",\"idx\":294,\"nvalue\":2,\"svalue\":\"Fault\"};\n        if (msg.payload.producing === false)\n        msg.payload = {\"command\":\"udevice\",\"idx\":294,\"nvalue\":4,\"svalue\":\"No Production\"};\n        msg.topic = \"Zonnepaneel 7\";\n    break;\n\n    case \"121098765431\": //Solar Panel 8\n        if (msg.payload.producing & msg.payload.communicating & msg.payload.provisioned & msg.payload.operating === true)\n        msg.payload = {\"command\":\"udevice\",\"idx\":295,\"nvalue\":1,\"svalue\":\"OK\"};\n        if ((msg.payload.communicating || msg.payload.provisioned || msg.payload.operating === false) && (msg.payload.producing === true))\n        msg.payload = {\"command\":\"udevice\",\"idx\":295,\"nvalue\":2,\"svalue\":\"Fault\"};\n        if (msg.payload.producing === false)\n        msg.payload = {\"command\":\"udevice\",\"idx\":295,\"nvalue\":4,\"svalue\":\"No Production\"};\n        msg.topic = \"Zonnepaneel 8\";\n    break;\n}\n}\nreturn [msg,null];","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1060,"y":360,"wires":[["df136f90.4190e"]]},{"id":"191a77ab.81ecd","type":"function","z":"7cd95b57.aab664","name":"Q Relay Status to Domoticz","func":"var msg1 = {};\nvar msg2 = {};\nvar msg3 = {};\nvar msg4 = {};\nvar msg5 = {};\n\nif (msg.payload == \"NSRB\"){\nreturn [null,msg]\n} else {\n\nswitch (msg.payload.serial_num) {\n    \n    case \"12112345698\": //Q Relay\n        if (msg.payload.communicating & msg.payload.provisioned & msg.payload.operating === true){\n        msg1.payload = {\"command\":\"udevice\",\"idx\":296,\"nvalue\":1,\"svalue\":\"OK\"};\n        msg1.topic = \"Q Relay Status\";\n        } else {\n        msg1.payload = {\"command\":\"udevice\",\"idx\":296,\"nvalue\":2,\"svalue\":\"Fault\"};\n        msg1.topic = \"Q Relay Status\";\n        }\n        if (msg.payload.relay == \"closed\"){\n        msg2.payload = {\"command\":\"udevice\",\"idx\":297,\"nvalue\":1,\"svalue\":\"Closed\"};\n        msg2.topic = \"Q Relay Contact Status\";\n        } else {\n        msg2.payload = {\"command\":\"udevice\",\"idx\":297,\"nvalue\":2,\"svalue\":\"Open\"};\n        msg2.topic = \"Q Relay Contact Status\";\n        }\n        if (msg.payload[\"line1-connected\"] === true){\n        msg3.payload = {\"command\":\"udevice\",\"idx\":298,\"nvalue\":1,\"svalue\":\"Connected\"};\n        msg3.topic = \"Line 1\";\n        } else {\n        msg3.payload = {\"command\":\"udevice\",\"idx\":298,\"nvalue\":2,\"svalue\":\"Disconnected\"};\n        msg3.topic = \"Line 1\";\n        }\n        if (msg.payload[\"line2-connected\"] === true){\n        msg4.payload = {\"command\":\"udevice\",\"idx\":299,\"nvalue\":1,\"svalue\":\"Connected\"};\n        msg4.topic = \"Line 2\";\n        } else {\n        msg4.payload = {\"command\":\"udevice\",\"idx\":299,\"nvalue\":2,\"svalue\":\"Disconnected\"};\n        msg4.topic = \"Line 2\";\n        }\n        if (msg.payload[\"line3-connected\"] === true){\n        msg5.payload = {\"command\":\"udevice\",\"idx\":300,\"nvalue\":1,\"svalue\":\"Connected\"};\n        msg5.topic = \"Line 3\";\n        } else {\n        msg5.payload = {\"command\":\"udevice\",\"idx\":300,\"nvalue\":2,\"svalue\":\"Disconnected\"};\n        msg5.topic = \"Line 3\";\n        }\n    break;\n}\n}\nreturn [[msg1,msg2,msg3,msg4,msg5],null];","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1040,"y":520,"wires":[["df136f90.4190e"]]},{"id":"c459ed4.7a2849","type":"inject","z":"7cd95b57.aab664","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":140,"wires":[["62206049.3d5c58"]]},{"id":"62206049.3d5c58","type":"http request","z":"7cd95b57.aab664","name":"Envoy-S Info Request","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.1/info.xml","tls":"","persist":false,"proxy":"","authType":"","x":380,"y":140,"wires":[["631034ee.648594"]]},{"id":"631034ee.648594","type":"xml","z":"7cd95b57.aab664","name":"","property":"payload","attr":"","chr":"","x":590,"y":140,"wires":[["d8a4ee6.0a3a09"]]},{"id":"d8a4ee6.0a3a09","type":"function","z":"7cd95b57.aab664","name":"Envoy-S Password","func":"var sn = msg.payload.envoy_info.device[0].sn[0];\nvar pw = sn.substr(6, 6);\nmsg.payload = pw;\nreturn msg;","outputs":1,"noerr":0,"x":790,"y":140,"wires":[["20dd15ef.367a4a"]]},{"id":"20dd15ef.367a4a","type":"debug","z":"7cd95b57.aab664","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1010,"y":140,"wires":[]},{"id":"4709b3cb.376b2c","type":"time-switch","z":"7cd95b57.aab664","name":"Day Time switch","lat":"52.179281","lon":"5.606528","startTime":"sunrise","endTime":"sunset","startOffset":"-30","endOffset":"+30","x":400,"y":240,"wires":[["d77c71e3.00c508","1bf22be8.529d6c"],[]]},{"id":"86287b9b.69f7b8","type":"function","z":"7cd95b57.aab664","name":"Solar Production Inverters to Domoticz","func":"var msg1 = {};\nvar msg2 = {};\n\nswitch (msg.payload.serialNumber) {\n\n    case \"121234567890\": //Solar Panel 1\n    if ((msg.payload.lastReportWatts) < 0) (msg.payload.lastReportWatts) = 0;\n    msg1.payload = {\"command\":\"udevice\",\"idx\":263,\"nvalue\":0,\"svalue\":((msg.payload.lastReportWatts).toString() + \";0\")};\n    msg2.payload = {\"command\":\"udevice\",\"idx\":271,\"nvalue\":0,\"svalue\":(msg.payload.maxReportWatts).toString()};\n    break;\n\n    case \"1216784321\": //Solar Panel 2\n    if ((msg.payload.lastReportWatts) < 0) (msg.payload.lastReportWatts) = 0;\n    msg1.payload = {\"command\":\"udevice\",\"idx\":264,\"nvalue\":0,\"svalue\":((msg.payload.lastReportWatts).toString() + \";0\")};\n    msg2.payload = {\"command\":\"udevice\",\"idx\":272,\"nvalue\":0,\"svalue\":(msg.payload.maxReportWatts).toString()};\n    break;\n\n    case \"12187654321\": //Solar Panel 3\n    if ((msg.payload.lastReportWatts) < 0) (msg.payload.lastReportWatts) = 0;\n    msg1.payload = {\"command\":\"udevice\",\"idx\":265,\"nvalue\":0,\"svalue\":((msg.payload.lastReportWatts).toString() + \";0\")};\n    msg2.payload = {\"command\":\"udevice\",\"idx\":273,\"nvalue\":0,\"svalue\":(msg.payload.maxReportWatts).toString()};\n    break;\n\n    case \"12134562189\": //Solar Panel 4\n    if ((msg.payload.lastReportWatts) < 0) (msg.payload.lastReportWatts) = 0;\n    msg1.payload = {\"command\":\"udevice\",\"idx\":266,\"nvalue\":0,\"svalue\":((msg.payload.lastReportWatts).toString() + \";0\")};\n    msg2.payload = {\"command\":\"udevice\",\"idx\":274,\"nvalue\":0,\"svalue\":(msg.payload.maxReportWatts).toString()};\n    break;\n\n    case \"1215687219\": //Solar Panel 5\n    if ((msg.payload.lastReportWatts) < 0) (msg.payload.lastReportWatts) = 0;\n    msg1.payload = {\"command\":\"udevice\",\"idx\":267,\"nvalue\":0,\"svalue\":((msg.payload.lastReportWatts).toString() + \";0\")};\n    msg2.payload = {\"command\":\"udevice\",\"idx\":275,\"nvalue\":0,\"svalue\":(msg.payload.maxReportWatts).toString()};\n    break;\n\n    case \"12187654321\": //Solar Panel 6\n    if ((msg.payload.lastReportWatts) < 0) (msg.payload.lastReportWatts) = 0;\n    msg1.payload = {\"command\":\"udevice\",\"idx\":268,\"nvalue\":0,\"svalue\":((msg.payload.lastReportWatts).toString() + \";0\")};\n    msg2.payload = {\"command\":\"udevice\",\"idx\":276,\"nvalue\":0,\"svalue\":(msg.payload.maxReportWatts).toString()};\n    break;\n\n    case \"12198745623\": //Solar Panel 7\n    if ((msg.payload.lastReportWatts) < 0) (msg.payload.lastReportWatts) = 0;\n    msg1.payload = {\"command\":\"udevice\",\"idx\":269,\"nvalue\":0,\"svalue\":((msg.payload.lastReportWatts).toString() + \";0\")};\n    msg2.payload = {\"command\":\"udevice\",\"idx\":277,\"nvalue\":0,\"svalue\":(msg.payload.maxReportWatts).toString()};\n    break;\n\n    case \"12198765432\": //Solar Panel 8\n    if ((msg.payload.lastReportWatts) < 0) (msg.payload.lastReportWatts) = 0;\n    msg1.payload = {\"command\":\"udevice\",\"idx\":270,\"nvalue\":0,\"svalue\":((msg.payload.lastReportWatts).toString() + \";0\")};\n    msg2.payload = {\"command\":\"udevice\",\"idx\":278,\"nvalue\":0,\"svalue\":(msg.payload.maxReportWatts).toString()};\n    break;\n}\nreturn [[msg1,msg2]];\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1240,"y":300,"wires":[["df136f90.4190e"]]},{"id":"8bcd8e7e.695e68","type":"split","z":"7cd95b57.aab664","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":970,"y":300,"wires":[["86287b9b.69f7b8"]]},{"id":"99bde26.878c82","type":"inject","z":"7cd95b57.aab664","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":460,"y":320,"wires":[["1bf22be8.529d6c"]]},{"id":"2d06e6e96ce54335","type":"mqtt-broker","name":"Jonas_MQTT_Server","broker":"192.168.10.24","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]
Regards
benedict
Posts: 16
Joined: Thursday 16 December 2021 16:05
Target OS: Linux
Domoticz version:
Contact:

Re: Read-out of Power production of individual solar panels with Enphase microinverters

Post by benedict »

FireWizard wrote: Thursday 23 December 2021 21:43 In the function nodes, you have to replace the inverter serial numbers (these are for privacy reasons random generated and not correct)in the "case" statements. Of course you have to use your own Domoticz idx numbers.
Another question about this I've been meaning to ask; Is there an easy way in domoticz to display the inverter info on some sort of roof-picture layout, similar to how enphase enlighten offers, only larger (and with the extra data we're getting here..) ?
User avatar
FireWizard
Posts: 1747
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Read-out of Power production of individual solar panels with Enphase microinverters

Post by FireWizard »

Hello @benedict,

You asked:
Is there an easy way in domoticz to display the inverter info on some sort of roof-picture layout, similar to how enphase enlighten offers, only larger (and with the extra data we're getting here..) ?
Yes that is possible.
Domoticz has the option to create Floor plans. See: https://www.domoticz.com/wiki/Floorplans

We will call it now a "Roof plan" :D

To create it, you need to create a drawing of your roof with the solar panels in it.
It is in fact the shape of your roof, probably a rectangular figure. Picture of solar panels are available all over the internet and copy and paste a panel of your choice into the shape. I decided to number the panels from, in my case, 1-8 and I also included the panel serial-number on it, as Enphase uses that for all information.

A clean picture will look like this (I have the serial number of the panel at the bottom of each panel):

Zonnepanelen_dak_without serial_number.png
Zonnepanelen_dak_without serial_number.png (143.69 KiB) Viewed 2342 times
If you want to do it in a very luxury way, you can use a drone and take some photographs :D

Next you can follow the wiki and place the sensors, you want to have on the roof plan.

In the following thread viewtopic.php?f=28&t=22368&hilit=APSystems, you will find some examples (including mine) of created "Roof plans".

If you need more info on how to do it, just ask.

Merry Christmas and happy holidays

Regards
Last edited by FireWizard on Friday 08 April 2022 21:51, edited 1 time in total.
benedict
Posts: 16
Joined: Thursday 16 December 2021 16:05
Target OS: Linux
Domoticz version:
Contact:

Re: Read-out of Power production of individual solar panels with Enphase microinverters

Post by benedict »

FireWizard wrote: Friday 20 September 2019 17:37 In this post you will find the results of the http request.
In order to see the results, you have to connect a "debug" node to the output of the "http request" node.
Press the left square of the inject node. It will present you the following in the "debug" node:
What inject node? Unclear to me is what you mean with "connect a node", and "the left square".
I only have a [Timer node and [Within time node, a [http request node and a [debug node. The http request node was not under the function nodes, but under the network nodes. New version of node-red, I guess? While setting up the nodes I noticed they are quite different from your screenshots.

Tip: the Within time node can also be set to "astronomical dawn" and "astronomical dusk", that way you don't need the -30 min offsets. Astronomical dawn/dusk is when the Sun is 18 degrees under the horizon, so that's enough time before sunrise and after sunset.

I must say I don't like graphical code interpreters like node-red, they are way too confusing. I have no idea where to put which block, if they even run or need to be deployed etc. I'd much rather have it in text-files only. Less prone to mistakes.
Can you provide me your entire config/flow in text-format, as an example, so I can import it after I changed the logins, inverter serial nrs and IDX values in a text-editor? This is also way faster to work with, because that way I can insert all 50 panels we have a little easier ;-)
If so, send it in a Private message. That way you don't have to edit out the serials etc.
User avatar
FireWizard
Posts: 1747
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Read-out of Power production of individual solar panels with Enphase microinverters

Post by FireWizard »

Hello @benedict.

You wrote:
What inject node? Unclear to me is what you mean with "connect a node", and "the left square".
This has probably to do, that you are quite new to Node RED.

I suggest thatyou watch some introduction movies, created by the developers of Node RED. It is a small investment but you will learn a lot.
See as a starter: https://www.youtube.com/watch?v=ksGeUD26Mw0
I only have a [Timer node and [Within time node, a [http request node and a [debug node. The http request node was not under the function nodes, but under the network nodes. New version of node-red, I guess? While setting up the nodes I noticed they are quite different from your screenshots.
If you click on the i (information) button and then on the various nodes you will see on the right after the "type" the type of the node.
What you call "Timer Node" is the "Inject" node, the "Within time" node is actually a "time-switch" node. etc.
At the time the flow has been created, it was, but it was moved to the Network section.

That the screenshots differ from my current flow will be caused by the fact that the "within time" node has been replaced by the 'time switch' node.
This is an optional node, just to prevent polling of the Communication unit during the night, as that is useless.
You can leave this out. As it is local communication it does no harm.
Tip: the Within time node can also be set to "astronomical dawn" and "astronomical dusk", that way you don't need the -30 min offsets. Astronomical dawn/dusk is when the Sun is 18 degrees under the horizon, so that's enough time before sunrise and after sunset.
That's fine, it is up to the user to define his own window, that the inverters or unit is polled.
But you are right it is enough time.
I must say I don't like graphical code interpreters like node-red, they are way too confusing. I have no idea where to put which block, if they even run or need to be deployed etc. I'd much rather have it in text-files only. Less prone to mistakes.
I think it is an fantastic open source tool, but you have to learn it. Watch the videos.
But, as said it is a matter of taste and fortunately other options exist.
if you prefer a script, like dzVents, you may want to look to: viewtopic.php?f=59&t=29516&p=224764&hil ... se#p224764.
This script is made at about the same time as I made mine with Node RED by the regretted Rens Waardenburg (waaren).
Can you provide me your entire config/flow in text-format
This is included in my post to you on December 23, 2021.
I can send you the same flow with my own serials in PM, but that will not add much, but let me know.

If you have further questions, just ask.

Regards
benedict
Posts: 16
Joined: Thursday 16 December 2021 16:05
Target OS: Linux
Domoticz version:
Contact:

Re: Read-out of Power production of individual solar panels with Enphase microinverters

Post by benedict »

FireWizard wrote: Monday 09 September 2019 18:44 In Domoticz hardware, add MQTT over LAN.
Do you have a screenshot of how this should look in your setup?
9b204744-9d7d-4abd-8e9f-c5799eeac4da.tmp.png
9b204744-9d7d-4abd-8e9f-c5799eeac4da.tmp.png (20.15 KiB) Viewed 2189 times
Also, why do I really need MQTT, as it seems both server and client will reside on one and the same server here.
I think I'll have a look at that dzVents script too, it looks easier, in a way..
User avatar
FireWizard
Posts: 1747
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Read-out of Power production of individual solar panels with Enphase microinverters

Post by FireWizard »

Hello @benedict,

You asked:
Do you have a screenshot of how this should look in your setup?
Yes I have,

Screenshot_MQTT_ Domoticz_Config.png
Screenshot_MQTT_ Domoticz_Config.png (188.53 KiB) Viewed 2185 times

You have to set the following properties:
1. Name ==> Whatever you like
2. IP Address ==> The IP address of the device on which your MQTT broker (Mosquitto) runs on
If it is the same hardware device as Domoticz "localhost" will be fine.
3. If you changed the default port of the MQTT broker, you have to set it, otherwise leave the default, 1883
3. All other things are default You can omit the domoticz/in and domotica/out topics
Also, why do I really need MQTT, as it seems both server and client will reside on one and the same server here.
You may have installed different programs/application on the same hardware device, but that doesn't mean that all those application can interchande data. In this case the data is collected from the Enphase Envoy by Node Red and its HTTP Request node. The essential data is handled by Node Red and prepared for Domoticz (in the format that Domoticz expects.

How to get it in the Domoticz database?
You have two options:
1. By sending a HTTP command with data in the correct format.
2. By sending a MQTT command with data in another correct format.

It is up to you which one you select.

If you go for HTTP, you do not need a MQTT broker (server).
MQTT is considered as more efficient than HTTP (about a factor 100).
See for a comparison e.g.: https://medium.com/mqtt-buddy/mqtt-vs-h ... 68169b3105
I think I'll have a look at that dzVents script too, it looks easier, in a way..
It is a matter of knowledge and experience. I am more familiar with Node Red than dZvents
But also, which tool you have already set-up and running.

If you need more support, let me know.

Regards
benedict
Posts: 16
Joined: Thursday 16 December 2021 16:05
Target OS: Linux
Domoticz version:
Contact:

Re: Read-out of Power production of individual solar panels with Enphase microinverters

Post by benedict »

FireWizard wrote: Thursday 12 September 2019 23:29 Do not forget to configure the configuration of the timecontrol (The pencil at the right).
Insert your lat/lon co-ordinates.
"Starting from Version 2.0 the coordinates are not saved as credentials due to privacy reasons. So they no longer part of the regular flow and will not part of the export! To update from a previous version save and re-deploy is necessary."
I don't see a pencil either. And I still have trouble following your node-red instructions. They are totally different from what I'm seeing. Probably older version in your case. I checked some of the videos you pointed me to, but they too are for older node-red versions. (Hate when that happens..)
Still don't see the panel info coming in.
It's sad that Home Assistant is such a horrible OS-take-over thing, because they have it down with Enphase. It sees them, shows them, just a few clicks away. I just can't install HA because it needs an entire OS to function besides other server systems. And I detest docker, so I'll stay with domoticz.
User avatar
FireWizard
Posts: 1747
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Read-out of Power production of individual solar panels with Enphase microinverters

Post by FireWizard »

@benedict

You are correct with your statement:
Probably older version in your case.
I started with another Time switch, but after I got some troubles with it, in another flow, I replaced them (in all cases) with the node-red-contrib-time-switch node. And indeed this node does not have any configuration in a separate node. So no configuration pencil.

Can you explain, how far you are at the moment. What is working and what is not working?

Let me know.

Regards
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest