From 5ff59e8ef3aa023a57e59e99bcd5ce2eee2159de Mon Sep 17 00:00:00 2001 From: Christian Butterweck Date: Wed, 13 Nov 2024 20:30:05 +0100 Subject: [PATCH 1/8] Update controller.sh --- scripts/controller.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/controller.sh b/scripts/controller.sh index 5f20284..839fc84 100644 --- a/scripts/controller.sh +++ b/scripts/controller.sh @@ -1192,7 +1192,7 @@ charger_command_stop_charging() { } charger_command_set_SOC_target() { - echo Nothing to do at sonnen charger. >nul + echo Nothing to do at sonnen charger. >/dev/null } charger_disable_inverter() { From 37aa1613f26308c20e809e2f3bfe21494a2f821f Mon Sep 17 00:00:00 2001 From: Christian Butterweck Date: Sun, 17 Nov 2024 00:50:32 +0100 Subject: [PATCH 2/8] Update controller.sh --- scripts/controller.sh | 50 +++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/scripts/controller.sh b/scripts/controller.sh index 839fc84..a469987 100644 --- a/scripts/controller.sh +++ b/scripts/controller.sh @@ -1173,41 +1173,41 @@ fi # sonnenBatterie (experimental) if [ "$use_charger" == "4" ]; then - -SOC_percent=$(curl --max-time 5 --header "Auth-Token: $sonnen_API_KEY" "$sonnen_API_URL/latestdata" | awk -F'[,{}:]' '{for(i=1;i<=NF;i++) if ($i ~ /"USOC"/) print $(i+1)}') + echo curl --max-time 5 --header "Auth-Token: $sonnen_API_KEY" "$sonnen_API_URL/latestdata" + SOC_percent=$(curl --max-time 5 --header "Auth-Token: $sonnen_API_KEY" "$sonnen_API_URL/latestdata" | awk -F'[,{}:]' '{for(i=1;i<=NF;i++) if ($i ~ /"USOC"/) print $(i+1)}') if [ -z "$SOC_percent" ]; then log_message >&2 "E: Timeout while trying to read RSOC from the charger." exit 1 fi -charger_command_charge() { - log_message >&2 "I: Executing curl -X PUT -d EM_USOC="$target_soc" --header "Auth-Token: $sonnen_API_KEY" "$sonnen_API_URL/configurations"" - curl -X PUT -d EM_USOC="$target_soc" --header "Auth-Token: $sonnen_API_KEY" "$sonnen_API_URL/configurations" -} + charger_command_charge() { + log_message >&2 "I: Executing curl -X PUT -d EM_USOC=$target_soc --header Auth-Token: $sonnen_API_KEY $sonnen_API_URL/configurations" + curl -X PUT -d "EM_USOC=$target_soc" --header "Auth-Token: $sonnen_API_KEY" "$sonnen_API_URL/configurations" + } -charger_command_stop_charging() { - log_message >&2 "I: Executing curl -X PUT -d EM_USOC=0 --header "Auth-Token: $sonnen_API_KEY" "$sonnen_API_URL/configurations"" - curl -X PUT -d EM_USOC=0 --header "Auth-Token: $sonnen_API_KEY" "$sonnen_API_URL/configurations" -} + charger_command_stop_charging() { + log_message >&2 "I: Executing curl -X PUT -d EM_USOC=0 --header Auth-Token: $sonnen_API_KEY $sonnen_API_URL/configurations" + curl -X PUT -d "EM_USOC=0" --header "Auth-Token: $sonnen_API_KEY" "$sonnen_API_URL/configurations" + } -charger_command_set_SOC_target() { - echo Nothing to do at sonnen charger. >/dev/null -} + charger_command_set_SOC_target() { + echo "Nothing to do at sonnen charger." >/dev/null + } -charger_disable_inverter() { - if ((charging == 0)); then - log_message >&2 "I: Executing curl -X PUT -d EM_USOC="$SOC_percent" --header "Auth-Token: $sonnen_API_KEY" "$sonnen_API_URL/configurations"" - curl -X PUT -d EM_USOC="$SOC_percent" --header "Auth-Token: $sonnen_API_KEY" "$sonnen_API_URL/configurations" - fi -} + charger_disable_inverter() { + if ((charging == 0)); then + log_message >&2 "I: Executing curl -X PUT -d EM_USOC=$SOC_percent --header Auth-Token: $sonnen_API_KEY $sonnen_API_URL/configurations" + curl -X PUT -d "EM_USOC=$SOC_percent" --header "Auth-Token: $sonnen_API_KEY" "$sonnen_API_URL/configurations" + fi + } -charger_enable_inverter() { - if ((charging == 0)); then - log_message >&2 "I: Executing curl -X PUT -d EM_USOC=0 --header "Auth-Token: $sonnen_API_KEY" "$sonnen_API_URL/configurations"" - curl -X PUT -d EM_USOC=0 --header "Auth-Token: $sonnen_API_KEY" "$sonnen_API_URL/configurations" - fi -} + charger_enable_inverter() { + if ((charging == 0)); then + log_message >&2 "I: Executing curl -X PUT -d EM_USOC=0 --header Auth-Token: $sonnen_API_KEY $sonnen_API_URL/configurations" + curl -X PUT -d "EM_USOC=0" --header "Auth-Token: $sonnen_API_KEY" "$sonnen_API_URL/configurations" + fi + } fi From 29922b37d55ac162e8ec2e57724a60acc9cd1acf Mon Sep 17 00:00:00 2001 From: Christian Butterweck Date: Sun, 17 Nov 2024 00:51:42 +0100 Subject: [PATCH 3/8] Update controller.sh --- scripts/controller.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/controller.sh b/scripts/controller.sh index a469987..6d0f75a 100644 --- a/scripts/controller.sh +++ b/scripts/controller.sh @@ -1173,7 +1173,7 @@ fi # sonnenBatterie (experimental) if [ "$use_charger" == "4" ]; then - echo curl --max-time 5 --header "Auth-Token: $sonnen_API_KEY" "$sonnen_API_URL/latestdata" + SOC_percent=$(curl --max-time 5 --header "Auth-Token: $sonnen_API_KEY" "$sonnen_API_URL/latestdata" | awk -F'[,{}:]' '{for(i=1;i<=NF;i++) if ($i ~ /"USOC"/) print $(i+1)}') if [ -z "$SOC_percent" ]; then From aa47e6e0ac47761dd002c9e791f893151198f963 Mon Sep 17 00:00:00 2001 From: Christian Butterweck Date: Sun, 17 Nov 2024 01:00:27 +0100 Subject: [PATCH 4/8] Update controller.sh --- scripts/controller.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/controller.sh b/scripts/controller.sh index 6d0f75a..67fa9b8 100644 --- a/scripts/controller.sh +++ b/scripts/controller.sh @@ -1182,12 +1182,12 @@ if [ "$use_charger" == "4" ]; then fi charger_command_charge() { - log_message >&2 "I: Executing curl -X PUT -d EM_USOC=$target_soc --header Auth-Token: $sonnen_API_KEY $sonnen_API_URL/configurations" + log_message >&2 "I: Executing curl -X PUT -d EM_USOC=$target_soc --header \"Auth-Token: $sonnen_API_KEY\" $sonnen_API_URL/configurations" curl -X PUT -d "EM_USOC=$target_soc" --header "Auth-Token: $sonnen_API_KEY" "$sonnen_API_URL/configurations" } charger_command_stop_charging() { - log_message >&2 "I: Executing curl -X PUT -d EM_USOC=0 --header Auth-Token: $sonnen_API_KEY $sonnen_API_URL/configurations" + log_message >&2 "I: Executing curl -X PUT -d EM_USOC=0 --header \"Auth-Token: $sonnen_API_KEY\" $sonnen_API_URL/configurations" curl -X PUT -d "EM_USOC=0" --header "Auth-Token: $sonnen_API_KEY" "$sonnen_API_URL/configurations" } @@ -1197,18 +1197,17 @@ if [ "$use_charger" == "4" ]; then charger_disable_inverter() { if ((charging == 0)); then - log_message >&2 "I: Executing curl -X PUT -d EM_USOC=$SOC_percent --header Auth-Token: $sonnen_API_KEY $sonnen_API_URL/configurations" + log_message >&2 "I: Executing curl -X PUT -d EM_USOC=$SOC_percent --header \"Auth-Token: $sonnen_API_KEY\" $sonnen_API_URL/configurations" curl -X PUT -d "EM_USOC=$SOC_percent" --header "Auth-Token: $sonnen_API_KEY" "$sonnen_API_URL/configurations" fi } charger_enable_inverter() { if ((charging == 0)); then - log_message >&2 "I: Executing curl -X PUT -d EM_USOC=0 --header Auth-Token: $sonnen_API_KEY $sonnen_API_URL/configurations" + log_message >&2 "I: Executing curl -X PUT -d EM_USOC=0 --header \"Auth-Token: $sonnen_API_KEY\" $sonnen_API_URL/configurations" curl -X PUT -d "EM_USOC=0" --header "Auth-Token: $sonnen_API_KEY" "$sonnen_API_URL/configurations" fi } - fi for tool in $tools; do From 5db91dd94160382e1dbb22f25bcc3ee3af1e50c6 Mon Sep 17 00:00:00 2001 From: Christian Butterweck Date: Sun, 17 Nov 2024 15:23:00 +0100 Subject: [PATCH 5/8] Add 13:00 extra loop to check if second day prices are available Five minute extra loop if next day prices are delayed. --- scripts/controller.sh | 62 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/scripts/controller.sh b/scripts/controller.sh index 67fa9b8..4d3d19d 100644 --- a/scripts/controller.sh +++ b/scripts/controller.sh @@ -957,6 +957,22 @@ checkAndClean() { fi } +fetch_prices() { + if [ "$select_pricing_api" -eq 1 ]; then + Unit="Cent/kWh $price_unit price" + get_awattar_prices + get_awattar_prices_integer + elif [ "$select_pricing_api" -eq 2 ]; then + Unit="EUR/MWh net" + get_entsoe_prices + get_prices_integer_entsoe + elif [ "$select_pricing_api" -eq 3 ]; then + Unit="EUR/kWh $price_unit price" + get_tibber_prices + get_tibber_prices_integer + fi +} + #################################### ### Begin of the script... ### #################################### @@ -1371,19 +1387,7 @@ if [ "$include_second_day" = 1 ]; then fi -if ((select_pricing_api == 1)); then - Unit="Cent/kWh $price_unit price" - get_awattar_prices - get_awattar_prices_integer -elif ((select_pricing_api == 2)); then - Unit="EUR/MWh net" - get_entsoe_prices - get_prices_integer_entsoe -elif ((select_pricing_api == 3)); then - Unit="EUR/kWh $price_unit price" - get_tibber_prices - get_tibber_prices_integer -fi +fetch_prices if ((use_solarweather_api_to_abort == 1)); then download_solarenergy @@ -1414,6 +1418,38 @@ for i in $(seq 1 $loop_hours); do fi done log_message >&2 "I: Sorted prices: $price_table" +if [ "$include_second_day" -eq 1 ]; then + price_count=$(echo "$price_table" | grep -oE '[0-9]+:[0-9]+\.[0-9]+' | wc -l) + log_message >&2 "D: number of prices: $price_count" + + if [ "$price_count" -le 24 ]; then + log_message >&2 "I: time is 13:00. Extra checking and waiting for 48-hr prices every 5 minutes..." + + current_hour=$(date +%H) + if [ "$current_hour" -eq 13 ]; then + while [ "$current_hour" -eq 13 ]; do + fetch_prices + price_table="" + for i in $(seq 1 $loop_hours); do + eval price=\$P$i + price_table+="$i:$price " + + if [ $((i % 12)) -eq 0 ]; then + price_table+="\n " + fi + done + log_message >&2 "I: Sorted prices: $price_table" + price_count=$(echo "$price_table" | tr ' ' '\n' | wc -l) + if [ "$price_count" -gt 24 ]; then + break + else + sleep 300 + fi + current_hour=$(date +%H) + done + fi + fi +fi if [ "$loop_hours" = 24 ]; then From 845427cb1401a37f678cf5dd73e4842720b529e3 Mon Sep 17 00:00:00 2001 From: Christian Butterweck Date: Mon, 18 Nov 2024 08:04:08 +0100 Subject: [PATCH 6/8] Update controller.sh --- scripts/controller.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/controller.sh b/scripts/controller.sh index 4d3d19d..a69c840 100644 --- a/scripts/controller.sh +++ b/scripts/controller.sh @@ -1423,10 +1423,9 @@ if [ "$include_second_day" -eq 1 ]; then log_message >&2 "D: number of prices: $price_count" if [ "$price_count" -le 24 ]; then - log_message >&2 "I: time is 13:00. Extra checking and waiting for 48-hr prices every 5 minutes..." - current_hour=$(date +%H) if [ "$current_hour" -eq 13 ]; then + log_message >&2 "I: time is > 13:00 and price data delayed. Extra checking and waiting for new prices every 5 minutes..." while [ "$current_hour" -eq 13 ]; do fetch_prices price_table="" From 9f14939edb55ec4c516f91b8f53e79cc99443ff1 Mon Sep 17 00:00:00 2001 From: Christian Butterweck Date: Mon, 18 Nov 2024 22:24:52 +0100 Subject: [PATCH 7/8] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bf5655d..76522f0 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ Supported systems are currently: - Shelly products (such as [Shelly Plug S](https://shellyparts.de/products/shelly-plus-plug-s) or [Shelly Plus](https://shellyparts.de/products/shelly-plus-1pm)) - [AVMFritz!DECT200](https://avm.de/produkte/smart-home/fritzdect-200/) and [210](https://avm.de/produkte/smart-home/fritzdect-210/) switchable sockets - [Victron](https://www.victronenergy.com/) Venus OS Energy Storage Systems like the [MultiPlus-II series](https://www.victronenergy.com/inverters-chargers) (Dbus at localhost and MQTT by LAN is supported) +- [sonnen](https://www.sonnen.de/) AC-AC systems like [sonnen Batterie 10](https://sonnen.de/stromspeicher/sonnenbatterie-10/) with software version 1.15.6 over LAN (standalone system without SonnenCommunity or sonnenVPP). - [other MQTT charger](http://www.steves-internet-guide.com/mosquitto_pub-sub-clients/) (chargers that are controlable by mosquitto MQTT commands) Getting Started: From 0b2cf6443d65f0cb6a783535b61a2c9b285c4375 Mon Sep 17 00:00:00 2001 From: Christian Butterweck Date: Mon, 18 Nov 2024 22:25:58 +0100 Subject: [PATCH 8/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 76522f0..2604c51 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Supported systems are currently: - Shelly products (such as [Shelly Plug S](https://shellyparts.de/products/shelly-plus-plug-s) or [Shelly Plus](https://shellyparts.de/products/shelly-plus-1pm)) - [AVMFritz!DECT200](https://avm.de/produkte/smart-home/fritzdect-200/) and [210](https://avm.de/produkte/smart-home/fritzdect-210/) switchable sockets - [Victron](https://www.victronenergy.com/) Venus OS Energy Storage Systems like the [MultiPlus-II series](https://www.victronenergy.com/inverters-chargers) (Dbus at localhost and MQTT by LAN is supported) -- [sonnen](https://www.sonnen.de/) AC-AC systems like [sonnen Batterie 10](https://sonnen.de/stromspeicher/sonnenbatterie-10/) with software version 1.15.6 over LAN (standalone system without SonnenCommunity or sonnenVPP). +- [sonnen](https://www.sonnen.de/) AC-AC systems like [sonnen Batterie 10](https://sonnen.de/stromspeicher/sonnenbatterie-10/). Tested with software version 1.15.6 over LAN at a standalone system without SonnenCommunity or sonnenVPP. - [other MQTT charger](http://www.steves-internet-guide.com/mosquitto_pub-sub-clients/) (chargers that are controlable by mosquitto MQTT commands) Getting Started: