Skip to content

Commit

Permalink
Renamed scripts for better reading #532
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-manuel committed May 3, 2023
1 parent 9f1da97 commit 74b459a
Show file tree
Hide file tree
Showing 15 changed files with 122 additions and 81 deletions.
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
--exclude bms/battery_template.py \
--exclude bms/revov.py \
--exclude bms/test_max17853.py \
--exclude restartservice.sh \
etc/dbus-serialbattery/
- name: Release
Expand Down
11 changes: 6 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
* Added: Support for HLPdata BMS4S https://github.com/Louisvdw/dbus-serialbattery/pull/505 by @peterohman
* Added: Support for Seplos BMS https://github.com/Louisvdw/dbus-serialbattery/pull/530 by @wollew
* Added: Temperature name for temperature sensor 1 & 2. This allows to see which sensor is low and high (e.g. battery and cable) by @mr-manuel
* Changed: `reinstalllocal.sh` to recreate `/data/conf/serial-starter.d` if deleted by `disabledriver.sh` --> to check if the file `conf/serial-starter.d` could now be removed from the repository by @mr-manuel
* Changed: Added QML to `restoregui.sh` by @mr-manuel
* Changed: `reinstall-local.sh` to recreate `/data/conf/serial-starter.d`, if deleted by `disable.sh` --> to check if the file `conf/serial-starter.d` could now be removed from the repository by @mr-manuel
* Changed: Added QML to `restore-gui.sh` by @mr-manuel
* Changed: Bash output by @mr-manuel
* Changed: Default config file by @mr-manuel
* Added missing descriptions to make it much clearer to understand by @mr-manuel
Expand All @@ -57,13 +57,14 @@
* Changed: Fixed Time-To-Go is not working, if `TIME_TO_SOC_VALUE_TYPE` is set to other than `1` https://github.com/Louisvdw/dbus-serialbattery/pull/424#issuecomment-1440511018 by @mr-manuel
* Changed: Improved JBD BMS soc calculation https://github.com/Louisvdw/dbus-serialbattery/pull/439 by @aaronreek
* Changed: Logging to get relevant data by @mr-manuel
* Changed: Moved Bluetooth part to `reinstalllocal.sh` by @mr-manuel
* Changed: Moved Bluetooth part to `reinstall-local.sh` by @mr-manuel
* Changed: Moved BMS scripts to subfolder by @mr-manuel
* Changed: Optimized installation scripts by @mr-manuel
* Changed: Removed cell voltage penalty. Replaced by automatic voltage calculation. Max voltage is kept until cells are balanced and reset when cells are inbalanced by @mr-manuel
* Changed: Removed wildcard imports from several BMS drivers and fixed black lint errors by @mr-manuel
* Changed: Serial-Starter file is now created from `reinstalllocal.sh`. Fixes also https://github.com/Louisvdw/dbus-serialbattery/issues/520 by @mr-manuel
* Changed: Renamed scripts for better reading #532 by @mr-manuel
* Changed: Reworked and optimized installation scripts by @mr-manuel
* Changed: Separate Time-To-Go and Time-To-SoC activation by @mr-manuel
* Changed: Serial-Starter file is now created from `reinstall-local.sh`. Fixes also https://github.com/Louisvdw/dbus-serialbattery/issues/520 by @mr-manuel
* Changed: Temperature alarm changed in order to not trigger all in the same condition for JKBMS by @mr-manuel
* Changed: Time-To-Soc repetition from cycles to seconds. Minimum value is every 5 seconds. This prevents CPU overload and ensures system stability. Renamed `TIME_TO_SOC_LOOP_CYCLES` to `TIME_TO_SOC_RECALCULATE_EVERY` by @mr-manuel
* Changed: Time-To-Soc string from `days, HR:MN:SC` to `<days>d <hours>h <minutes>m <seconds>s` (same as Time-To-Go) by @mr-manuel
Expand Down
14 changes: 7 additions & 7 deletions docs/docs/general/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ In [VRM](https://vrm.victronenergy.com/) look under the device list for your ins
2. Run these commands to install or update to the latest release version.

```bash
wget -O /tmp/installrelease.sh https://raw.githubusercontent.com/Louisvdw/dbus-serialbattery/master/etc/dbus-serialbattery/installrelease.sh
wget -O /tmp/install-release.sh https://raw.githubusercontent.com/Louisvdw/dbus-serialbattery/master/etc/dbus-serialbattery/install-release.sh

bash /tmp/installrelease.sh
bash /tmp/install-release.sh

reboot
```
Expand Down Expand Up @@ -138,7 +138,7 @@ If you use the cell voltage limits, temperature limits or SoC limits you also ne

### Settings location/path

💡 After updating the settings reboot the device or run `/data/etc/dbus-serialbattery/reinstalllocal.sh` to apply the changes.
💡 After updating the settings reboot the device or run `/data/etc/dbus-serialbattery/reinstall-local.sh` to apply the changes.

#### Driver version `<= v0.14.3`
Edit `/data/etc/dbus-serialbattery/utils.py` to update the constants.
Expand Down Expand Up @@ -204,7 +204,7 @@ Edit `/data/etc/dbus-serialbattery/dbus-serialbattery.py` and uncommented (witho
You can disable the driver so that it will not be run by the GX device. To do that run the following command in SSH.

```bash
bash /data/etc/dbus-serialbattery/disabledriver.sh
bash /data/etc/dbus-serialbattery/disable.sh
```

You also need to configure your MPPTs to run in `Stand alone mode` again. Follow the Victron guide for [Err 67 - BMS Connection lost](https://www.victronenergy.com/live/mppt-error-codes#err_67_-_bms_connection_lost).
Expand All @@ -213,7 +213,7 @@ You also need to configure your MPPTs to run in `Stand alone mode` again. Follow
To enable the driver again you can run the installer.

```bash
bash /data/etc/dbus-serialbattery/reinstalllocal.sh
bash /data/etc/dbus-serialbattery/reinstall-local.sh
```

## Uninstall/remove the driver
Expand All @@ -236,11 +236,11 @@ rm -rf /opt/victronenergy/service/dbus-serialbattery
rm -rf /opt/victronenergy/service-templates/dbus-serialbattery
rm -rf /opt/victronenergy/dbus-serialbattery

# kill if running
# kill driver, if running
pkill -f "python .*/dbus-serialbattery.py"

# remove install-script from rc.local
sed -i "/sh \/data\/etc\/dbus-serialbattery\/reinstalllocal.sh/d" /data/rc.local
sed -i "/sh \/data\/etc\/dbus-serialbattery\/reinstall-local.sh/d" /data/rc.local
```

> If after the uninstall for some reason several items in the GUI were red, DO NOT reboot your GX device. See [Uninstalling driver bricked my cerbo #576](https://github.com/Louisvdw/dbus-serialbattery/issues/576)
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ sh /opt/victronenergy/swupdate-scripts/remount-rw.sh
rm -f /data/conf/serial-starter.d/$DRIVERNAME.conf
rm -rf /service/dbus-blebattery.*

# kill if running
# kill driver, if running. It gets restarted by the service daemon
pkill -f "python .*/$DRIVERNAME.py"

# remove install-script from rc.local
sed -i "/sh \/data\/etc\/$DRIVERNAME\/reinstalllocal.sh/d" /data/rc.local

# remove install script from rc.local
sed -i "/sh \/data\/etc\/$DRIVERNAME\/reinstall-local.sh/d" /data/rc.local


### temporary
### needed for upgrading from older versions | start ###
# remove old drivers before changing from dbus-blebattery-$1 to dbus-blebattery.$1
# can be removed on second release (>1.0.0)
rm -rf /service/dbus-blebattery-*

# can be removed on second release (>1.0.0)
sed -i "/sh \/data\/etc\/$DRIVERNAME\/installble.sh/d" /data/rc.local
# remove old install script from rc.local
sed -i "/sh \/data\/etc\/$DRIVERNAME\/reinstalllocal.sh/d" /data/rc.local
# remove old entry from rc.local
sed -i "/sh \/data\/etc\/dbus-serialbattery\/installble.sh/d" /data/rc.local
### needed for upgrading from older versions | end ###
23 changes: 23 additions & 0 deletions etc/dbus-serialbattery/install-local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh

# remove comment for easier troubleshooting
#set -x

# backup config.ini
if [ -f "/data/etc/dbus-serialbattery/config.ini" ]; then
mv /data/etc/dbus-serialbattery/config.ini /data/etc/config.ini
fi

# remove old driver
rm -rf /data/etc/dbus-serialbattery

# extract driver
tar -zxf ./venus-data.tar.gz -C /data

# restore config.ini
if [ -f "/data/etc/config.ini" ]; then
mv /data/etc/config.ini /data/etc/dbus-serialbattery/config.ini
fi

# install driver
sh /data/etc/dbus-serialbattery/reinstall-local.sh
2 changes: 1 addition & 1 deletion etc/dbus-serialbattery/install-nightly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ chmod +x /data/etc/dbus-serialbattery/service/run
chmod +x /data/etc/dbus-serialbattery/service/log/run

# run install script
bash /data/etc/dbus-serialbattery/reinstalllocal.sh
bash /data/etc/dbus-serialbattery/reinstall-local.sh
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
curl -s https://api.github.com/repos/Louisvdw/dbus-serialbattery/releases/latest | grep "browser_download_url.*gz" | cut -d : -f 2,3 | tr -d \" | wget -O venus-data.tar.gz -qi -

# extract and install driver
sh /data/etc/dbus-serialbattery/installlocal.sh
sh /data/etc/dbus-serialbattery/install-local.sh
10 changes: 0 additions & 10 deletions etc/dbus-serialbattery/installlocal.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ mkdir /opt/victronenergy/$DRIVERNAME/bms
cp -f /data/etc/$DRIVERNAME/* /opt/victronenergy/$DRIVERNAME &>/dev/null
cp -f /data/etc/$DRIVERNAME/bms/* /opt/victronenergy/$DRIVERNAME/bms &>/dev/null
cp -rf /data/etc/$DRIVERNAME/service /opt/victronenergy/service-templates/$DRIVERNAME
sh /data/etc/$DRIVERNAME/installqml.sh
sh /data/etc/$DRIVERNAME/install-qml.sh

# check if serial-starter.d was deleted
serialstarter_path="/data/conf/serial-starter.d"
serialstarter_file="$serialstarter_path/dbus-serialbattery.conf"

# check if folder is a file (older versions of this driver)
# check if folder is a file (older versions of this driver < v1.0.0)
if [ -f $serialstarter_path ]; then
rm -f $serialstarter_path
fi
Expand All @@ -40,16 +40,13 @@ if [ ! -f $serialstarter_file ]; then
echo "alias rs485 cgwacs:fzsonick:imt:modbus:sbattery" >> $serialstarter_file
fi

# restart if running
pkill -f "python .*/$DRIVERNAME.py"

# add install-script to rc.local to be ready for firmware update
filename=/data/rc.local
if [ ! -f $filename ]; then
echo "#!/bin/bash" >> $filename
chmod 755 $filename
fi
grep -qxF "sh /data/etc/$DRIVERNAME/reinstalllocal.sh" $filename || echo "sh /data/etc/$DRIVERNAME/reinstalllocal.sh" >> $filename
grep -qxF "sh /data/etc/$DRIVERNAME/reinstall-local.sh" $filename || echo "sh /data/etc/$DRIVERNAME/reinstall-local.sh" >> $filename

# add empty config.ini, if it does not exist to make it easier for users to add custom settings
filename=/data/etc/$DRIVERNAME/config.ini
Expand All @@ -58,6 +55,7 @@ if [ ! -f $filename ]; then
echo "" >> $filename
echo "; If you want to add custom settings, then check the settings you want to change in \"config.default.ini\"" >> $filename
echo "; and add them below to persist future driver updates." >> $filename
echo "" >> $filename
fi


Expand All @@ -80,6 +78,8 @@ IFS="," read -r -a bms_array <<< "$bluetooth_bms_clean"
length=${#bms_array[@]}
# echo $length

# always remove existing blebattery services to cleanup
rm -rf /service/dbus-blebattery.*

if [ $length -gt 0 ]; then

Expand All @@ -96,19 +96,6 @@ if [ $length -gt 0 ]; then
# setup cronjob to restart Bluetooth
grep -qxF "5 0,12 * * * /etc/init.d/bluetooth restart" /var/spool/cron/root || echo "5 0,12 * * * /etc/init.d/bluetooth restart" >> /var/spool/cron/root


### temporary | start
# can be removed on second release (>1.0.0)
# remove old drivers before changing from dbus-blebattery-$1 to dbus-blebattery.$1
rm -rf /service/dbus-blebattery-*
# remove old entry from rc.local
sed -i "/sh \/data\/etc\/$DRIVERNAME\/installble.sh/d" /data/rc.local
### temporary | end


# remove existing driver to cleanup
rm -rf /service/dbus-blebattery.*

# function to install ble battery
install_blebattery_service() {
mkdir -p /service/dbus-blebattery.$1/log
Expand All @@ -126,8 +113,8 @@ if [ $length -gt 0 ]; then
echo "Packages installed."
echo ""

# install_blebattery_service 0 Jkbms_Ble C8:47:8C:12:34:56
# install_blebattery_service 1 Jkbms_Ble C8:47:8C:78:9A:BC
# install_blebattery_service 0 Jkbms_Ble C8:47:8C:00:00:00
# install_blebattery_service 1 Jkbms_Ble C8:47:8C:00:00:11

for (( i=0; i<${length}; i++ ));
do
Expand All @@ -136,12 +123,36 @@ if [ $length -gt 0 ]; then
done

else

# remove cronjob
sed -i "/5 0,12 \* \* \* \/etc\/init.d\/bluetooth restart/d" /var/spool/cron/root

echo "No Bluetooth battery configuration found in \"/data/etc/dbus-serialbattery/config.ini\"."
echo "You can ignore this, if you are using only a serial connection."

fi
### BLUETOOTH PART | END ###


### needed for upgrading from older versions | start ###
# remove old drivers before changing from dbus-blebattery-$1 to dbus-blebattery.$1
rm -rf /service/dbus-blebattery-*
# remove old install script from rc.local
sed -i "/sh \/data\/etc\/$DRIVERNAME\/reinstalllocal.sh/d" /data/rc.local
# remove old entry from rc.local
sed -i "/sh \/data\/etc\/dbus-serialbattery\/installble.sh/d" /data/rc.local
### needed for upgrading from older versions | end ###


# kill driver, if running. It gets restarted by the service daemon
pkill -f "python .*/$DRIVERNAME.py"

# restart bluetooth service, if Bluetooth BMS configured
if [ $length -gt 0 ]; then
/etc/init.d/bluetooth restart
fi


# install notes
echo
echo
Expand All @@ -156,7 +167,7 @@ echo " If your Bluetooth BMS are nearby you can show the MAC address with
echo
echo " 2. Make sure to disable Settings -> Bluetooth in the remote console/GUI to prevent reconnects every minute."
echo
echo " 3. Re-run \"/data/etc/dbus-serialbattery/reinstalllocal.sh\", if the Bluetooth BMS were not added to the \"config.ini\" before."
echo " 3. Re-run \"/data/etc/dbus-serialbattery/reinstall-local.sh\", if the Bluetooth BMS were not added to the \"config.ini\" before."
echo
echo " ATTENTION!"
echo " If you changed the default connection PIN of your BMS, then you have to pair the BMS first using OS tools like the \"bluetoothctl\"."
Expand Down
10 changes: 0 additions & 10 deletions etc/dbus-serialbattery/restart-driver-and-ble.sh

This file was deleted.

27 changes: 27 additions & 0 deletions etc/dbus-serialbattery/restart-driver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# remove comment for easier troubleshooting
#set -x

# copy config.ini in case it was changed
cp -f /data/etc/dbus-serialbattery/config.ini /opt/victronenergy/dbus-serialbattery/config.ini

# would not restart ble services
# svc -d -u /service/dbus-serialbattery

# kill driver, if running. It gets restarted by the service daemon
pkill -f "python .*/$DRIVERNAME.py"


# get BMS list from config file
bluetooth_bms=$(awk -F "=" '/BLUETOOTH_BMS/ {print $2}' /data/etc/dbus-serialbattery/config.ini)
# clear whitespaces
bluetooth_bms_clean="$(echo $bluetooth_bms | sed 's/\s*,\s*/,/g')"
# split into array
IFS="," read -r -a bms_array <<< "$bluetooth_bms_clean"
length=${#bms_array[@]}

# restart bluetooth service, if Bluetooth BMS configured
if [ $length -gt 0 ]; then
/etc/init.d/bluetooth restart
fi
6 changes: 0 additions & 6 deletions etc/dbus-serialbattery/restartservice.sh

This file was deleted.

File renamed without changes.
24 changes: 15 additions & 9 deletions etc/dbus-serialbattery/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,26 @@ rm -rf /opt/victronenergy/service-templates/dbus-serialbattery
rm -rf /opt/victronenergy/dbus-serialbattery
rm -rf /service/dbus-blebattery.*

# remove old drivers before changing from dbus-blebattery-$1 to dbus-blebattery.$1
# can be removed on second release (>1.0.0)
rm -rf /service/dbus-blebattery-*

# kill if running
pkill -f "python .*/dbus-serialbattery.py"

# remove install-script from rc.local
sed -i "/sh \/data\/etc\/dbus-serialbattery\/reinstalllocal.sh/d" /data/rc.local
sed -i "/sh \/data\/etc\/dbus-serialbattery\/installble.sh/d" /data/rc.local
sed -i "/sh \/data\/etc\/dbus-serialbattery\/reinstall-local.sh/d" /data/rc.local

# remove cronjob
sed -i "/5 0,12 \* \* \* \/etc\/init.d\/bluetooth restart/d" /var/spool/cron/root


### needed for upgrading from older versions | start ###
# remove old drivers before changing from dbus-blebattery-$1 to dbus-blebattery.$1
rm -rf /service/dbus-blebattery-*
# remove old install script from rc.local
sed -i "/sh \/data\/etc\/$DRIVERNAME\/reinstalllocal.sh/d" /data/rc.local
# remove old entry from rc.local
sed -i "/sh \/data\/etc\/dbus-serialbattery\/installble.sh/d" /data/rc.local
### needed for upgrading from older versions | end ###


# kill driver, if running
pkill -f "python .*/dbus-serialbattery.py"

# uninstall modules
read -r -p "Do you also want to uninstall bleak, python3-pip and python3-modules? If you don't know select y. [Y/n] " response
echo
Expand Down

0 comments on commit 74b459a

Please sign in to comment.