GithubHelp home page GithubHelp logo

kubaceg / sofar_g3_lsw3_logger_reader Goto Github PK

View Code? Open in Web Editor NEW
15.0 2.0 9.0 284 KB

Tool written in GO for reading and exporting metrics from Sofar LSW-3 inverters with SN 23XXXXXXX

License: GNU General Public License v3.0

Dockerfile 1.23% Go 96.84% Makefile 0.49% Shell 1.44%
lsw3 sofar sofarsolar mqtt otlp

sofar_g3_lsw3_logger_reader's Introduction

Sofar g3 LSW-3 logger reader

Gorelease

Tool written in GO for reading metrics from Sofar LSW-3 and writing results into MQTT topics. Program queries logger modbus port in infinite loop and sends data into MQTT topics (e.g. mosquito in HomeAssistant).

Installation and setup

  1. Download go 1.19
  2. Clone this repo git clone [email protected]:kubaceg/sofar_g3_lsw3_logger_reader.git
  3. Go into project directory cd sofar_g3_lsw3_logger_reader
  4. Copy example config cp config-example.yaml config.yaml
  5. Edit config.yaml in Your favorite editor, fill all required stuff
  6. Build program make build or build for ARM machines e.g. raspberryPi make build-arm
  7. Run bin/sofar or bin/sofar-arm

Output data format

MQTT

Data will be sent into MQTT topic with name {mqttPrefix}/{fieldName} where:

  • mqttPrefix is value defined in config.yaml e.g. /sensors/energy/inverter
  • fieldName is measurement name, all available measurements are described in adapters/devices/sofar/sofar_protocol.go, e.g. PV_Generation_Today

Full topic name for given example values is /sensors/energy/inverter/PV_Generation_Today. Additional field is All which contains all measurements and their values marshalled into one json.

Home Assistant

This tool can integrate with Home Assistant using MQTT protocol. If You want to configure MQTT along with discovery feature, just fill 'ha_discovery_prefix' and all sensors will be configured automatically in Your Home Assistant instance.

OTLP

Data can also be sent over OTLP protocol to a gRPC or http server. Typically, this would be received by the OTel-Collector for further export to any required platform.

Metrics are all captured as gauges and recorded and exported at the same frequency that measurements are taken. Metric names follow the convention sofar.logger.<fieldName> by default. This can be updated in the configuration file.

Grafana dashboard

You can monitor Your solar instalation using grafana dashboard

Origin

This is based on program written by @sigxcpu76 XtheOne/Inverter-Data-Logger#37 (comment).

Contributing

Feel free if You want to extend this tool with new features. Just open issue or make PR.

sofar_g3_lsw3_logger_reader's People

Contributors

brianroch avatar icez avatar kubaceg avatar

Stargazers

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

Watchers

 avatar  avatar

sofar_g3_lsw3_logger_reader's Issues

Failed to perform measurements

Hello,

I'm facing issues with reader
Here is the exact error

2023/02/05 20:25:01 using TCP/IP communications port 192.168.xx.xx:8899
2023/02/05 20:25:01 performing measurements
2023/02/05 20:25:01 MQTT Connected
2023/02/05 20:25:03 failed to perform measurements: short reply: 29 bytes
2023/02/05 20:25:03 performing measurements

I'm using Afore inverter with LSW-3 logger:
Firmware version: LSW3_15_1E03_1.31

serial is: 2327xxxxxx

Checked with nmap - port 8899 is open

Here is registry file, shared from Afore:

AFORE_T4.pdf

Nonsense values in PV_Generation_Today metric

I use this logger reader sending data through MQTT to my Home Assistant. Sometimes my reader sens nonsense PV_Generation_Today metric value e.g. 345178783 which means that my solar generates 3.45 GWh power today :D quite good value but unfortunately it's not real value. After such peak values are corrected to the proper one.
I don't know if these bad values came from the inverter or maybe from errors in deserialization, it's hard to debug.

The problem is in Home Assistant because the energy dashboard stores every diff value from the sensor and displays graphs based on the sum of these diff values, so I have peaks like this on screenshot and fixing it manually is a pain in the ass.
image

Here is PV_Generation_Today and PV_Generation_Total graph from grafana:
image

My idea to fix this issue is to introduce filter mechanism which can check for failed metrics and don't send them. This filter will be activated for each exporter individually (I want to see those errors in my grafana). I have an idea for 2 filters now:

  • don't send if PV_Generation_Today is greater than PV_Generation_Total.
  • dont' send if there is if any of Fault* metrics are greater than 0.

Has anyone else encountered this problem?

help with this integration

I have no experience in programming, nor do I have experience in using Home Assistant, I need to test this integration, since I cannot obtain all the necessary data through Solarman, can you help me with this?
thank you

Sensors for Purchase, Selling and Ratio

Verry good work. This works verry good for me to integrate my Inverter to Home Assistant.
Maybe you can add more Sensors:

Register/addressFiel/Type/Accuracy
1672 Load_Consumption_Today U32 0,01
1673
1674 Load_Consumption_Total U32 0,1
1675
1676 Energy_Purchase_Today U32 0,01
1677
1678 Energy_Purchase_Total U32 0,1
1679
1680 Energy_Selling_Today U32 0,01
1681
1682 Energy_Selling_Total U32 0,1

4153 PV_Generation_Ratio U16 0,001
4154 Energy_Purchase_Ratio U16 0,001
4155 Energy_Selling_Ratio U16 0,001
4156 Bat_Charge_Ratio U16 0,001
4157 Bat_Discharge_Ratio U16 0,001

Docker build failing on main branch

Docker build currently failing on main branch with the error:

   4 |     
   5 | >>> RUN apt update && apt install -y ca-certificates tzdata && \
   6 | >>>   cd /src && go build && /bin/mv -vf /src/sofar* /sofar
   7 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c apt update && apt install -y ca-certificates tzdata &&   cd /src && go build && /bin/mv -vf /src/sofar* /sofar" did not complete successfully: exit code: 1

Full log attached. docker-fail.log

cc: @icez

Docker version details below:

$ docker version
Client: Docker Engine - Community
 Version:           23.0.1
 API version:       1.42
 Go version:        go1.19.5
 Git commit:        a5ee5b1
 Built:             Thu Feb  9 19:46:56 2023
 OS/Arch:           linux/amd64
 Context:           default

how to make it run in HA OS?

Hi, built OK, but how do I add this to my HA OS? Where do I put the executable and how do I make it run? I see there are lots of other projects doing similar things for different data loggers, so I guess everyone but me knows what to do.

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.