Paxy / SmartESS-proxy

SmartESS (PowMr) to MQTT proxy
14 stars 5 forks source link

No topic on MQTT #4

Open AndrewT1000 opened 6 months ago

AndrewT1000 commented 6 months ago

Sorry for my English. The program starts, receives data from the logger and sends it further, the settings from SmartESS also work. However, no data appears on the MQTT broker. Logs from the broker show that the client connected successfully. What else can I check?

Paxy commented 6 months ago

Can you show a log from java service?

AndrewT1000 commented 6 months ago

I have little contact with Java. How to see these logs? Any parameters at startup? I have it under debian 12.

console run:

root@debian12:/usr/SmartESS-proxy-main/bin# java -jar SmartESS-proxy.jar 2024-05-13 21:14:09.834 - Connected to server 47.242.188.205 2024-05-13 21:14:09.936 - MQTT connected 2024-05-13 21:14:10.141 - Server: 598A0001000AFF0118050D130E090023 2024-05-13 21:14:10.141 - Waiting for node ... 2024-05-13 21:14:10.771 - Connected node 192.168.43.11 2024-05-13 21:14:10.973 - Node: 598A01020010FF015130303237303832383130373539

Paxy commented 6 months ago

If you have started the process with screen command, type screen -r to resume the screen and see the last logs. JAR when starter, reports what inverter and cloud have sent. I need to see that log report to be able to help you.

AndrewT1000 commented 6 months ago

with such a command java -jar SmartESS-proxy.jar 2>>sm.log sm.log file is empty

command: screen -dmS jar1 bash -c 'java -jar SmartESS-proxy.jar' result screen -r:

2024-05-14 09:08:18.035 - Connected to server 47.242.188.205 2024-05-14 09:08:18.091 - MQTT connected 2024-05-14 09:08:18.353 - Server: 40A70001000AFF0118050E0708120023 2024-05-14 09:08:18.353 - Waiting for node ... 2024-05-14 09:08:18.867 - Connected node 192.168.43.11 2024-05-14 09:08:19.068 - Node: 40A701020010FF015130303237303832383130373539 2024-05-14 09:08:19.457 - Server: 40A80001000BFF02010204050C191A2241 2024-05-14 09:08:19.671 - Node: 40A801020008FF0200016E756C6C40A801020012FF020002513030323730383238313037353940A801020007FF020004312E3240A80102000BFF020005332E352E312E3340A801020005FF02000C3140A801020006FF020019313440A801020004FF02011A40A80102000EFF020022323430302D382D312D3040A801020004FF020141 2024-05-14 09:08:20.059 - Server: 40A90001000AFF04050311D30002314A 2024-05-14 09:08:20.574 - Node: 40A900010007FF04050382E150 2024-05-14 09:08:20.962 - Server: 40AA0001000AFF0405031195002D9143 2024-05-14 09:08:21.878 - Node: 40AA00010061FF0405035A0400A509F301FD073B011601640004000000A509F3015901A400080008000000000040080000010068106810E6001200F000E600F401120000000000F923D200A80C19002401020001000100020000001E00E6000200E6000E018A71 2024-05-14 09:08:22.267 - Server: 40AB0001000AFF04050311C20010E142 2024-05-14 09:08:22.881 - Node: 40AB00010027FF0405032024011601C80024013C0078001E00661502000D000D003D000000000005000100B60E

Paxy commented 6 months ago

That looks completely fine. The server is sending a requests to the inverter, and the inverter is responding back with the data. Also, MQTT shows as contected. Test accessing to MQTT from computer to see all MQTT topics with the command: mosquitto_sub -v -h <ip> -p <port> -t '#' -u <user> -P <pass>

Also, check your config.ini file where SmartESS-proxy.jar is located that you have set correct settings for enableMqttAuthm mqttUser and mqttPass.

AndrewT1000 commented 6 months ago

config.ini is the first thing that I check.

mosquitto_sub -v -h 192.168.40.11 -p 1883 -t '#' -u ##### -P ##### lxu401/connected online homeassistant/switch/Listwa_LXU401_relay_1/config {"dev":{"ids":["Listwa LXU401"],"name":"lxu401","sw":"1.17.457","mf":"Beken Corporation","mdl":"BK7231T","cu":"http://192.168.43.100/index"},"name":"1","~":"lxu401","avty_t":"~/connected","pl_on":"1","pl_off":"0","uniq_id":"Listwa_LXU401_relay_1","qos":1,"stat_t":"~/1/get","cmd_t":"~/1/set"} homeassistant/switch/Listwa_LXU401_relay_2/config {"dev":{"ids":["Listwa LXU401"],"name":"lxu401","sw":"1.17.457","mf":"Beken Corporation","mdl":"BK7231T","cu":"http://192.168.43.100/index"},"name":"2","~":"lxu401","avty_t":"~/connected","pl_on":"1","pl_off":"0","uniq_id":"Listwa_LXU401_relay_2","qos":1,"stat_t":"~/2/get","cmd_t":"~/2/set"} homeassistant/switch/Listwa_LXU401_relay_3/config {"dev":{"ids":["Listwa LXU401"],"name":"lxu401","sw":"1.17.457","mf":"Beken Corporation","mdl":"BK7231T","cu":"http://192.168.43.100/index"},"name":"3","~":"lxu401","avty_t":"~/connected","pl_on":"1","pl_off":"0","uniq_id":"Listwa_LXU401_relay_3","qos":1,"stat_t":"~/3/get","cmd_t":"~/3/set"} homeassistant/switch/Listwa_LXU401_relay_4/config {"dev":{"ids":["Listwa LXU401"],"name":"lxu401","sw":"1.17.457","mf":"Beken Corporation","mdl":"BK7231T","cu":"http://192.168.43.100/index"},"name":"4","~":"lxu401","avty_t":"~/connected","pl_on":"1","pl_off":"0","uniq_id":"Listwa_LXU401_relay_4","qos":1,"stat_t":"~/4/get","cmd_t":"~/4/set"} homeassistant/switch/Listwa_LXU401_relay_5/config {"dev":{"ids":["Listwa LXU401"],"name":"lxu401","sw":"1.17.457","mf":"Beken Corporation","mdl":"BK7231T","cu":"http://192.168.43.100/index"},"name":"5","~":"lxu401","avty_t":"~/connected","pl_on":"1","pl_off":"0","uniq_id":"Listwa_LXU401_relay_5","qos":1,"stat_t":"~/5/get","cmd_t":"~/5/set"} homeassistant/sensor/Listwa_LXU401_rssi/config {"dev":{"ids":["Listwa LXU401"],"name":"lxu401","sw":"1.17.457","mf":"Beken Corporation","mdl":"BK7231T","cu":"http://192.168.43.100/index"},"name":"RSSI","~":"lxu401","avty_t":"~/connected","uniq_id":"Listwa_LXU401_rssi","qos":1,"dev_cla":"signal_strength","stat_t":"~/rssi","unit_of_meas":"dBm"}

this is with running smartess_proxy! I have devices that work via MQTT without problems.

AndrewT1000 commented 6 months ago

Or maybe the reason is that I have a different inverter (Anern) and only the logger is supported? The data is forwarded but not decoded to MQTT. Should I look for the reason in ProcessInverterData.java?

Paxy commented 6 months ago

If you have time, try to troubleshoot ProcessInverterData.java, especially part of data parsing. It is likely that inverter have different data codes. This project was based on PowMr inverters data.

AndrewT1000 commented 6 months ago

And that's fine. Works with Anern inverter. I read the basic parameters correctly, but I still need to work on the additional ones.

Paxy commented 6 months ago

you can set service as man-in-the-middle service (without fake) and montior data changes while changing additional parameteres in ESS app. That can give you a clue what data means.

thematica commented 3 months ago

anyone got this working? the proxy works, fakeClient false also works, but no MQTT topic generated

thanks

AndrewT1000 commented 3 months ago

After the above conversation. I got the hang of it. the problem is that my inverter provided different data and the program stated that there was nothing to publish on MQTT. Now everything works fine, I added some code for energy calculation, which my inverter did not provide. I am working on Anern SCI02-pro

thematica commented 3 months ago

After the above conversation. I got the hang of it. the problem is that my inverter provided different data and the program stated that there was nothing to publish on MQTT. Now everything works fine, I added some code for energy calculation, which my inverter did not provide. I am working on Anern SCI02-pro

any tips for common folk like me? :) the last programming i use was VB6

ProcessInverterData.java -> based on Paxy comment above, i assume i need to debug this code?

AndrewT1000 commented 3 months ago

For me, it was enough to determine the offset of the appropriate data. There should be such data available for your hardware somewhere on the internet.

I have this:

public class ProcessInverterData implements Runnable {

    private Engine engine;
    private short modeIdx = 11;
    private short acVoltageIdx = 13;
    private short acFrequencyIdx = 15;
    private short pvVoltageIdx = 17;
    private short pvPowerIdx = 19;
    private short batteryVoltageIdx = 21;
    private short batteryChargedIdx = 23;
    private short batteryChargingCurrIdx = 25;
    private short batteryDisChargingCurrIdx = 27;
    private short outputVoltageIdx = 29;
    private short outputFrequencyIdx = 31;
    private short outputApparentPowerIdx = 33;
    private short outputPowerIdx = 35;
    private short outputLoadIdx = 37;
    private short chargeStateIdx=85;
    private short loadStateIdx=87;
    private short mainCpuVersionIdx=45;
    private short secondaryCpuVersionIdx=47; 

I also handled a few network and reconnect exceptions, but that may come later, these register addresses need to be determined first.

thematica commented 3 months ago

For me, it was enough to determine the offset of the appropriate data. There should be such data available for your hardware somewhere on the internet.

I have this:

public class ProcessInverterData implements Runnable {

  private Engine engine;
    private short modeIdx = 11;
    private short acVoltageIdx = 13;
    private short acFrequencyIdx = 15;
    private short pvVoltageIdx = 17;
    private short pvPowerIdx = 19;
    private short batteryVoltageIdx = 21;
    private short batteryChargedIdx = 23;
    private short batteryChargingCurrIdx = 25;
    private short batteryDisChargingCurrIdx = 27;
    private short outputVoltageIdx = 29;
    private short outputFrequencyIdx = 31;
    private short outputApparentPowerIdx = 33;
    private short outputPowerIdx = 35;
    private short outputLoadIdx = 37;
    private short chargeStateIdx=85;
    private short loadStateIdx=87;
    private short mainCpuVersionIdx=45;
    private short secondaryCpuVersionIdx=47; 

I also handled a few network and reconnect exceptions, but that may come later, these register addresses need to be determined first.

alright thank you very much and to Paxy too

i'll try setup Eclipse IDE first :)

thematica commented 3 months ago

i just debug a few times

here is my inverter data

1st loop always 130 bytes [44, 84, 1, 2, 0, 8, -1, 2, 0, 1, 110, 117, 108, 108, 44, 84, 1, 2, 0, 18, -1, 2, 0, 2, 81, 48, 48, 51, 49, 50, 55, 49, 50, 53, 48, 56, 57, 53, 44, 84, 1, 2, 0, 7, -1, 2, 0, 4, 49, 46, 50, 44, 84, 1, 2, 0, 11, -1, 2, 0, 5, 51, 46, 54, 46, 54, 46, 54, 44, 84, 1, 2, 0, 5, -1, 2, 0, 12, 49, 44, 84, 1, 2, 0, 6, -1, 2, 0, 25, 49, 57, 44, 84, 1, 2, 0, 4, -1, 2, 1, 26, 44, 84, 1, 2, 0, 14, -1, 2, 0, 34, 57, 54, 48, 48, 45, 56, 45, 49, 45, 48, 44, 84, 1, 2, 0, 4, -1, 2, 1, 65]

(another example) [93, -13, 1, 2, 0, 8, -1, 2, 0, 1, 110, 117, 108, 108, 93, -13, 1, 2, 0, 18, -1, 2, 0, 2, 81, 48, 48, 51, 49, 50, 55, 49, 50, 53, 48, 56, 57, 53, 93, -13, 1, 2, 0, 7, -1, 2, 0, 4, 49, 46, 50, 93, -13, 1, 2, 0, 11, -1, 2, 0, 5, 51, 46, 54, 46, 54, 46, 54, 93, -13, 1, 2, 0, 5, -1, 2, 0, 12, 49, 93, -13, 1, 2, 0, 6, -1, 2, 0, 25, 49, 57, 93, -13, 1, 2, 0, 4, -1, 2, 1, 26, 93, -13, 1, 2, 0, 14, -1, 2, 0, 34, 57, 54, 48, 48, 45, 56, 45, 49, 45, 48, 93, -13, 1, 2, 0, 4, -1, 2, 1, 65]

and the next loop always 22 bytes [18, -52, 1, 2, 0, 16, -1, 1, 81, 48, 48, 51, 49, 50, 55, 49, 50, 53, 48, 56, 57, 53] [105, 109, 1, 2, 0, 16, -1, 1, 81, 48, 48, 51, 49, 50, 55, 49, 50, 53, 48, 56, 57, 53] [105, -113, 1, 2, 0, 16, -1, 1, 81, 48, 48, 51, 49, 50, 55, 49, 50, 53, 48, 56, 57, 53]

*all data are randomly copy pasted, it didn't have any connection

the original line was like this : if (data[2] == 0x09 && data[3] == 0x25) {

so i just change the data[2] == 0x01 && data[3] == 0x02 -> this makes MQTT run but with wrong idx (i haven't lookup the values yet) but the 22 bytes are making error "array index out of bound", since your sample index are > 22 bytes

anyone can help me decode this "data" variable? did yours also different in bytes and how do you decode it?

Paxy commented 3 months ago

Although I can't directly help you decode the data you receive, I can tell you how I made sense of my interview data. First, I reverse-engineered the protocol data by using a Proxy (not a Fake client) that connects to the ESS cloud. That way, I could monitor the data that the inverter sends to the cloud and look for received values in the raw data. That helped me find every value position I needed to intercept and send over MQTT. When this part was done, Proxy worked by transferring data both to ESS cloud and MQTT server, I created FakeClient so I could generate "getData" request without ESS cloud. You can ether look on other GitHub projects for raw data structure, or do your own reverse-engineering for your inverter.

thematica commented 3 months ago

thanks for the pointers question though, does the data encrypted or in plain text?

Paxy commented 3 months ago

They are plain text, primitive variables (integers, booleans, ...).

thematica commented 3 months ago

alright thank you :) i'll see what i can do later this weekend