Paxy / SmartESS-proxy

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

MQTT issue #2

Closed skylax1 closed 1 year ago

skylax1 commented 1 year ago

Hey @Paxy, first of all - thank you for this project, it looks potentially really useful. I was able to make it work(partially) by wrapping it into docker image and putting in the same docker network as my Home Assistant and mosquitto containers. I've added local DNS record to my pihole, so now all traffic from PowMr is redirected to your app. I see packages in logs (Node: and Server: logs), so modbus stuff is working, and my SmartESS app is still showing data(I set fakeClient to false), so all good with that.

The only problem I can't figure out is how to make mqtt work. I configured MQTT integration in Home Assistant and tested it(started listening home/Inverter/ and then published test message to that topic), but I don't see any data coming from your app. Looks like your app is not sending any data to my mosquitto instance. Any hints what's wrong with my setup? I'm not really familiar with Java so maybe I messed up something.

I see that you mentioned org.eclipse.paho.client.mqtt library, do I need to install it separately? I assumed it would be included to your .jar during compilation.

Also I noticed that your MQTTClient.java file contains public class ModbusClient and judging by code it connects to port 502(which is modbus port) which doesn't look right. Maybe that's the problem?

Thanks

Paxy commented 1 year ago

Hi, I just looked at the MQTTClient.java and saw it was a wrong commit. Somehow, I committed to another class in this file. Check MQTTClient.java now.

skylax1 commented 1 year ago

any chance you can recompile it and put new .jar into bin/ directory?

Paxy commented 1 year ago

Actually, jar file was correct. That's the one I am currently using. It is tested to work correctly. Only difference is that I am using modified MQTT broker that does not require authentication. I need to test jat with authenticated MQTT later. Do you see in MQTT broker any messages about bad authentication?

skylax1 commented 1 year ago

nope, no MQTT errors visible, there is only 1 log message related to mqtt - 2023-07-15 09:16:06.077 - MQTT connected

I tried to disable auth on mosquitto(just to see if problem is with auth), here is my latest conf.ini file:

mqttServer=mosquitto
mqttPort=1883
enableMqttAuth=false
mqttUser=
mqttPass=
mqttTopic=home/Inverter/
updateFrequency=3

but it didn't help, still same issue - I don't see any data coming to MQTT

any ideas?

Is it normal that sendMsg method is commented out here: https://github.com/Paxy/SmartESS-proxy/blob/main/ModbusServer.java#L45

skylax1 commented 1 year ago

nevermind, I can see data now, I was trying to read it from home/Inverter/ topic, but actually each "type" of field is sent to a separate topics like home/Inverter/loadState, home/Inverter/chargeState, etc. I'm not very experienced with MQTT :)

Sorry for bothering, I'm closing this issue now.