forked from snaptec/openWB
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of git://github.com/snaptec/openWB
- Loading branch information
Showing
13 changed files
with
436 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 andig | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#!/bin/bash | ||
OPENWBBASEDIR=$(cd `dirname $0`/../../ && pwd) | ||
RAMDISKDIR="$OPENWBBASEDIR/ramdisk" | ||
MODULEDIR=$(cd `dirname $0` && pwd) | ||
DMOD="EVSOC" | ||
CHARGEPOINT=$1 | ||
|
||
# check if config file is already in env | ||
if [[ -z "$debug" ]]; then | ||
echo "soc_evcc: Seems like openwb.conf is not loaded. Reading file." | ||
# try to load config | ||
. $OPENWBBASEDIR/loadconfig.sh | ||
# load helperFunctions | ||
. $OPENWBBASEDIR/helperFunctions.sh | ||
fi | ||
|
||
case $CHARGEPOINT in | ||
2) | ||
# second charge point | ||
ladeleistung=$(<$RAMDISKDIR/llaktuells1) | ||
soctimerfile="$RAMDISKDIR/soctimer1" | ||
socfile="$RAMDISKDIR/soc1" | ||
fztype=$soc_evcc_type_lp2 | ||
username=$soc_evcc_username_lp2 | ||
password=$soc_evcc_password_lp2 | ||
vin=$soc_evcc_vin_lp2 | ||
token=$soc_evcc_token_lp2 | ||
intervall=$(( soc2intervall * 6 )) | ||
intervallladen=$(( soc2intervallladen * 6 )) | ||
;; | ||
*) | ||
# defaults to first charge point for backward compatibility | ||
# set CHARGEPOINT in case it is empty (needed for logging) | ||
CHARGEPOINT=1 | ||
ladeleistung=$(<$RAMDISKDIR/llaktuell) | ||
soctimerfile="$RAMDISKDIR/soctimer" | ||
socfile="$RAMDISKDIR/soc" | ||
fztype=$soc_evcc_type_lp1 | ||
username=$soc_evcc_username_lp1 | ||
password=$soc_evcc_password_lp1 | ||
vin=$soc_evcc_vin_lp1 | ||
token=$soc_evcc_token_lp1 | ||
intervall=$(( soc_evcc_intervall * 6 )) | ||
intervallladen=$(( soc_evcc_intervallladen * 6 )) | ||
;; | ||
esac | ||
|
||
incrementTimer(){ | ||
case $dspeed in | ||
1) | ||
# Regelgeschwindigkeit 10 Sekunden | ||
ticksize=1 | ||
;; | ||
2) | ||
# Regelgeschwindigkeit 20 Sekunden | ||
ticksize=2 | ||
;; | ||
3) | ||
# Regelgeschwindigkeit 60 Sekunden | ||
ticksize=6 | ||
;; | ||
*) | ||
# Regelgeschwindigkeit unbekannt | ||
ticksize=1 | ||
;; | ||
esac | ||
soctimer=$((soctimer+$ticksize)) | ||
echo $soctimer > $soctimerfile | ||
} | ||
|
||
getAndWriteSoc(){ | ||
openwbDebugLog ${DMOD} 0 "Lp$CHARGEPOINT: Requesting SoC" | ||
echo 0 > $soctimerfile | ||
answer=$($MODULEDIR/../soc_evcc/soc $fztype --user "$username" --password "$password" --vin "$vin" --token "$token" 2>&1) | ||
if [ $? -eq 0 ]; then | ||
# we got a valid answer | ||
echo $answer > $socfile | ||
openwbDebugLog ${DMOD} 0 "Lp$CHARGEPOINT: SoC: $answer" | ||
else | ||
# we have a problem | ||
openwbDebugLog ${DMOD} 0 "Lp$CHARGEPOINT: Error from EVCC: $answer" | ||
fi | ||
} | ||
|
||
soctimer=$(<$soctimerfile) | ||
if (( ladeleistung > 500 )); then | ||
if (( soctimer < intervallladen )); then | ||
openwbDebugLog ${DMOD} 0 "Lp$CHARGEPOINT: Charging, but nothing to do yet. Incrementing timer." | ||
incrementTimer | ||
else | ||
getAndWriteSoc | ||
fi | ||
else | ||
if (( soctimer < intervall )); then | ||
openwbDebugLog ${DMOD} 0 "Lp$CHARGEPOINT: Nothing to do yet. Incrementing timer." | ||
incrementTimer | ||
|
||
else | ||
getAndWriteSoc | ||
fi | ||
fi |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
OPENWBBASEDIR=$(cd `dirname $0`/../../ && pwd) | ||
|
||
# for backward compatibility only | ||
# functionality is in soc_evcc | ||
$OPENWBBASEDIR/modules/soc_evcc/main.sh 2 | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.