Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dbus_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def __init__(
self._dbusservice.add_path("/Connected", 1)

self._dbusservice.add_path("/Latency", None)
self._dbusservice.add_path("/FirmwareVersion", 0.1)
self._dbusservice.add_path("/FirmwareVersion", read_version('version.txt'))
self._dbusservice.add_path("/HardwareVersion", 0)
self._dbusservice.add_path("/Position", self.acposition) # normaly only needed for pvinverter
self._dbusservice.add_path("/Serial", self._get_serial(self.pvinverternumber))
Expand Down
13 changes: 13 additions & 0 deletions helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# system imports
import functools
import time
import os

# our imports:
import logging
Expand Down Expand Up @@ -124,3 +125,15 @@ def wrapped_func(*args, **kwargs):
logging.debug(f"function {func.__name__} finished in {round(elapsed_time * 1000)} ms")
return result
return wrapped_func

def read_version(file_name):
try:
current_dir = os.path.dirname(os.path.abspath(__file__))
file_path = os.path.join(current_dir, file_name)
with open(file_path, 'r') as file:
line = file.readline()
version = line.split(':')[-1].strip()
return version
except FileNotFoundError:
logging.error(f"File {file_name} not found in the current directory.")
return 0.1
9 changes: 9 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ if [ -f $SCRIPT_DIR/current.log ]; then
rm $SCRIPT_DIR/current.log*
fi

# check if version.txt exists and is larger than 2.0.0
if [ -f $SCRIPT_DIR/version.txt ] &&
( [ "$(grep -o 'Version: [^ ]*' version.txt | cut -d' ' -f2)" = "2.0.0" ] ||
[ "$(grep -o 'Version: [^ ]*' version.txt | cut -d' ' -f2)" \> "2.0.0" ] ); then
# delete old dbus-opendtu.py file
if [ -f $SCRIPT_DIR/dbus-opendtu.py ]; then
rm $SCRIPT_DIR/dbus-opendtu.py
fi
fi

# set permissions for script files
chmod a+x $SCRIPT_DIR/restart.sh
Expand Down
8 changes: 4 additions & 4 deletions service/run
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#Script Directory
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
#Define the version filename
FILENAME=$(realpath $SCRIPT_DIR/../version.txt)
CODE_VERSION_FILE=$(realpath $SCRIPT_DIR/../version.txt)
exec 2>&1
#Check if the file exists
if [ -f "$FILENAME" ]; then
if [ -f "$CODE_VERSION_FILE" ]; then
#If the file exists, print its contents to stdout
cat "$FILENAME"
cat "$CODE_VERSION_FILE"
fi
python $(realpath $SCRIPT_DIR/../dbus_opendtu.py)
python $(realpath $SCRIPT_DIR/../dbus_opendtu.py)
2 changes: 1 addition & 1 deletion update.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set the repository name and username
REPO="henne49/dbus-opendtu"
STARTUP_FILE="/data/home/root/rc.local"
STARTUP_FILE="/data/rc.local"
#!/bin/bash

# Check if the file exists
Expand Down
Loading