Skip to content

Commit

Permalink
Fix of uninstall.sh script and typos (#198)
Browse files Browse the repository at this point in the history
* align naming and remove typos

* typo

* fix uninstall-sh script not removing service

* use SCRIPT_DIR in uninstall.sh script

* add comments to install.sh
  • Loading branch information
henne49 committed Jun 6, 2024
1 parent 1878823 commit 1279b89
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
9 changes: 5 additions & 4 deletions dbus_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 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 interter'''
'''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)
Expand Down Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
8 changes: 6 additions & 2 deletions uninstall.sh
Original file line number Diff line number Diff line change
@@ -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 "python $SCRIPT_DIR/dbus-opendtu.py")

# 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

0 comments on commit 1279b89

Please sign in to comment.