Skip to content

Commit

Permalink
reworked PR comments and requests
Browse files Browse the repository at this point in the history
  • Loading branch information
henne49 committed May 27, 2024
1 parent 680e392 commit 1f47ed2
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 19 deletions.
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ The following commands should do everything for you:
wget -O main.zip https://github.com/henne49/dbus-opendtu/archive/refs/heads/main.zip
unzip main.zip "dbus-opendtu-main/*" -d /data
mv /data/dbus-opendtu-main /data/dbus-opendtu
rm /data/dbus-opendtu/current.log*
chmod a+x /data/dbus-opendtu/install.sh
```

Expand All @@ -84,24 +83,19 @@ Just grap a copy of the main branch and copy the content to `/data/` e.g. `/data
After that call the `install.sh script.

```bash
cp /data/dbus-opendtu/config.ini /data/dbus-opendtu/config.backup
wget -O main.zip https://github.com/henne49/dbus-opendtu/archive/refs/heads/main.zip
unzip main.zip "dbus-opendtu-main/*" -d /data
rm /data/dbus-opendtu/current.log*
mv /data/dbus-opendtu-main/config.ini /data/dbus-opendtu-main/config.template
cp -R /data/dbus-opendtu-main/* /data/dbus-opendtu
rm -rf /data/dbus-opendtu-main/
cp /data/dbus-opendtu/config.ini /data/dbus-opendtu/config.backup
chmod a+x /data/dbus-opendtu/install.sh
```

Tha last step is to install the service and remove the downloaded files:

```bash
/data/dbus-opendtu/uninstall.sh
/data/dbus-opendtu/install.sh
/data/dbus-opendtu/restart.sh
rm main.zip
```
The last 4 step is to install the service and remove the downloaded files:

If the script does not work or start, please check the config.template file and update your config.ini. Or reconfigure the config.template with your configuration and save as config.ini. The process also creates a copy of your old config.ini called config.backup.

Expand Down
8 changes: 6 additions & 2 deletions dbus-opendtu.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ def main():
dtuvariant = config["DEFAULT"]["DTU"]
try:
number_of_inverters = int(config["DEFAULT"]["NumberOfInvertersToQuery"])
except Exception:
except (KeyError, ValueError) as ex:
logging.warning("NumberOfInvertersToQuery: %s", ex)
logging.warning("NumberOfInvertersToQuery not set, using default")
number_of_inverters = 0

try:
number_of_templates = int(config["DEFAULT"]["NumberOfTemplates"])
except Exception:
except (KeyError, ValueError) as ex:
logging.warning("NumberOfTemplates: %s", ex)
logging.warning("NumberOfTemplates not set, using default")
number_of_templates = 0

logging.basicConfig(
Expand Down
8 changes: 4 additions & 4 deletions dbus_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ def _read_config_dtu(self, actual_inverter):
try:
self.max_age_ts = int(config["DEFAULT"]["MaxAgeTsLastSuccess"])
except (KeyError, ValueError) as ex:
logging.debug("MaxAgeTsLastSuccess: %s", ex)
logging.debug("MaxAgeTsLastSuccess not set, using default")
logging.warning("MaxAgeTsLastSuccess: %s", ex)
logging.warning("MaxAgeTsLastSuccess not set, using default")
self.max_age_ts = 600

self.dry_run = is_true(get_default_config(config, "DryRun", False))
Expand Down Expand Up @@ -260,8 +260,8 @@ def _read_config_template(self, template_number):
try:
self.max_age_ts = int(config["DEFAULT"]["MaxAgeTsLastSuccess"])
except (KeyError, ValueError) as ex:
logging.debug("MaxAgeTsLastSuccess: %s", ex)
logging.debug("MaxAgeTsLastSuccess not set, using default")
logging.warning("MaxAgeTsLastSuccess: %s", ex)
logging.warning("MaxAgeTsLastSuccess not set, using default")
self.max_age_ts = 600

self.dry_run = is_true(get_default_config(config, "DryRun", False))
Expand Down
5 changes: 5 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SERVICE_NAME=$(basename $SCRIPT_DIR)

# delete old logs if they exist
if [ -f /data/dbus-opendtu/current.log ]; then
rm /data/dbus-opendtu/current.log*
fi

# set permissions for script files
chmod a+x $SCRIPT_DIR/restart.sh
chmod 744 $SCRIPT_DIR/restart.sh
Expand Down
3 changes: 2 additions & 1 deletion service/log/run
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh
exec 2>&1
exec multilog t s25000 n4 /var/log/dbus-opendtu
# documentation on how to use multilog https://manpages.debian.org/stretch/daemontools/multilog.8.en.html
exec multilog t s153600 n2 /var/log/dbus-opendtu
13 changes: 9 additions & 4 deletions uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SERVICE_NAME=$(basename $SCRIPT_DIR)
filename=/data/rc.local

#remove the service
rm /service/$SERVICE_NAME

# end the dbus-opendtu process
kill $(pgrep -f 'supervise dbus-opendtu')
chmod a-x $SCRIPT_DIR/service/run
$SCRIPT_DIR/restart.sh
STARTUP=$SCRIPT_DIR/install.sh
sed -i "\~$STARTUP~d" $filename

# delete old logs if they exist
if [ -f /data/dbus-opendtu/current.log ]; then
rm /data/dbus-opendtu/current.log*
fi

0 comments on commit 1f47ed2

Please sign in to comment.