Skip to content

Commit

Permalink
Added GUIv2 to the installation process
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-manuel committed Oct 31, 2024
1 parent 4c38d2a commit 66488d8
Show file tree
Hide file tree
Showing 15 changed files with 1,891 additions and 211 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@

## v1.5.x
* Added: Daly BMS - Connect multiple BMS to the same RS485 port by @CaptKrisp
* Added: GUIv2 by @mr-manuel
* Added: Possibility to change the CAN bus speed by @mr-manuel
* Added: Threshold, if `CCL = 0` or `DCL = 0` is reached to prevent flapping @mr-manuel
* Changed: Calculate Time-to-Go until ESS -> Minimum SOC (unless grid fails), Active SOC limit or `SOC_LOW_WARNING` from `config.ini` by @mr-manuel
Expand Down
273 changes: 200 additions & 73 deletions etc/dbus-serialbattery/install-qml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,93 +32,220 @@ function versionStringToNumber ()
fi
}

# backup old PageBattery.qml once. New firmware upgrade will remove the backup
if [ ! -f /opt/victronenergy/gui/qml/PageBattery.qml.backup ]; then
cp /opt/victronenergy/gui/qml/PageBattery.qml /opt/victronenergy/gui/qml/PageBattery.qml.backup
fi
# backup old PageBatteryParameters.qml once. New firmware upgrade will remove the backup
if [ ! -f /opt/victronenergy/gui/qml/PageBatteryParameters.qml.backup ]; then
cp /opt/victronenergy/gui/qml/PageBatteryParameters.qml /opt/victronenergy/gui/qml/PageBatteryParameters.qml.backup
fi
# backup old PageBatterySettings.qml once. New firmware upgrade will remove the backup
if [ ! -f /opt/victronenergy/gui/qml/PageBatterySettings.qml.backup ]; then
cp /opt/victronenergy/gui/qml/PageBatterySettings.qml /opt/victronenergy/gui/qml/PageBatterySettings.qml.backup
fi
# backup old PageLynxIonIo.qml once. New firmware upgrade will remove the backup
if [ ! -f /opt/victronenergy/gui/qml/PageLynxIonIo.qml.backup ]; then
cp /opt/victronenergy/gui/qml/PageLynxIonIo.qml /opt/victronenergy/gui/qml/PageLynxIonIo.qml.backup
fi

# count changed files
filesChanged=0

# copy new PageBattery.qml if changed
if ! cmp -s /data/etc/dbus-serialbattery/qml/PageBattery.qml /opt/victronenergy/gui/qml/PageBattery.qml
then
cp /data/etc/dbus-serialbattery/qml/PageBattery.qml /opt/victronenergy/gui/qml/
((filesChanged++))
fi

# copy new PageBatteryCellVoltages if changed
if ! cmp -s /data/etc/dbus-serialbattery/qml/PageBatteryCellVoltages.qml /opt/victronenergy/gui/qml/PageBatteryCellVoltages.qml
then
cp /data/etc/dbus-serialbattery/qml/PageBatteryCellVoltages.qml /opt/victronenergy/gui/qml/
((filesChanged++))
fi
# GUI V1
if [ -d /opt/victronenergy/gui ]; then

# copy new PageBatteryParameters.qml if changed
if ! cmp -s /data/etc/dbus-serialbattery/qml/PageBatteryParameters.qml /opt/victronenergy/gui/qml/PageBatteryParameters.qml
then
cp /data/etc/dbus-serialbattery/qml/PageBatteryParameters.qml /opt/victronenergy/gui/qml/
((filesChanged++))
fi
echo ""
echo "Installing QML files for GUI V1..."

# copy new PageBatterySettings.qml if changed
if ! cmp -s /data/etc/dbus-serialbattery/qml/PageBatterySettings.qml /opt/victronenergy/gui/qml/PageBatterySettings.qml
then
cp /data/etc/dbus-serialbattery/qml/PageBatterySettings.qml /opt/victronenergy/gui/qml/
((filesChanged++))
fi
# backup old PageBattery.qml once. New firmware upgrade will remove the backup
if [ ! -f /opt/victronenergy/gui/qml/PageBattery.qml.backup ]; then
cp /opt/victronenergy/gui/qml/PageBattery.qml /opt/victronenergy/gui/qml/PageBattery.qml.backup
fi
# backup old PageBatteryParameters.qml once. New firmware upgrade will remove the backup
if [ ! -f /opt/victronenergy/gui/qml/PageBatteryParameters.qml.backup ]; then
cp /opt/victronenergy/gui/qml/PageBatteryParameters.qml /opt/victronenergy/gui/qml/PageBatteryParameters.qml.backup
fi
# backup old PageBatterySettings.qml once. New firmware upgrade will remove the backup
if [ ! -f /opt/victronenergy/gui/qml/PageBatterySettings.qml.backup ]; then
cp /opt/victronenergy/gui/qml/PageBatterySettings.qml /opt/victronenergy/gui/qml/PageBatterySettings.qml.backup
fi
# backup old PageLynxIonIo.qml once. New firmware upgrade will remove the backup
if [ ! -f /opt/victronenergy/gui/qml/PageLynxIonIo.qml.backup ]; then
cp /opt/victronenergy/gui/qml/PageLynxIonIo.qml /opt/victronenergy/gui/qml/PageLynxIonIo.qml.backup
fi

# copy new PageBatterySetup if changed
if ! cmp -s /data/etc/dbus-serialbattery/qml/PageBatterySetup.qml /opt/victronenergy/gui/qml/PageBatterySetup.qml
then
cp /data/etc/dbus-serialbattery/qml/PageBatterySetup.qml /opt/victronenergy/gui/qml/
((filesChanged++))
fi
# copy new PageBattery.qml if changed
if ! cmp -s /data/etc/dbus-serialbattery/qml/gui-v1/PageBattery.qml /opt/victronenergy/gui/qml/PageBattery.qml
then
cp /data/etc/dbus-serialbattery/qml/gui-v1/PageBattery.qml /opt/victronenergy/gui/qml/
((filesChanged++))
fi

# copy new PageBatteryCellVoltages if changed
if ! cmp -s /data/etc/dbus-serialbattery/qml/gui-v1/PageBatteryCellVoltages.qml /opt/victronenergy/gui/qml/PageBatteryCellVoltages.qml
then
cp /data/etc/dbus-serialbattery/qml/gui-v1/PageBatteryCellVoltages.qml /opt/victronenergy/gui/qml/
((filesChanged++))
fi

# copy new PageBatteryParameters.qml if changed
if ! cmp -s /data/etc/dbus-serialbattery/qml/gui-v1/PageBatteryParameters.qml /opt/victronenergy/gui/qml/PageBatteryParameters.qml
then
cp /data/etc/dbus-serialbattery/qml/gui-v1/PageBatteryParameters.qml /opt/victronenergy/gui/qml/
((filesChanged++))
fi

# copy new PageBatterySettings.qml if changed
if ! cmp -s /data/etc/dbus-serialbattery/qml/gui-v1/PageBatterySettings.qml /opt/victronenergy/gui/qml/PageBatterySettings.qml
then
cp /data/etc/dbus-serialbattery/qml/gui-v1/PageBatterySettings.qml /opt/victronenergy/gui/qml/
((filesChanged++))
fi

# copy new PageLynxIonIo.qml if changed
if ! cmp -s /data/etc/dbus-serialbattery/qml/gui-v1/PageLynxIonIo.qml /opt/victronenergy/gui/qml/PageLynxIonIo.qml
then
cp /data/etc/dbus-serialbattery/qml/gui-v1/PageLynxIonIo.qml /opt/victronenergy/gui/qml/
((filesChanged++))
fi


# get current Venus OS version
versionStringToNumber $(head -n 1 /opt/victronenergy/version)
((venusVersionNumber = $versionNumber))

# revert to VisualItemModel, if Venus OS older than v3.00~14 (v3.00~14 uses VisibleItemModel)
versionStringToNumber "v3.00~14"

# change in Victron directory, else the files are "broken" if upgrading from v2 to v3
qmlDir="/opt/victronenergy/gui/qml"

if (( $venusVersionNumber < $versionNumber )); then
echo -n "Venus OS $(head -n 1 /opt/victronenergy/version) is older than v3.00~14. Replacing VisibleItemModel with VisualItemModel... "
fileList="$qmlDir/PageBattery.qml"
fileList+=" $qmlDir/PageBatteryCellVoltages.qml"
fileList+=" $qmlDir/PageBatteryParameters.qml"
fileList+=" $qmlDir/PageBatterySettings.qml"
fileList+=" $qmlDir/PageBatterySetup.qml"
fileList+=" $qmlDir/PageLynxIonIo.qml"
for file in $fileList ; do
sed -i -e 's/VisibleItemModel/VisualItemModel/' "$file"
done
echo "done."
fi

# copy new PageLynxIonIo.qml if changed
if ! cmp -s /data/etc/dbus-serialbattery/qml/PageLynxIonIo.qml /opt/victronenergy/gui/qml/PageLynxIonIo.qml
then
cp /data/etc/dbus-serialbattery/qml/PageLynxIonIo.qml /opt/victronenergy/gui/qml/
((filesChanged++))
fi


# get current Venus OS version
versionStringToNumber $(head -n 1 /opt/victronenergy/version)
((venusVersionNumber = $versionNumber))

# revert to VisualItemModel, if Venus OS older than v3.00~14 (v3.00~14 uses VisibleItemModel)
versionStringToNumber "v3.00~14"

# change in Victron directory, else the files are "broken" if upgrading from v2 to v3
qmlDir="/opt/victronenergy/gui/qml"

if (( $venusVersionNumber < $versionNumber )); then
echo -n "Venus OS $(head -n 1 /opt/victronenergy/version) is older than v3.00~14. Replacing VisibleItemModel with VisualItemModel... "
fileList="$qmlDir/PageBattery.qml"
fileList+=" $qmlDir/PageBatteryCellVoltages.qml"
fileList+=" $qmlDir/PageBatteryParameters.qml"
fileList+=" $qmlDir/PageBatterySettings.qml"
fileList+=" $qmlDir/PageBatterySetup.qml"
fileList+=" $qmlDir/PageLynxIonIo.qml"
for file in $fileList ; do
sed -i -e 's/VisibleItemModel/VisualItemModel/' "$file"
done
echo "done."
# GUI V2
if [ -d /opt/victronenergy/gui-v2 ]; then

# COPY QML FILES for device screen
echo ""
echo "Installing QML files for GUI V2..."

# backup old PageBattery.qml once. New firmware upgrade will remove the backup
if [ ! -f /opt/victronenergy/gui-v2/Victron/VenusOS/pages/settings/devicelist/battery/PageBattery.qml.backup ]; then
cp /opt/victronenergy/gui-v2/Victron/VenusOS/pages/settings/devicelist/battery/PageBattery.qml /opt/victronenergy/gui-v2/Victron/VenusOS/pages/settings/devicelist/battery/PageBattery.qml.backup
fi
# backup old PageBatteryParameters.qml once. New firmware upgrade will remove the backup
if [ ! -f /opt/victronenergy/gui-v2/Victron/VenusOS/pages/settings/devicelist/battery/PageBatteryParameters.qml.backup ]; then
cp /opt/victronenergy/gui-v2/Victron/VenusOS/pages/settings/devicelist/battery/PageBatteryParameters.qml /opt/victronenergy/gui-v2/Victron/VenusOS/pages/settings/devicelist/battery/PageBatteryParameters.qml.backup
fi
# backup old PageBatterySettings.qml once. New firmware upgrade will remove the backup
if [ ! -f /opt/victronenergy/gui-v2/Victron/VenusOS/pages/settings/devicelist/battery/PageBatterySettings.qml.backup ]; then
cp /opt/victronenergy/gui-v2/Victron/VenusOS/pages/settings/devicelist/battery/PageBatterySettings.qml /opt/victronenergy/gui-v2/Victron/VenusOS/pages/settings/devicelist/battery/PageBatterySettings.qml.backup
fi
# backup old PageLynxIonIo.qml once. New firmware upgrade will remove the backup
if [ ! -f /opt/victronenergy/gui-v2/Victron/VenusOS/pages/settings/devicelist/battery/PageLynxIonIo.qml.backup ]; then
cp /opt/victronenergy/gui-v2/Victron/VenusOS/pages/settings/devicelist/battery/PageLynxIonIo.qml /opt/victronenergy/gui-v2/Victron/VenusOS/pages/settings/devicelist/battery/PageLynxIonIo.qml.backup
fi

# copy new PageBattery.qml if changed
if ! cmp -s /data/etc/dbus-serialbattery/qml/gui-v2/PageBattery.qml /opt/victronenergy/gui-v2/Victron/VenusOS/pages/settings/devicelist/battery/PageBattery.qml
then
cp /data/etc/dbus-serialbattery/qml/gui-v2/PageBattery.qml /opt/victronenergy/gui-v2/Victron/VenusOS/pages/settings/devicelist/battery/
((filesChanged++))
fi

# copy new PageBatteryCellVoltages if changed
if ! cmp -s /data/etc/dbus-serialbattery/qml/gui-v2/PageBatteryCellVoltages.qml /opt/victronenergy/gui-v2/Victron/VenusOS/pages/settings/devicelist/PageBatteryCellVoltages.qml
then
cp /data/etc/dbus-serialbattery/qml/gui-v2/PageBatteryCellVoltages.qml /opt/victronenergy/gui-v2/Victron/VenusOS/pages/settings/devicelist/
((filesChanged++))
fi

# copy new PageBatteryParameters.qml if changed
if ! cmp -s /data/etc/dbus-serialbattery/qml/gui-v2/PageBatteryParameters.qml /opt/victronenergy/gui-v2/Victron/VenusOS/pages/settings/devicelist/PageBatteryParameters.qml
then
cp /data/etc/dbus-serialbattery/qml/gui-v2/PageBatteryParameters.qml /opt/victronenergy/gui-v2/Victron/VenusOS/pages/settings/devicelist/
((filesChanged++))
fi

# copy new PageBatterySettings.qml if changed
if ! cmp -s /data/etc/dbus-serialbattery/qml/gui-v2/PageBatterySettings.qml /opt/victronenergy/gui-v2/Victron/VenusOS/pages/settings/devicelist/PageBatterySettings.qml
then
cp /data/etc/dbus-serialbattery/qml/gui-v2/PageBatterySettings.qml /opt/victronenergy/gui-v2/Victron/VenusOS/pages/settings/devicelist/
((filesChanged++))
fi

# copy new PageLynxIonIo.qml if changed
if ! cmp -s /data/etc/dbus-serialbattery/qml/gui-v2/PageLynxIonIo.qml /opt/victronenergy/gui-v2/Victron/VenusOS/pages/settings/devicelist/PageLynxIonIo.qml
then
cp /data/etc/dbus-serialbattery/qml/gui-v2/PageLynxIonIo.qml /opt/victronenergy/gui-v2/Victron/VenusOS/pages/settings/devicelist/
((filesChanged++))
fi


# DOWNLOAD AND INSTALL WASM BUILD
if [ -f "/var/www/venus/gui-v2/commit-sha" ]; then
# check if latest version is already installed
hash_local=$(cat /var/www/venus/gui-v2/commit-sha)
hash_online=$(curl -s https://api.github.com/repos/mr-manuel/venus-os_dbus-serialbattery_gui-v2/commits?path=venus-webassembly.zip | grep "sha" | head -n 1 | cut -d : -f 2,3 | tr -d "\ " | tr -d \" | tr -d \,)

if [ "$hash_local" != "$hash_online" ]; then
install_wasm=1
else
install_wasm=0
fi
else
install_wasm=1
fi

if [ $install_wasm -eq 1 ]; then

echo ""
echo "Installing GUIv2 WASM build..."

wget -q -O /tmp/venus-webassembly.zip https://raw.githubusercontent.com/mr-manuel/venus-os_dbus-serialbattery_gui-v2/master/venus-webassembly.zip

# check if download was successful
if [ ! -f "/tmp/venus-webassembly.zip" ]; then
echo "** Download of GUIv2 failed! Skip installation. **"
echo "For offline installing see https://github.com/mr-manuel/venus-os_dbus-serialbattery_gui-v2"
else

unzip -o /data/venus-os_TailscaleGX/FileSets/venus-webassembly.zip -d /tmp > /dev/null

# remove unneeded files
if [ -f "/tmp/wasm/Makefile" ]; then
rm -f /tmp/wasm/Makefile
fi

# add commit-sha file
echo $hash_online > /tmp/wasm/commit-sha

# move original wasm build, if it's a folder
if [ -d "/var/www/venus/gui-v2" ] && [ ! -L "/var/www/venus/gui-v2" ]; then
mv /var/www/venus/gui-v2 /var/www/venus/gui-v2.bak
# remove if it's a symlink
elif [ -L "/var/www/venus/gui-v2" ]; then
rm -f /var/www/venus/gui-v2
fi
mv /tmp/wasm /var/www/venus/gui-v2

# create missing files for VRM portal check
echo "GZip WASM build..."
cd /var/www/venus/gui-v2 || return
gzip -k venus-gui-v2.wasm
echo "Create SHA256 checksum..."
sha256sum /var/www/venus/gui-v2/venus-gui-v2.wasm > /var/www/venus/gui-v2/venus-gui-v2.wasm.sha256

rm -f /tmp/venus-webassembly.zip

fi

fi

fi


# if files changed, restart gui
if [ $filesChanged -gt 0 ]; then

Expand Down
Loading

0 comments on commit 66488d8

Please sign in to comment.