Skip to content

Commit

Permalink
Merge pull request #156 from christian1980nrw/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
christian1980nrw authored Nov 1, 2023
2 parents 75fca66 + f53bcc9 commit 44e0a9c
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
- name: Set script permissions
run: chmod +x ./victron-venus-os-install.sh
- name: Install
run: ./victron-venus-os-install.sh
run: echo 'y' | sh ./victron-venus-os-install.sh
env:
DEBUG: 1
DESTDIR: /tmp/testing
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Albania (AL), Austria (AT), Belgium (BE), Bosnia and Herz. (BA), Bulgaria (BG),

![grafik](https://user-images.githubusercontent.com/6513794/224442951-c0155a48-f32b-43f4-8014-d86d60c3b311.png)

If you like to see a more detailed output in debugmode, please have a look at this example testrun: [pull request testrun #155](https://github.com/christian1980nrw/Spotmarket-Switcher/actions/runs/6697976612/job/18199014118])

## Installation

Setting up the Spotmarket-Switcher is a straightforward process. If you are already running a UNIX-based machine, such as macOS, Linux, or Windows with the Linux subsystem, follow these steps to install the software:
Expand Down
21 changes: 9 additions & 12 deletions scripts/controller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ License=$(
EOLICENSE
)

VERSION="2.3.10-DEV"
VERSION="2.3.11-DEV"

set -e

Expand Down Expand Up @@ -151,8 +151,8 @@ else
["energy_loss_percent"]="[0-9]+(\.[0-9]+)?"
["battery_lifecycle_costs_cent_per_kwh"]="[0-9]+(\.[0-9]+)?"
["economic_check"]="0|1|2"
["stop_price"]="[0-9]+(\.[0-9]+)?"
["start_price"]="[0-9]+(\.[0-9]+)?"
["stop_price"]="-?[0-9]+(\.[0-9]+)?"
["start_price"]="-?[0-9]+(\.[0-9]+)?"
["feedin_price"]="[0-9]+(\.[0-9]+)?"
["energy_fee"]="[0-9]+(\.[0-9]+)?"
["abort_price"]="[0-9]+(\.[0-9]+)?"
Expand Down Expand Up @@ -504,18 +504,15 @@ download_solarenergy() {
log_message "D: No delay of download of solarenergy data since DEBUG variable set." >&2
fi
if ! curl "$link3" -o "$file3"; then
log_message "E: Download of solarenergy data from '$link3' failed."
exit_with_cleanup 1
log_message "E: Download of solarenergy data from '$link3' failed. Solarenergy will be ignored."
elif ! test -f "$file3"; then
log_message "E: Could not get solarenergy data, missing file '$file3'."
exit_with_cleanup 1
log_message "E: Could not get solarenergy data, missing file '$file3'. Solarenergy will be ignored."
fi
if [ -n "$DEBUG" ]; then
log_message "D: File3 $file3 downloaded" >&2
fi
if ! test -f "$file3"; then
log_message "E: Could not find downloaded file '$file3' with solarenergy data."
exit_with_cleanup 1
log_message "E: Could not find downloaded file '$file3' with solarenergy data. Solarenergy will be ignored."
fi
if [ -n "$DEBUG" ]; then
log_message "D: Solarenergy data downloaded to file '$file3'."
Expand Down Expand Up @@ -1203,9 +1200,9 @@ switchablesockets_conditions=(
evaluate_conditions switchablesockets_conditions[@] switchablesockets_conditions_descriptions[@] "execute_switchablesockets_on" "switchablesockets_condition_met"

if ((use_solarweather_api_to_abort == 1)); then
check_abort_condition $((abort_suntime <= suntime_today)) "There are enough sun minutes today."
check_abort_condition $((abort_solar_yield_today_integer <= solarenergy_today_integer)) "There is enough solarenergy today."
check_abort_condition $((abort_solar_yield_tomorrow_integer <= solarenergy_tomorrow_integer)) "There is enough sun tomorrow."
check_abort_condition $((abort_suntime <= suntime_today)) "There are enough sun minutes today. No need to charge or swtich."
check_abort_condition $((abort_solar_yield_today_integer <= solarenergy_today_integer)) "There is enough solarenergy today. No need to charge or switch."
check_abort_condition $((abort_solar_yield_tomorrow_integer <= solarenergy_tomorrow_integer)) "There is enough sun tomorrow. No need to charge or switch."
fi

# abort_price_integer cannot be found by shellcheck can be ignored, false positive
Expand Down
2 changes: 1 addition & 1 deletion scripts/sample.config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ feedin_price=9.87 # your feed-in-tariff of your solar system
energy_fee=18.492 # proofs of origin, allocations, duties and taxes (in case if stock price is at 0 Cent/kWh)
abort_price=50.1 # abort and never charge or switch if actual price is same or higher than this (Energy fees not included)

use_start_stop_logic=0 # Set to 1 to activate start/stop logic (start_stop_price).
use_start_stop_logic=0 # Set to 1 to activate charging with start/stop logic (start_stop_price).
switchablesockets_at_start_stop=0 # You can add a additional load (like water heater) with AVM Fritz DECT200/210 switch sockets if you like.
charge_at_solar_breakeven_logic=0 # Charge if energy including fees is cheaper than your own feedin-tariff of your solar system
switchablesockets_at_solar_breakeven_logic=0
Expand Down
62 changes: 43 additions & 19 deletions victron-venus-os-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ e_note() {
printf "${underline}${bold}${blue}Note:${reset} ${blue}%s${reset}\n" "$@"
}

echo
e_header "Spotmarket-Switcher Installer"
echo

# Checking preconditions for successful execution

missing=""
Expand All @@ -157,23 +161,33 @@ for tool in wget curl; do
fi
done
if [ -n "$missing" ]; then
e_note "W: Install the following tools prior to the execution of the installed scripts: $missing."
e_note " Try running 'opkg install $missing'."
e_warning "W: Install the following tools prior to the execution of the installed scripts: $missing."
e_warning " Try running 'opkg install $missing'."
echo
e_note " Now continuing with the installation, which will be fine per se, but you as the user are responsible to get those dependencies installed to prevent the control script from failing. Drop an issue at https://github.com/christian1980nrw/Spotmarket-Switcher/issues if this package shall somehow prepare you better."
echo
fi

# DESTDIR is optionally set as an environment variable.
if [ -n "$DESTDIR" ] && [ "/" != "$DESTDIR" ]; then
e_note "W: The environment variable DESTDIR is set to the value '$DESTDIR' that is different from '/', the root directory."
e_warning "W: The environment variable DESTDIR is set to the value '$DESTDIR' that is different from '/', the root directory."
e_note " This is meant to support testing and packaging, not for a true installation."
e_underline " If you are using Victron Venus OS, the correct installation directory should be '/'."
e_note " No harm is expected to be caused, but it's recommended to install directly to '/' for a standard installation."
e_note " You can cancel now with CTRL-C if this is not what you intended."
sleep 5
e_underline "I: Will now continue. You can still interrupt at any time."
echo
e_bold " If you are using Victron Venus OS, the correct installation directory should be '/'."
echo
e_note " No harm is expected to be caused, but it's recommended to install directly to '/' for a standard installation."
e_header " You can cancel now with CTRL-C if this is not what you intended."

printf "Do you want to continue? (y/N)"
read CONTINUE
CONTINUE=${CONTINUE:-n}
if [ "$CONTINUE" = "y" ] || [ "$CONTINUE" = "Y" ]; then
e_success "Starting installation."
else
e_error "Installation aborted."
exit 1
fi

else
ln -s /data/etc/Spotmarket-Switcher/service /service/Spotmarket-Switcher
(crontab -l | grep -Fxq "0 * * * * /data/etc/Spotmarket-Switcher/controller.sh") || (
Expand All @@ -191,7 +205,7 @@ downloadToDest() {
url="$1"
dest="$2"

echo "I: Downloading '$(basename "$url")'"
e_bold "I: Downloading '$(basename "$url")'"
if ! wget --no-verbose --continue --no-directories --show-progress -O "$dest" "$url"; then
e_error "E: Download of '$(basename "$url")' failed."
return 1
Expand All @@ -214,7 +228,7 @@ download_file_if_missing() {
ls
}
fi
e_note "I: Downloading '$(basename "$file_path")' from github repository - '$BRANCH' branch"
e_bold "I: Downloading '$(basename "$file_path")' from github repository - '$BRANCH' branch"
downloadToDest "$file_url" "$dest_path"
fi
}
Expand All @@ -239,12 +253,16 @@ cp -n "$DESTDIR/data/etc/Spotmarket-Switcher/sample.config.txt" "$DESTDIR/data/e
# $DESTDIR is always an absolut path
if [ ! -d "$DESTDIR"/service ]; then
if [ -n "$DESTDIR" ] && [ "/" != "$DESTDIR" ]; then
echo
e_note "I: The '$DESTDIR/service' directory is not existing, as expected because of the custom DESTDIR setting."
e_note " Skipping creation of symbolic link to the Sportmarket-Switcher to register this service."
echo
else
e_note "W: The '$DESTDIR/service' directory is not existing."
echo
e_warning "W: The '$DESTDIR/service' directory is not existing."
e_note " Not installing a symbolic link to the Sportmarket-Switcher to register this service."
e_note " Check on https://github.com/$ACTOR/Spotmarket-Switcher/issues if that has already been reported."
echo
fi
else
if [ ! -L "$DESTDIR"/service/Spotmarket-Switcher ]; then
Expand All @@ -267,16 +285,22 @@ fi

echo
e_success "Installation completed. Spotmarket-Switcher will be executed every full hour."
e_note "The crontab will be changed automatically by the script '$DESTDIR/data/etc/Spotmarket-Switcher/service/run' ."
e_note "Please edit the configuration file with a text editor, like"
e_note " vi '$DESTDIR/data/etc/Spotmarket-Switcher/config.txt'"
e_note " or"
e_note " nano '$DESTDIR/data/etc/Spotmarket-Switcher/config.txt'"
e_note "and change it to your needs."
echo
e_note "Note: This installation will survive a Venus OS firmware update."
e_bold "The crontab will be changed automatically by the script '$DESTDIR/data/etc/Spotmarket-Switcher/service/run' ."
echo
e_underline "Please edit the configuration file with a text editor, like"
echo
echo " vi '$DESTDIR/data/etc/Spotmarket-Switcher/config.txt'"
echo
echo "or"
echo
echo " nano '$DESTDIR/data/etc/Spotmarket-Switcher/config.txt'"
echo
e_underline "and change it to your needs."
echo
e_success "Note: This installation will survive a Venus OS firmware update."
echo
if [ -n "$missing" ]; then
e_note "Note: Remember to install these missing executables: $missing"
echo
fi
fi

0 comments on commit 44e0a9c

Please sign in to comment.