From 6b732274e45dfa12ced3383c21009f946ef0c761 Mon Sep 17 00:00:00 2001 From: henne49 Date: Thu, 6 Jun 2024 14:56:07 +0200 Subject: [PATCH 1/5] align naming and remove typos --- dbus_service.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dbus_service.py b/dbus_service.py index d458ffa..eb850ed 100644 --- a/dbus_service.py +++ b/dbus_service.py @@ -425,13 +425,14 @@ def check_opendtu_data(self, meter_data): raise ValueError("You do not have the latest OpenDTU Version to run this script," "please upgrade your OpenDTU to at least version 4.4.3") - def fetch_opendtu_inverter_data(self, inverter_serial): - '''Fetch inverter date from OpenDTU device for one interter''' + def fetch_opendtu_iv_data(self, inverter_serial): + '''Fetch inverter date from OpenDTU device for one inverter''' iv_url = self._get_status_url() + "?inv=" + inverter_serial + logging.debug(f"Inverter URL: {iv_url}") return self.fetch_url(iv_url) def fetch_ahoy_iv_data(self, inverter_number): - '''Fetch inverter date from Ahoy device for one interter''' + '''Fetch inverter date from Ahoy device for one inverter''' iv_url = self.get_ahoy_base_url() + "/inverter/id/" + str(inverter_number) logging.debug(f"Inverter URL: {iv_url}") return self.fetch_url(iv_url) @@ -606,7 +607,7 @@ def get_values_for_inverter(self): else: inverter_serial = meter_data["inverters"][self.pvinverternumber]["serial"] logging.info(f"Inverter #{self.pvinverternumber} Serial: {inverter_serial}") - root_meter_data = self.fetch_opendtu_inverter_data(inverter_serial)["inverters"][0] + root_meter_data = self.fetch_opendtu_iv_data(inverter_serial)["inverters"][0] logging.debug(f"{root_meter_data}") firmware_v24_2_12_or_newer = False From 84e386a404262de9222256b325de1b83ac311e70 Mon Sep 17 00:00:00 2001 From: henne49 Date: Thu, 6 Jun 2024 15:22:26 +0200 Subject: [PATCH 2/5] typo --- dbus_service.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbus_service.py b/dbus_service.py index eb850ed..4f69355 100644 --- a/dbus_service.py +++ b/dbus_service.py @@ -426,13 +426,13 @@ def check_opendtu_data(self, meter_data): "please upgrade your OpenDTU to at least version 4.4.3") def fetch_opendtu_iv_data(self, inverter_serial): - '''Fetch inverter date from OpenDTU device for one inverter''' + '''Fetch inverter data from OpenDTU device for one inverter''' iv_url = self._get_status_url() + "?inv=" + inverter_serial logging.debug(f"Inverter URL: {iv_url}") return self.fetch_url(iv_url) def fetch_ahoy_iv_data(self, inverter_number): - '''Fetch inverter date from Ahoy device for one inverter''' + '''Fetch inverter data from Ahoy device for one inverter''' iv_url = self.get_ahoy_base_url() + "/inverter/id/" + str(inverter_number) logging.debug(f"Inverter URL: {iv_url}") return self.fetch_url(iv_url) From f75bef813de1f43fefd15f7408016ff3ba691d66 Mon Sep 17 00:00:00 2001 From: henne49 Date: Thu, 6 Jun 2024 15:42:28 +0200 Subject: [PATCH 3/5] fix uninstall-sh script not removing service --- uninstall.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/uninstall.sh b/uninstall.sh index 10493d9..f15c9f8 100644 --- a/uninstall.sh +++ b/uninstall.sh @@ -1,15 +1,19 @@ #!/bin/bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) SERVICE_NAME=$(basename $SCRIPT_DIR) -filename=/data/rc.local +RC_LOCAL_FILE=/data/rc.local #remove the service rm /service/$SERVICE_NAME # end the dbus-opendtu process -kill $(pgrep -f 'supervise dbus-opendtu') +kill $(pgrep -f 'dbus-opendtu') # delete old logs if they exist if [ -f $SCRIPT_DIR/current.log ]; then rm $SCRIPT_DIR/current.log* fi + +# remove install.sh from rc.local +STARTUP=$SCRIPT_DIR/install.sh +sed -i "\~$STARTUP~d" $RC_LOCAL_FILE \ No newline at end of file From cdfafd1a6ac9988e10033c1381a0f9d23caec1e9 Mon Sep 17 00:00:00 2001 From: henne49 Date: Thu, 6 Jun 2024 15:43:52 +0200 Subject: [PATCH 4/5] use SCRIPT_DIR in uninstall.sh script --- uninstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uninstall.sh b/uninstall.sh index f15c9f8..075e5be 100644 --- a/uninstall.sh +++ b/uninstall.sh @@ -7,7 +7,7 @@ RC_LOCAL_FILE=/data/rc.local rm /service/$SERVICE_NAME # end the dbus-opendtu process -kill $(pgrep -f 'dbus-opendtu') +kill $(pgrep -f "python $SCRIPT_DIR/dbus-opendtu.py") # delete old logs if they exist if [ -f $SCRIPT_DIR/current.log ]; then From f62aeabcc56600c9e4bf69b815b141936ec92ec0 Mon Sep 17 00:00:00 2001 From: henne49 Date: Thu, 6 Jun 2024 16:03:57 +0200 Subject: [PATCH 5/5] add comments to install.sh --- install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/install.sh b/install.sh index 1e35c7b..ff317f6 100755 --- a/install.sh +++ b/install.sh @@ -33,6 +33,8 @@ ln -s $SCRIPT_DIR/service /service/$SERVICE_NAME # add install-script to rc.local to be ready for firmware update filename=/data/rc.local + +#check if rc.local already exists, if not create it if [ ! -f $filename ] then touch $filename @@ -41,4 +43,5 @@ then echo >> $filename fi +#check if the service exists? if not add it to rc.local grep -qxF "$SCRIPT_DIR/install.sh" $filename || echo "$SCRIPT_DIR/install.sh" >> $filename