-
-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
install BLE battery as local independent service #502
Conversation
I also changed the Serial "port" to use the BLE address, I guess that would be important to make multiple BLE BME work, althought I can't really test it. |
I have several jk bms to test. If you help me, I can test this on a fresh venusos Installation. |
Oh cool. That would be great. I guess testing two serial and two Bluetooth BMS would be ideal test case. I don't think it's difficult. Just do the normal install, then edit the |
To install you can execute: cd /tmp
wget https://github.com/seidler2547/dbus-serialbattery/archive/refs/heads/jkbms_ble.zip
unzip jkbms_ble.zip
mv /data/etc/dbus-serialbattery /data/etc/dbus-serialbattery_$(date +%Y%m%d_%H%M%S)
cp -rf /tmp/dbus-serialbattery-jkbms_ble/etc/dbus-serialbattery/ /data/etc
chmod +x /data/etc/dbus-serialbattery/*.sh
chmod +x /data/etc/dbus-serialbattery/*.py
chmod +x /data/etc/dbus-serialbattery/service/run
chmod +x /data/etc/dbus-serialbattery/service/log/run
bash /data/etc/dbus-serialbattery/installble.sh |
Thank you both!! How can i debug it? I don't see any new devices in the victron console. I found a process like this with alternating the mac adress from the BMS 1 + 2
do i have to pair the BMS with the rpi first? |
@mr-manuel Thank you, this helped a lot! Just this line
needs to be changed to cp -rf /tmp/dbus-serialbattery-jkbms_ble/etc/dbus-serialbattery/ /data/etc |
Oh, yes thats correct. Thanks! Forgot it to change, since I copied it from my repo. |
Ok, found the old thread: executed
which worked! But still no new device in venusos shows up.
Processes with old MAC-Adresses (from another BMS which i currently cannot pair). Still cannot see any new devices and no new logfile. |
etc/dbus-serialbattery/installble.sh
Outdated
|
||
## DO NOT TOUCH THIS ## | ||
install_service() { | ||
mkdir -p /service/dbus-blebattery-$1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about that, but is /service the correct folder for this? If i remember correctly in recent versions of venusos this is overwritten on every reboot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is correct. It's being recreated via /data/rc.local
@pos-ei-don I think you don't really need the individual steps. If you're installing it on a new system it should be installed more or less using the official install instructions, it's important that the reinstalllocal or installlocal script is run so that it will create the service properly.
So the last step needs to be |
@pos-ei-don this is only needed, if you are not using the default PIN of the JKBMS. |
@seidler2547 |
I did not change the default pin! What can I try next? |
The logs should be in |
I think I didn't pair, but I did |
The other option to debug is to remove the lines from the installable script and just start it manually on the command line. |
OK. Do I have to disable the BT Service in the console to "free" the Bluetooth Adapter for your Script? |
I'm not sure about that, since during the service creation (https://github.com/Louisvdw/dbus-serialbattery/blob/2a65d6c0fbcea030d52b6d0854a8b6536fa26900/etc/dbus-serialbattery/installble.sh) the creation for the log is missing. You should also add mkdir -p /service/dbus-blebattery-$1/log
echo "#!/bin/sh" > /service/dbus-blebattery-$1/log/run
echo "exec 2>&1" >> /service/dbus-blebattery-$1/log/run
echo "exec multilog t s25000 n4 /var/log/dbus-blebattery-$1" >> /service/dbus-blebattery-$1/log/run
chmod 755 /service/dbus-blebattery-$1/log/run and then reboot. |
The other option to debug is to remove the lines from the installable script and just start it manually on the command line.
It's advisable. Otherwise it reconnects a lot. |
I executed these lines! Thank you! The log just contains: so no big difference currently.
I now also trusted all 3. |
@mr-manuel great, thanks. I added the logging and added one more log message. @pos-ei-don the part with |
I found this in the processlist.
|
I get this when i run it manually.
Edit: I Updated to the version from 0a2adb2 |
Oh, yes, you'll have to run
These commands are also in |
@pos-ei-don although I'm not sure anymore if the
but I don't know if either |
was already installed.
worked.
After that, the device got created,
Do I get the "NameExistsException" because this device is also connected by 485RS? |
@pos-ei-don I think now you're getting this error because you're running it manually but it was already started automatically. |
Do you say the device is visible in the Victron GUI now? Then everything works as expected. You should not run the script manually anymore, the logs for the service are in |
THankl you!!
|
If you have two BMS you want to connect to using BLE you need to change the number after
(note that the second line has |
Yess!! I saw them when starting it manually! |
I had this!! |
The log is somehow "empty".
So currently I'd say it works with 1 JK-BMS, but not with two. |
Hmm okay, that's strange. But to be honest, it could be how the BLE stack or how python-bleak works or is used. Here I'm a bit out of my depth. But did you say when you have only one on autostart and start the other one manually it works? |
Is it really ... can't find anything obvious, but I might be missing something. |
Ah... all 3 exists. Here is the rest
|
Okay, then I have the strong suspicion that the culprit is the actual BLE code then. Maybe there's a fundamental change needed in how the service communicates with the device (i.e. releasing it every time to let other processes communicate with other BMSs). But I feel that's somehow out of scope for this PR. |
Ok, I just wanted to help testing. Feel free to contact me again if i can test anything or help further! |
Ah, but iI just want to add that the driver also stopped adding batteries connected by serial. See the log
For me its not a big deal, I only use the virtual mqtt-battery driver from @mr-manuel , so i don't need this! |
-misc was needed in my case; otherwise i got some weird errors and nothing worked. -modules is not necessary |
that is some weird behaviour... Only one battery is possible independent of attachment via ble or serial -> so it's possibly no problem with ble-code itself but some problem with concurrecy of multiple runs of dbus-serialbattery.py? But there were multiple instances of that script before when someone attached more than one serialdongle and that worked, didn't it? How did And why is the log almost completely empty? the first thing |
Did you ever run installlocal.sh ? Because if not then the serial part didn't get installed. |
Maybe not, it did all the steps i got to test this build. |
I just found out, that 2 BLE-Batteries work!!! Now it seems to work well if all Devices answer fast enough at boot time!! |
@pos-ei-don that's very good to know. I agree it would be a good thing to have the devices be always registered since we give it the BLE address. However, I recently checked the dbus messages on my system and I saw all the BLE messages printed there. So I have a suspicion that it might be possible to forego the use of python-bleak and use the built-in Bluetooth implementation by listening to dbus messages and decoding them accordingly. That would have the additional benefit of not needing to manually add the BLE addresses because they should just show up in the device scan. |
Only one device at the same time can be connected to a JKBMS. |
I understand. But it would be nice if the driver tries it again later, when I disconnect es the cellphone. I sum the values from these bms on a secondary venusos Installation in NodeRed and send those calculate values to you mqtt Aggregated battery device on the Main venusos. To get the correct sum of "maximum Charge current", I need to know all connected BMS. |
The ble driver prior this PR tries to connect over and over again. As soon as the ble device is ready it connects, Seems to behave different with this PR? The disconnection is not that easy. I noted also when I only restarted the driver, it did not connect anymore to the BMS, since somehow a connection is still open. I had to restart the driver and the bluetooth service. See https://github.com/mr-manuel/venus-os_dbus-serialbattery/blob/jkbms_ble/etc/dbus-serialbattery/restart-driver-and-ble.sh In general you should not have to change very often the settings. I haven't changed them for over a year. If you have to, you can
|
@mr-manuel that's why I put a disconnect statement in the service file. That works for me. @pos-ei-don I think the driver will retry. The logic isn't different to before: it tries to connect. If that doesn't work, it exits. Then, the service managr will restart the service and it'll try again. |
No description provided.