ai-republic / bms-to-inverter

Use, monitor and control any battery brand with any inverter! Application to read and monitor data from BMSes and write data to an inverter using any protocol (e.g. UART, RS485, ModBus or CAN)
https://github.com/ai-republic/bms-to-inverter
Other
32 stars 6 forks source link

Webserver module #10

Open sanitariu opened 4 months ago

sanitariu commented 4 months ago

I noticed a bug that after sometime 24 hours the webserver is working but do not refresh values like SoC and other correctly. Actually they stay as they were previous day. App seems to work no crash. I stop and start it and everything is displayed normal updated. If you need more info you can email me for live access.

ai-republic commented 4 months ago

Thanks Todor, I will have a look into this. Do you have a log file of the bms-to-inverter-main application? Has the MQTT server stopped?

sanitariu commented 4 months ago

I am sending the log files. It happened again. Can you check if it happens when UART crash ? If i restart webserver only it will start working good. logs.tar.gz

ai-republic commented 4 months ago

I can't find any errors in the logs. I suspect it could be a session timeout on the webserver. I will check that. If possible you could send me a console log of the browser. If you press F12 you usually get the developer console (at least on FF or Edge).

sanitariu commented 4 months ago

After 1 day it stops always. I tested second browser. Web console

[yoroi/prod] checking if should inject dapp-connector api inject.js:63:17 [yoroi/prod] injecting over 'nothing' inject.js:66:21 [yoroi/prod] dapp-connector is successfully injected into xx.xx.xx.xx

sanitariu commented 4 months ago

Webserver even shows wrong data although i have restarted it.

ai-republic commented 4 months ago

[yoroi/prod] checking if should inject dapp-connector api inject.js:63:17 [yoroi/prod] injecting over 'nothing' inject.js:66:21 [yoroi/prod] dapp-connector is successfully injected into xx.xx.xx.xx

This is nothing from my application. I suspect its a timeout in the webserver. I haven't had time to look into it yet. Can you give me more detailed information on what wrong data it displays after restart?

sanitariu commented 4 months ago

It is displaying old information from yesterday for example ...

ai-republic commented 4 months ago

Ok, that would mean that the BMS reading has stopped or the MQTT server. I believe I saw that the BMS reading was still running, so maybe its a timeout or validity of the MQTT topic on the MQTT server. Thanks, that's a possibility to look into.

sanitariu commented 4 months ago

For last hours seems like webserver is working. Lets see one more day and if it still refreshes it means problem is fixed.

ai-republic commented 4 months ago

yes. I've also been keeping an eye on it :)

sanitariu commented 4 months ago

After testing 1 day ... seems like webserver is not stable and stops refreshing the information for some reason. No crashes or anything just stop. After restart it works again. Maybe timeout or something like that. When you have time look at it.

ai-republic commented 3 months ago

@sanitariu I think I fixed the webserver issue due to a MQTT producer disconnect. I now try to reconncect if the message could not be sent.

sanitariu commented 3 months ago

Hi, I have downloaded latest release and this is what i have:

root@sol:~/bms # java -jar -DconfigFile=config/config.properties -Dlog4j2.configurationFile=file:config/log4j2.xml lib/bms-to-inverter-main-0.0.1-SNAPSHOT.jar 2024-03-21 10:08:13.145 | INFO | main | erter.core.util.Util:25 | Loading config.properties from: config/config.properties 2024-03-21 10:08:13.240 | INFO | main | ootstrap.WeldStartup:150 | WELD-000900: 5.1.1 (Final) 2024-03-21 10:08:13.810 | INFO | main | ionDiscoveryStrategy:52 | WELD-ENV-000014: Falling back to Java Reflection for bean-discovery-mode="annotated" discovery. Add org.jboss:jandex to the classpath to speed-up startup. 2024-03-21 10:08:13.867 | WARN | main | .environment.se.Weld:1015 | WELD-ENV-002008: Bean class module-info found in multiple bean archives - this may result in incorrect behavior:

ai-republic commented 3 months ago

The important lines are: 2024-03-21 10:08:17.891 | INFO | main | erter.core.util.Util:25 | Loading config.properties from: config/config.properties 2024-03-21 10:08:17.892 | ERROR | main | core.BMSListProducer:58 | No config.properties found or no BMSes are configured!

So there is no configuration file found in your installation folder under config/config.properties

sanitariu commented 3 months ago

Hi, There is the file @.:~/bms # pico config/config.properties @.:~/bms # ls -la config/config.properties -rw-r--r-- 1 sani sani 3150 Mar 21 10:14 config/config.properties @.***:~/bms #

I even run like this:

@.***:~/bms # java -DconfigFile=/root/bms/config/config.properties -Dlog4j2.configurationFile=file:config/log4j2.xml -jar lib/bms-to-inverter-main-0.0.1-SNAPSHOT.jar

@.***:~/bms # ls -la /root/bms/config/config.properties -rw-r--r-- 1 sani sani 3150 Mar 21 10:14 /root/bms/config/config.properties

###################################################################

System specific settings

###################################################################

###################################################################

BMS settings

###################################################################

Simple single port configuration

bms.x.type - can be (DALY_CAN, DALY_RS485, JK_CAN, PYLON_CAN or SEPLOS_CAN

bms.x.portLocator - is the locator/device to use to communicate to the BMS, eg. can0, /dev/ttyUSB0, com3, etc.

bms.x.pollIntervall - is the interval to request BMS data (in seconds)

bms.x.delayAfterNoBytes - is the delay after receiving no data (in ms)

bms.0.type=DALY_RS485 bms.0.portLocator=/dev/ttyAMA0 bms.0.pollInterval=5 bms.0.delayAfterNoBytes=200

###################################################################

Inverter settings

###################################################################

The inverter type can be NONE, DEYE_CAN, GROWATT_CAN, SMA_SI_CAN, SOLARK_CAN

inverter.type=NONE

The port name/device to use to communicate to the inverter

inverter.portLocator=/dev/can1

Interval to send data to the inverter (in seconds)

inverter.sendInterval=5

I tried to stop Webserver but not starting.

Best Regards, Todor

On 21 Mar 2024, at 10:31, Torsten Oltmanns @.***> wrote:

The important lines are: 2024-03-21 10:08:17.891 | INFO | main | erter.core.util.Util:25 | Loading config.properties from: config/config.properties 2024-03-21 10:08:17.892 | ERROR | main | core.BMSListProducer:58 | No config.properties found or no BMSes are configured!

So there is no configuration file found in your installation folder under config/config.properties

— Reply to this email directly, view it on GitHub https://github.com/ai-republic/bms-to-inverter/issues/10#issuecomment-2011630319, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACVA45GC5DM7MPHMEO7MQ23YZKLHRAVCNFSM6AAAAABCUVIQGOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJRGYZTAMZRHE. You are receiving this because you were mentioned.

sanitariu commented 3 months ago

I think i found the problem. config.properties should be like that:

bms.1.type=DALY_RS485 bms.1.id=1 bms.1.portLocator=/dev/ttyAMA0 bms.1.delayAfterNoBytes=200

sanitariu commented 3 months ago

I will run the webserver and we will know in some hours if it is ok. Also i have noted the following:

2024-03-21 11:28:34.274 | INFO | Thread-5 | verter.BmsToInverter:190 | Sending to inverter NONE on /dev/can1... 2024-03-21 11:28:34.277 | DEBUG | Thread-5 | verter.core.Inverter:79 | Inverter received: Buffer (HEX): [null]

Maybe we should not send anything to inverter if type is NONE ?

ai-republic commented 3 months ago

Hi Todor, yes, the numbering changed from starting from 0 to starting from 1. Also the poll interval is now general for all BMS because it makes no sense to differ between multiple BMSes.

The DummyInverter (NONE) is not actually sending or receiving anything. It also doesn't open a port. I added that for the automatic discovery, but yes, I could take the NONE and just not have any inverter thread and processor running. Thanks for pointing it out :)

sanitariu commented 3 months ago

I tested for 1 day and webserver stopped refreshing data. After restarting only the web module everything is okay. Strange that there is no errors or anything. I can not help you for debug

sanitariu commented 2 months ago

Do you have any clues for fixing this ? Also why not add some graph charts per day/hour so we can see the history ?

ai-republic commented 2 months ago

I think its related the number of posts for the MQTT Server on the queue. I have not had time to look into that.

Yeah, the history would be a great thing. Good idea! It'll need a database in the background and some new views. Let's see when I get around doing that :)

sanitariu commented 2 months ago

Also i noted that Web server is showing Discharge with -18A while the other console is showing +30A Charging which is the correct one and i see the same on my Growatt display. Maybe this is old data after it stucked ?!

ai-republic commented 1 month ago

Hi @sanitariu, I changed the MQTT handling and hope that the webserver will not loose connection to the MQTT broker