Git Product home page Git Product logo

Comments (16)

nmakel avatar nmakel commented on June 19, 2024 1

Hi, thanks a tonne for this project, it's quite awesome!

Thanks!

I've used your sample influx script to dump the data to influxdb, and have Grafana plugged in over the top and been able to create a few graphs such as power usage, production, temp monitors, and wondering if you have anything built or what you use to visualize the data.

My setup is similar, solaredge_modbus, combined with solaredge_setapp (for module level reporting) and sdm_modbus (which is my kWh meter measuring import+export at the grid), all reporting to influxdb, with grafana on top.

On a PV panel I plot voltage_dc, power_ac, and temperature to get a general picture of the state of things. I then have individual graphs of module voltages and current grouped by orientation (east facing modules, and west facing modules). In dashboard style I show the latest power_ac, ac voltage, ac frequency, dc voltage, production today, this month, and all time (from solaredge_setapp).

On a more general panel which also show temperature readings from around the house, along with central heating stats, I show a large graph of the inverter's power_ac, voltage dc, and the consumption as calculated from the actual import or export power measurement by my kWh meter. This graph shows whether the system is producing anything, when the production and consumption spikes were, and gives a general picture of production and consumption throughout the day. I find this graph alone enough for a quick glance at how things are going. Add a couple dashboard style gauges for current power_ac, voltages and temperature, and you should be fine.

Edit: I should add that I calculate daily usage, import and export, by looking at values reported by my kWh meter only. It is possible to do basic difference calculations on values such as energy_total with queries such as:

SELECT difference(last("energy_total")) *1000 FROM "pv" WHERE $timeFilter GROUP BY time(1d)

from solaredge_modbus.

iNaiks avatar iNaiks commented on June 19, 2024

hi @Bonn93,
Seeing that you are running, I've a question for you xD.
I've an error running the example_influxdb.py, maybe I'm running wrong.
I use the terminal with command: pythoon3 example_influxdb.py [and the other commands with database, user, password, host...]
Is correct? or I need to run with a python program or something? (I use a raspberry pi)

Can you explain me how do you run? (if you want)

Thanks
Nico

from solaredge_modbus.

Bonn93 avatar Bonn93 commented on June 19, 2024

@iNaiks so I originally tested with a python/terminal and wrapped into a docker image that a built, so I could set a few things to work for me, I had an earlier version where it tried a new modbus library which didn't work well, and had to tweak the requirements.

But, sharing is caring! Here's my docker run script ( it was in k8s, but had some issues with influx storage and had to move to plain old docker whilst rebuilt things ).

I also use the latest 1.8.X release on InfluxDB, not 2.X as it had a bunch of weird issues.

#!/bin/bash

docker stop modbus
docker rm mobus

docker run -d \
--name=modbus \
--restart=always \
-e INVERTER_IP=10.5.90.2 \
-e INVERTER_PORT=1502 \
-e INFLUX_HOST=10.5.70.3 \
-e INFLUX_PORT=8086 \
-e INFLUX_DB=solaredge \
-e INFLUX_USER=solaredge\
-e INFLUX_PASSWORD=solaredge\
mbern/modbus-solaredge:latest

The dockerfile is more interesting and shows how I run it.

FROM python:3.7.9

RUN mkdir /modbus
WORKDIR /modbus
ADD ./python/solaredge_modbus /modbus
ADD ./requirements.txt /modbus
ADD ./example_influxdb.py /modbus

RUN pip install influxdb
RUN pip install -r requirements.txt
#RUN python setup.py install

ENV PYTHONUNBUFFERED=1

WORKDIR /modbus
CMD ["/bin/bash", "-c", "python3 example_influxdb.py ${INVERTER_IP} ${INVERTER_PORT} --influx_host ${INFLUX_HOST} --influx_port ${INFLUX_PORT}  --influx_db ${INFLUX_DB} --influx_user ${INFLUX_USER} --influx_pass ${INFLUX_PASSWORD}"]

It's not perfect, but does the job. Ideally, I need to raise a PR and would like to use python to read the OS.envs to build the config, and it does need more logging that works differently when run direct via python in your own shell.

from solaredge_modbus.

iNaiks avatar iNaiks commented on June 19, 2024

@Bonn93 @nmakel Thanks for the info,

But my first problem is build the python into a docker... (I know networks things, not programming, sorry)
I've a nas (Synology) with docker (for read and calculate the information) and a raspberry with a screen to see Grafana graphics.

What docker image I need to install or build with python?

Thanks
Nico

from solaredge_modbus.

nmakel avatar nmakel commented on June 19, 2024

What docker image I need to install or build with python?

You don't need to run the script in a docker container. What error are you getting when you run the script currently?

from solaredge_modbus.

Bonn93 avatar Bonn93 commented on June 19, 2024

@Bonn93 @nmakel Thanks for the info,

But my first problem is build the python into a docker... (I know networks things, not programming, sorry)
I've a nas (Synology) with docker (for read and calculate the information) and a raspberry with a screen to see Grafana graphics.

What docker image I need to install or build with python?

Thanks
Nico

So the dockerfile i linked above shows how you can build it, mines a little different because I use this repo as a submodule, that way I get all the version control and updates from this repo within my own repo.

But, if you read the dockerfile carefully, you'll understand how it works.

FROM python:3.7.9 is using the python docker image as the base, and i use python 3.7.9 specifically.

RUN mkdir /modbus
WORKDIR /modbus

These lines I create a directory in the container image, and set my working directory to this one.

ADD ./python/solaredge_modbus /modbus
ADD ./requirements.txt /modbus
ADD ./example_influxdb.py /modbus

These lines I add basically the entire repo to my workdir, but then I also add the requirements.txt file ( which is consumed by pip ) I then add the exact script into the container being example.influx.py to my workdir.

RUN pip install influxdb
RUN pip install -r requirements.txt

I then run pip ( which is like a package manger for python, included in the docker image you may need to install this locally to play/test ( apt install python3-pip ) for example.

Pip then installs all the libraries/packages defined in requirements.txt

CMD ["/bin/bash", "-c", "python3 example_influxdb.py ${INVERTER_IP} ${INVERTER_PORT} --influx_host ${INFLUX_HOST} --influx_port ${INFLUX_PORT}  --influx_db ${INFLUX_DB} --influx_user ${INFLUX_USER} --influx_pass ${INFLUX_PASSWORD}"]

Finally, I run the script via bash, it executes python, in a normal shell, this would be something like this:

python3 example_influx.py 10.0.0.50 1502 --influx-host=10.0.0.51

Ultimately, ignore all the docker stuff, get it working with python locally first. Install python 3.7.9, install pip, run the pip install, run the script at let us know how you go with the basics, in a shell, it'll spit out stuff, or get the example.py working first.

from solaredge_modbus.

Bonn93 avatar Bonn93 commented on June 19, 2024

Hi, thanks a tonne for this project, it's quite awesome!

Thanks!

I've used your sample influx script to dump the data to influxdb, and have Grafana plugged in over the top and been able to create a few graphs such as power usage, production, temp monitors, and wondering if you have anything built or what you use to visualize the data.

My setup is similar, solaredge_modbus, combined with solaredge_setapp (for module level reporting) and sdm_modbus (which is my kWh meter measuring import+export at the grid), all reporting to influxdb, with grafana on top.

On a PV panel I plot voltage_dc, power_ac, and temperature to get a general picture of the state of things. I then have individual graphs of module voltages and current grouped by orientation (east facing modules, and west facing modules). In dashboard style I show the latest power_ac, ac voltage, ac frequency, dc voltage, production today, this month, and all time (from solaredge_setapp).

On a more general panel which also show temperature readings from around the house, along with central heating stats, I show a large graph of the inverter's power_ac, voltage dc, and the consumption as calculated from the actual import or export power measurement by my kWh meter. This graph shows whether the system is producing anything, when the production and consumption spikes were, and gives a general picture of production and consumption throughout the day. I find this graph alone enough for a quick glance at how things are going. Add a couple dashboard style gauges for current power_ac, voltages and temperature, and you should be fine.

Edit: I should add that I calculate daily usage, import and export, by looking at values reported by my kWh meter only. It is possible to do basic difference calculations on values such as energy_total with queries such as:

SELECT difference(last("energy_total")) *1000 FROM "pv" WHERE $timeFilter GROUP BY time(1d)

I didn't even see your panel level stuff, I wonder if my SE10000H is supported, I did play with setapp stuff to get modbus going...

Do you think you could share the grafana dashboards/template you have? It would be pretty cool if that could be a grafana template, I think many others would like it, I know a few folks with solaredge inverters all trying for the same type of monitoring. Any chance you could export your dashboard/json via grafana ( it removes and templates the queries ) mostly...

from solaredge_modbus.

iNaiks avatar iNaiks commented on June 19, 2024

What docker image I need to install or build with python?

You don't need to run the script in a docker container. What error are you getting when you run the script currently?

Ok, but I prefer to run all the things on the nas with docker. And use the raspberry only for watch the graphics in Grafana.
How can I create a docker to run the python scrip. I've the influxDB server and grafana server, installed on other dockers.

Very Thanks
Nico

from solaredge_modbus.

Bonn93 avatar Bonn93 commented on June 19, 2024

@iNaiks not trying to be rude here, but everything is in the above, you might need to go and understand the basics on containers and building images before you look at this.

from solaredge_modbus.

iNaiks avatar iNaiks commented on June 19, 2024

Captura de pantalla 2021-08-17 a las 21 01 18 @iNaiks not trying to be rude here, but everything is in the above, you might need to go and understand the basics on containers and building images before you look at this.

Yes, I have deleted everything and I have started again from the beginning and now everything works XD.
The only problem is that the NAS just broke ... But before that, it was perfect. Thanks a lot

from solaredge_modbus.

iNaiks avatar iNaiks commented on June 19, 2024

Captura de pantalla 2021-08-18 a las 14 51 38

The only think is sometimes the scrip stops and I need to open the terminal in docker container, and run again. I've a docker container in a Synology. I access via web to the UI of docker and I have a terminal (bash) open in a specified directory (/home/solaredge_modbus-master), and then I run the command (python3 example_influxdb.py 10.1.0.254 1502 --influx_host XXXX --influx_port 8086 --influx_db XXXX --influx_user XXXX --influx_pass XXXX --timeout 2)

A few hours later, the command stops (I can't see the error because when I go in the terminal via web on Synology, there isn't any error and is like a terminal console waiting for an input command)

There is anything that I can do for run again the scrips when stops or stop the scrip every hour and restart it again automatically?

Thanks Nico

from solaredge_modbus.

TuxFan777 avatar TuxFan777 commented on June 19, 2024

In regards to Bonn93's original thread topic, I've been trying to put together a close approximation of what we see in the online SolarEdge monitoring portal.

This is what I've ended up with :

image

To achieve this, I've modified Niels' "example_influxdb.py" utility to populate an additional InfluxDB MEASUREMENT set I’ve called "graph". This allowed me to get around InfluxDB's annoying inability to perform simple maths across multiple measurements (e.g. inverter, meter, battery). I'm performing all the required maths in the Python script as part of writing the metrics that I actually need for Grafana into InfluxDB’s "graph" MEASUREMENT.

There's been some cursing throughout the journey, but very happy now with the result.

Hat's off to Niels and the solaredge_modbus team for making this possible!

@iNaiks – In regards to the Python script dying on a regular basis, from what I can tell it’s the inverter itself that triggers this crash at random times when it fails to return properly formed data (possibly just busy collecting data to send to the online SolarEdge portal at that exact second).

The approach I ended up taking was to write a tiny wrapper script to check whether my solaredge_modbus Python script was already running and restart it if it wasn’t. I then added a cron job to run this wrapper script every minute of the day.

Bit of a hack, but it’s worked well for me so far.

Hope this helps others.

from solaredge_modbus.

Bonn93 avatar Bonn93 commented on June 19, 2024

@TuxFan777 this looks awesome! Is the code added anywhere, how much of this is using the measurement methods in influx? Can you share the grafana json too?

from solaredge_modbus.

TuxFan777 avatar TuxFan777 commented on June 19, 2024

Thanks @Bonn93 - Appreciate the feedback!

Here is my modified version of Niels' "example_influxdb.py" utility which includes the additional "graph" MEASUREMENT that I've used in Grafana. I wasn't sure whether it was appropriate to upload this directly to the project's Code repository without Niels' blessing, so leaving it here for anyone who wants it :

example_influxdb_with_graph_measurement_TuxFan777.zip

I'll also spend some time cleaning up a json export of the Grafana dashboard for you (minus db credentials, etc.).
Will post that as soon as it's ready.

from solaredge_modbus.

TuxFan777 avatar TuxFan777 commented on June 19, 2024

Hi @Bonn93 - Grafana json export attached below as promissed :

solaredge_grafana_TuxFan777.zip

Let me know how it works out for you.

from solaredge_modbus.

frezeen avatar frezeen commented on June 19, 2024

@TuxFan777 i try ur modified py and i got this error:

today at 15:15:42 SyntaxError: invalid syntax
today at 15:16:36 Traceback (most recent call last):
today at 15:16:36   File "/solaredge_modbus/example_influxdb.py", line 54, in <module>
today at 15:16:36     battery1 = inverter.batteries()["Battery1"]
today at 15:16:36 KeyError: 'Battery1'
today at 15:16:38 Traceback (most recent call last):

edit: i delete all references to battery1 and battery2 from script becouse i dont have batteries and its running right now without errors.
i have the graph metrics now. the question is: all metrics are in? Wh?
edit2: can u add math for energy_total, export_energy_active, import_energy_active" for to calculate kWh/mo costs
example: right now i have

production: SELECT difference(last("energy_total")) FROM "inverter" WHERE $timeFilter GROUP BY time(24h) tz('Europe/Rome')

export: SELECT difference(last("export_energy_active")) FROM "meter" WHERE $timeFilter GROUP BY time(24h) tz('Europe/Rome')

kwh selfconsuption cost math expression: ($Production - $export) * ( 0.20 / 1000)

i dont want to use expression becouse i cant use cost $price variable with it.
if u let me know how to add this expression in .py with example ill add the other i need too myself.

i need script do: energy total from meter - export energy active from meter and with this i can use a query like: kwh energy selfconsuption * $price

from solaredge_modbus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.