Louisvdw / dbus-serialbattery

Battery Monitor driver for serial battery in VenusOS GX systems
MIT License
545 stars 149 forks source link

Add other use case (grid meter) or ignore devices - ANT BMS check missing #479

Closed seidler2547 closed 1 year ago

seidler2547 commented 1 year ago

I have a smart energy meter from my local power company that can be read through an IR interface. The IR interface I have has USB and is a simple USB to serial to IR converter. When I plug it into my MultiPlus GX, it is detected and the immediately "taken over" by dbus-serialbattery which thinks it's an ANT BMS. It would be nice to have the option to use the readout as Grid Meter or at least to ignore the device and let another process take over the reading of it. I am willing to work on this, but I don't know where in the code would be a good starting point for either option.

transistorgit commented 1 year ago

I have the same problem. Also, I already made my own SML smartmeter USB serial driver for venus. It works nicely, but on reboots it can come to hassles when serialbattery grabs the port before my driver.

transistorgit commented 1 year ago

just checked the code in ant.py. seems that there is no check at all if the returned data is valid. the driver gulps anything that comes in.... And as the Smart meter is just sending all the time, the ant driver takes this. For a proper solution, one must check the real ant bms output und look for some characteristic values to check for.

@seidler2547 for now, you can just comment out the ant bms in the utils.py, I did it also.

seidler2547 commented 1 year ago

@transistorgit thanks, I will do that. Have you published your driver for the SML smart meter? Mine in an MT175 and it only sends kWh in .1 Wh resolution as 1-0:1.8.0 and 1-0:1.8.1 and current draw in W as 1-0:16.7.0. That's probably not enough the the MultiPlus to use it as grid meter for 1-phase injection, but at least it's something.

transistorgit commented 1 year ago

Thats the same with mine. It's enough to let the Multiplus ESS regulate to zero grid consumption. Would be nice to get values more frequent, but it works. image Picture: my grid connection shows consumption over night and the PV system comes up around 08:00 and charges the battery. Around noon there is also some excess feed in. (not really sunny today)

I haven't published my driver yet, as I thought it may be too complicated with with this problem that you mentioned...but maybe I will do in some time.

If you are a programmer, you can implement a check in dbus-serialbattery.py in the get_battery() function that looks if the port is silent before sending commands. If there is a BMS connected the port should be silent, as they wait for commands. If there is a SML Gridmeter, the serial buffer would be always full. In this case the funtion should return false. This would solve this issue. @Louisvdw

seidler2547 commented 1 year ago

Nice. I am a software developer, yes. Just checked the code a little bit and it seems it wouldn't bee too much work to implement it. I might give it a shot. If anything, it's easier because no polling is needed, the SM sends the data by itself and we can just act on it. Which modbus/dbus path are you sending it to?

transistorgit commented 1 year ago

I set my repo to public. Feel free to examine or test it. But please be aware that is just a first try as I have very little time. It runs quite good, but stops occasionally and the auto-restart feature can't restart it automatically in all cases. This may be due to my sloppy usb active extender cable, but hadn't time to fix. https://github.com/transistorgit/dbus-gridmeter-sml

idstein commented 1 year ago

Same issue here with my MetCom MCS301 meter. My workaround was to utilise a wt32-eth01 with esphome. The actual trick to avoid customising the GX device is to implement a fairly simple Modbus TCP server on your meter IR reading device. It is well defined here https://github.com/victronenergy/dbus-modbus-client/blob/master/carlo_gavazzi.py how the interaction is implemented with the EM24 via TCP Modbus. Modbus TCP is queried every 250ms from VenusOS. SML / D0 with 9600 baudrate often only deliveries a 1s reading interval.

transistorgit commented 1 year ago

great, with disabling ANT this is fixed for me

mr-manuel commented 1 year ago

You can also specify only the BMS_TYPE that you are using in the config.ini so all others are ignored and it is update persistant.

transistorgit commented 1 year ago

yes, but not everybody nows it, and if somebody wants to use my SML smartmeter driver he may think it's broken...

mr-manuel commented 1 year ago

Someone has a ANT BMS or the protocol documentation, so that this can be fixed in the ANT BMS script?

seidler2547 commented 1 year ago

Then maybe ANT should be disabled by default until this is fixed?

mr-manuel commented 1 year ago

Then maybe ANT should be disabled by default until this is fixed?

Already done, if you scroll up a bit :-)

transistorgit commented 1 year ago

@Louisvdw this should be solved

mr-manuel commented 1 year ago

It‘s not solved, there is only a workaround, that I removed the ANT BMS by default. The definitive solution should be to add a check, if it‘s a ANT BMS.

mr-manuel commented 1 year ago

Who has an ANT BMS to test a fix?

mr-manuel commented 1 year ago

I added some verifications to the driver that check, if the data is valid or not. So things like in this issue https://github.com/Louisvdw/dbus-serialbattery/issues/418 cannot happen anymore.

Nerverthless the ANT BMS stay disabled by default, but can be enabled via config file with driver version >= v1.0.20230611beta.