alexeyden / openess

Metrics export daemon for PowMr solar invertors (self hosted SmartESS mobile app replacement)
4 stars 1 forks source link

I have error for Anenji 4kw #2

Open sabatex opened 1 month ago

sabatex commented 1 month ago

go run ./cmd/openess/*.go -b -d 192.168.1.128:58899 -l debug INFO 2024/09/21 07:36:40 client: connecting to device 192.168.1.128:58899 DEBUG 2024/09/21 07:36:40 proto: starting up tcp server on 8899 port DEBUG 2024/09/21 07:36:40 proto: requesting datalogger connection to 192.168.1.99:8899 DEBUG 2024/09/21 07:36:40 proto: datalogger conncted DEBUG 2024/09/21 07:36:40 proto: setting timeout 5000 ms DEBUG 2024/09/21 07:36:40 proto: read header {TID:1 DevCode:258 Size:6 DevAddr:255 FuncCode:2} DEBUG 2024/09/21 07:36:40 proto: read body 00016e756c6c DEBUG 2024/09/21 07:36:40 commands:info: got response: par = 1 data = null DEBUG 2024/09/21 07:36:40 proto: setting timeout 5000 ms DEBUG 2024/09/21 07:36:40 proto: read header {TID:1 DevCode:258 Size:16 DevAddr:255 FuncCode:2} DEBUG 2024/09/21 07:36:40 proto: read body 00025130303435323331373635303531 DEBUG 2024/09/21 07:36:40 commands:info: got response: par = 2 data = Q0045231765051 DEBUG 2024/09/21 07:36:40 proto: setting timeout 5000 ms DEBUG 2024/09/21 07:36:40 proto: read header {TID:1 DevCode:258 Size:9 DevAddr:255 FuncCode:2} DEBUG 2024/09/21 07:36:40 proto: read body 0005332e362e372e36 DEBUG 2024/09/21 07:36:40 commands:info: got response: par = 5 data = 3.6.7.6 DEBUG 2024/09/21 07:36:40 proto: setting timeout 5000 ms DEBUG 2024/09/21 07:36:40 proto: read header {TID:1 DevCode:258 Size:9 DevAddr:255 FuncCode:2} DEBUG 2024/09/21 07:36:40 proto: read body 0006332e302e302e30 DEBUG 2024/09/21 07:36:40 commands:info: got response: par = 6 data = 3.0.0.0 DEBUG 2024/09/21 07:36:40 proto: setting timeout 5000 ms DEBUG 2024/09/21 07:36:40 proto: read header {TID:1 DevCode:258 Size:21 DevAddr:255 FuncCode:2} DEBUG 2024/09/21 07:36:40 proto: read body 0007323032342d30382d30372031383a34383a3039 DEBUG 2024/09/21 07:36:40 commands:info: got response: par = 7 data = 2024-08-07 18:48:09 DEBUG 2024/09/21 07:36:40 proto: setting timeout 5000 ms DEBUG 2024/09/21 07:36:40 proto: read header {TID:1 DevCode:258 Size:3 DevAddr:255 FuncCode:2} DEBUG 2024/09/21 07:36:40 proto: read body 000b30 DEBUG 2024/09/21 07:36:40 commands:info: got response: par = 11 data = 0 DEBUG 2024/09/21 07:36:40 proto: setting timeout 5000 ms DEBUG 2024/09/21 07:36:40 proto: read header {TID:1 DevCode:258 Size:3 DevAddr:255 FuncCode:2} DEBUG 2024/09/21 07:36:40 proto: read body 000c31 DEBUG 2024/09/21 07:36:40 commands:info: got response: par = 12 data = 1 DEBUG 2024/09/21 07:36:40 proto: setting timeout 5000 ms DEBUG 2024/09/21 07:36:40 proto: read header {TID:1 DevCode:258 Size:7 DevAddr:255 FuncCode:2} DEBUG 2024/09/21 07:36:40 proto: read body 0030312c302c30 DEBUG 2024/09/21 07:36:40 commands:info: got response: par = 48 data = 1,0,0 DEBUG 2024/09/21 07:36:40 proto: setting timeout 5000 ms DEBUG 2024/09/21 07:36:40 proto: read header {TID:1 DevCode:258 Size:4 DevAddr:255 FuncCode:2} DEBUG 2024/09/21 07:36:40 proto: read body 00033030 DEBUG 2024/09/21 07:36:40 commands:info: got response: par = 3 data = 00 DEBUG 2024/09/21 07:36:40 proto: setting timeout 5000 ms DEBUG 2024/09/21 07:36:40 proto: read header {TID:1 DevCode:258 Size:5 DevAddr:255 FuncCode:2} DEBUG 2024/09/21 07:36:40 proto: read body 0004312e32 DEBUG 2024/09/21 07:36:40 commands:info: got response: par = 4 data = 1.2 DEBUG 2024/09/21 07:36:40 proto: setting timeout 5000 ms DEBUG 2024/09/21 07:36:40 proto: read header {TID:1 DevCode:258 Size:14 DevAddr:255 FuncCode:2} DEBUG 2024/09/21 07:36:40 proto: read body 000e303246462c302c302c233023 DEBUG 2024/09/21 07:36:40 commands:info: got response: par = 14 data = 02FF,0,0,#0# DEBUG 2024/09/21 07:36:40 proto: setting timeout 5000 ms DEBUG 2024/09/21 07:36:40 proto: read header {TID:1 DevCode:258 Size:12 DevAddr:255 FuncCode:2} DEBUG 2024/09/21 07:36:40 proto: read body 0022393630302d382d312d30 DEBUG 2024/09/21 07:36:40 commands:info: got response: par = 34 data = 9600-8-1-0 DEBUG 2024/09/21 07:36:40 proto: setting timeout 5000 ms DEBUG 2024/09/21 07:36:40 proto: read header {TID:1 DevCode:258 Size:15 DevAddr:255 FuncCode:2} DEBUG 2024/09/21 07:36:40 proto: read body 00294b65656e657469632d32313238 DEBUG 2024/09/21 07:36:40 commands:info: got response: par = 41 data = Keenetic-2128 INFO 2024/09/21 07:36:40 client: connected to datalogger: manufacturer 00 device type null (protocol v1.2 props 02FF,0,0,#0#) DEBUG 2024/09/21 07:36:40 client: datalogger info {DeviceType:null SerialNumber:Q0045231765051 FirmwareVersion:3.6.7.6 HardwareVersion:3.0.0.0 FactoryTime:2024-08-07 18:48:09 DevicesOnline:0 MonitoredDevices:1 ConnectionStatus:1,0,0 Manufacturer:00 ProtocolVersion:1.2 DeviceProps:02FF,0,0,#0# SerialBaudrate:9600-8-1-0 SSID:Keenetic-2128} INFO 2024/09/21 07:36:40 client: WARNING protocols other than 0925 are untested ERROR 2024/09/21 07:36:40 failed to load protocol descriptor: json: invalid use of ,string struct tag, trying to unmarshal unquoted value into uint8 INFO 2024/09/21 07:36:40 client: loaded protocol descriptor: data//02FF.json ERROR 2024/09/21 07:36:40 openess: failed to init collector: descriptor is not loaded exit status 1 Makefile:15: recipe for target 'run-daemon' failed make: *** [run-daemon] Error 1

misaka-eth commented 1 month ago

POW-HVM6.2M-48V. Same here. My protocol descriptor "02FF", but this looks like wrong. I tried to load 0925.json and it worked. Also if we look at this project https://github.com/odya/esphome-powmr-hybrid-inverter they have confirmed many working powmrs with 0925-like register addresses. Maybe we can add config parameter for manual descriptor selection?

alexeyden commented 1 month ago

I've added a config parameter that allows to override autodetected protocol as @misaka-eth suggested.

@sabatex can you try with 0925 protocol ?

Here's the config example:

{
    "BindPort": 8899,
    "DeviceAddr": "192.168.1.37:58899",
    "ProtoPath": "data/",
    "Protocol": "0925",   // HERE
    "Export": {
        "Broker": "tcp://127.0.0.1:1883"
    },
    "Collector": {
        "Interval": "500ms",
        "Enabled": true,
        "Registers": {
            "working_state": "Working State",
            "output_voltage": "Output voltage",
            "output_power": "Output apparent power ",
            "output_active_power": "Output active power",
            "output_power_percent": "AC output Load %"
        }
    }
}

I'll revisit decompiled SmartESS sources when I have some time. Looks like it does something a bit more complicated when detecting the protocol than simply taking the protocol string out of reported properties

sabatex commented 1 month ago

Fix error in mqtt.go, line 123 122 if config.Password != nil { 123 opts.SetUsername(*config.Password) //SetPassword 124 }

alexeyden commented 1 month ago

Fixed, thanks

sabatex commented 1 month ago

The register addresses are not the same for my inverter, similar addresses are https://github.com/HotNoob/PythonProtocolGateway/blob/main/protocols/eg4/eg4_3000ehv_v1. I tested some of the registers with www.dessmonitor.com. I'm not proficient in Go. My main programming language is C#. How do I fix the file 0925.json the logger read my registers. Thanks.

alexeyden commented 1 month ago

Can you confirm that reading those registers via read-raw command in CLI mode works and returns meaningful values?

E.g.:

❯ ./openess
INFO    2024/09/24 08:33:57 client: connecting to device 192.168.1.37:58899
INFO    2024/09/24 08:33:58 client: connected to datalogger: manufacturer 37 device type 8 (protocol v1.2 props 0925,5,5,#0#)
INFO    2024/09/24 08:33:58 client: loaded protocol descriptor: data//0925.json
% read-raw 1 3 201 1
0100

The syntax is read-raw DEV_ADDR FUNCTION ADDRESS LENGTH

It will return read value as a hex dump (values are little endian)

If it does, you can simply write a register descriptor json for your inverter. I'll provide a minimal example a bit later

stripu commented 1 month ago

The register addresses are not the same for my inverter, similar addresses are https://github.com/HotNoob/PythonProtocolGateway/blob/main/protocols/eg4/eg4_3000ehv_v1. I tested some of the registers with www.dessmonitor.com. I'm not proficient in Go. My main programming language is C#. How do I fix the file 0925.json the logger read my registers. Thanks.

Hello! I might have the same inverter as you, the 4Kw 24v Anenji. I'm also trying to get this to work with it. Can you also tell me how you're testing the registers with dessmonitor.com? Because I tried all kinds of commands, but i only get "null" response.

Thank you!

sabatex commented 1 month ago

Hello! I wrote new code for [NetDaemon](Home Assistant). Benefits, after publish project device automaticaly registered in Home Assistant with all sensors. InverterAnenji-4kw-7.2kw