bradcagle / dbus-btbattery

20 stars 3 forks source link

Merge with dbus-serialbattery #7

Open mr-manuel opened 1 year ago

mr-manuel commented 1 year ago

Hi, nice driver! You want to help to develop the https://github.com/Louisvdw/dbus-serialbattery driver and merge the features of this driver, that our driver does not have?

With the latest beta our driver also supports JBD BMS via bluetooth connection.

I‘m looking forward to your answer :-)

bradcagle commented 1 year ago

Sure, we can combine our efforts. I need to learn how to use the Bluetooth library you're using :)

The virtual battery driver I have might be very simple to merge into your code.

Also I plan on adding SOC monitoring to trigger relays. For example when your battery is 100% SOC you might want to run other loads to use that excess PV, then when SOC is < maybe 98% you turn off these loads, etc..

If you guys are fine with me adding features like this we can work together. Thanks

mr-manuel commented 1 year ago

You can achieve such very simple by using Node-RED, that is running in the Venus OS large image. So it makes not much sense in my eyes to integrate it directly in the driver :-)

In our driver you can also specify to display/calculate the time to specific soc points. So you know when you reach e.g. 80%.

Could you try to install the latest beta and see, if there are features missing, that are in your driver?

bradcagle commented 1 year ago

I'll try your latest beta.

BTW are you having any Bluetooth lockup issues? I see you have some code to reset bluetooth.

I'm having this lockup issue (multiple times a day) since I started connecting to two batteries. With one battery it happen very rarely.

It locks the Bluetooth hardware, only a reboot will fix. So I have a watchdog looking at the timestamp of new data coming in. If the last timestamp is over 5min I reboot.

I tried your reset code today, but it would not fix the lockup.

mr-manuel commented 1 year ago

We had a problem every 15 hours and 20 minutes. It's the BlueZ driver for Linux in Venus OS. With Raspian there are no problems.

A reboot is a little bit hard. Try to kill only the Bluetooth driver and start it again:

pkill -f "bluetoothd"
/etc/init.d/bluetooth start
bradcagle commented 1 year ago

Yeah, I tried your reset code. But it did not fix. Only a reboot fixes the lockup I'm talking about

` def reset_bluetooth(self): logger.info("Reset of Bluetooth triggered") self.resetting = True

if self.jk.is_running():

    # self.jk.stop_scraping()
    logger.info("Scraping ended, issuing sys-commands")
    # process kill is needed, since the service/bluetooth driver is probably freezed
    os.system('pkill -f "bluetoothd"')
    # stop will not work, if service/bluetooth driver is stuck
    # os.system("/etc/init.d/bluetooth stop")
    time.sleep(2)
    os.system("rfkill block bluetooth")
    os.system("rfkill unblock bluetooth")
    os.system("/etc/init.d/bluetooth start")
    logger.info("Bluetooth should have been restarted")`
mr-manuel commented 1 year ago

Check https://github.com/Louisvdw/dbus-serialbattery/pull/499.

The JBD seems to work stable.

bradcagle commented 1 year ago

But have you tried connecting to two batteries? Because I did not get the lock until I connected to two batteries.

mr-manuel commented 1 year ago

I do not have JBD BMS therefore I have no answer to that. You can comment in the linked PR above and ask.