Coder Social home page Coder Social logo

marcuswichelmann / energyexporter Goto Github PK

View Code? Open in Web Editor NEW
22.0 5.0 2.0 2.48 MB

Collects data from Modbus devices like SolarEdge inverters and exports it as JSON, XML or to Prometheus/InfluxDB.

License: MIT License

C# 99.12% Dockerfile 0.88%
solaredge photovoltaics sunspec prometheus inverter influxdb solar

energyexporter's Introduction

EnergyExporter (previously SolarEdgeExporter)

This project was renamed and refactored to be usable for other devices than just SolarEdge.

Collects data from Modbus devices like inverters, batteries or energy meters and exports it as JSON, XML or to Prometheus/InfluxDB and Mqtt.

The data is queried over Modbus TCP. For now, the following devices are supported:

  • SolarEdge (over SunSpec)
    • Inverters
    • Energy meters
    • Batteries (StorEdge, BYD, ...)
  • Janitza
    • Energy Meters
      • UMG 96-PA with UMG 96-PA-RCM-EL Ethernet module

Other device models that use similar Modbus registers may also work.

It's possible to query any number of devices at the same time.

Usage

Configuration

This exporter can be configured through commandline arguments, environment variables (details) or via a appsettings.json file. The last option is probably the easiest.

You can find an example for such a configuration file at src/EnergyExporter/appsettings.sample.json. This shows all available configuration options. Just create your own appsettings.json based on that sample.

The Devices section is the main part and configures all the devices that should be queried via Modbus TCP, grouped by vendor. When multiple configured devices use the same Modbus TCP server, the TCP connection is shared between them, as many devices (e.g. SolarEdge) don't allow multiple clients to connect to Modbus TCP at the same time.

When the Modbus devices are in a master-slave configuration, the Unit number should be counted up for every slave. If you don't know the correct order, you can just try different options. If the exporter hangs on start, the Unit number is probably wrong and it doesn't receive any response from the device.

The InfluxDB section in the export configuration is fully optional and can be configured to push all queried metrics directly to an InfluxDB instance. If you don't need that, just remove that section.

Likewise, the Mqtt section in the export configuration is optional and can be configured to publish all queried metrics directly to an MQTT broker. If you don't need it, just remove that section, too.

If needed, you can enable extended logging by setting the default log level in appsettings.json to Debug.

Run the exporter

Using Docker

This repository provides Docker images using the GitHub Container Registry to get things running easily: Images

Sample docker-compose.yml:

energy-exporter:
    image: ghcr.io/marcuswichelmann/energy-exporter:3
    container_name: energy-exporter
    ports:
        - "14552:80"
    volumes:
        - /path/to/appsettings.json:/app/appsettings.json
    restart: always

Using .NET

You can also install the .NET SDK on your system and run the exporter this way:

  • Pull this repository and navigate into src/EnergyExporter
  • Create an appsettings.json (see appsettings.sample.json) with your configuration options
  • Execute dotnet run -c Release

Access metrics

While the exporter is running and has access to the Modbus TCP interface, it will query all data for the available devices in a regular interval (IntervalSeconds).

Now visit the IP address and port (14552 by default) of the running exporter to see the queried device data.

The available URLs are:

  • /metrics: Prometheus metrics
  • /devices: REST API (see Swagger documentation)
  • /swagger: Interactive API documentation

The REST API will export the data in a readable JSON format. If you prefer XML, just set the HTTP Accept header to application/xml and you will get the response as XML.

Vendors

SolarEdge

Enable Modbus TCP

To enable the Modbus TCP interface on your SolarEdge inverter, enable its configuration Wifi (turn the switch on the inverter to P) and connect to it using the QR code on its side. You don't have to use the SolarEdge app, just connect using your phone's WiFi settings. After that you can visit the IP address (the WiFi gateway IP) of the inverter and enable Modbus TCP in the configuration interface.

You can also use the SolarEdge SetApp to enable Modbus TCP, but that will require you to be a verified installer and grant you only read-only access otherwise.

Janitza

This exporter was tested with the UMG 96-PA power analyzer with the UMG 96-PA-RCM-EL Ethernet module. It should also be possible to use an external Modbus gateway instead of the UMG 96-PA-RCM-EL.

energyexporter's People

Contributors

marcuswichelmann avatar yguy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

kafisatz yguy

energyexporter's Issues

InfluxDB

I'm looking to check which InfliuxDB version can be used with this awesome program. I'm running 1.x release at the moment, any compatibility? Thanks

Bring back linux-arm (armv7) docker images

Support for Docker Images on armV7 has been removed in this commit. The comment says that there's likely no one using it, but actually at least I was :-(

ArmV7 is what's running RaspberryPI and this is actually great for home automation which I would like to use this project for.

I am pasting this here for others to find. If you know of a better way, I would be happy to hear about it!

So the only quick workaround I found was to build the docker image manually on the PI (which takes many minutes on the PI4). To get this to work, I had to adjust the dockerfile to use the generic base image and then pass in the build arguments for TARGETARCH and TARGETOS to arm and linux.

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.