„edl21.sh“ ändern

Upload in Snapshot-Tabelle hinzugefügt - schnelleres Auslesen durch Webseite möglich.
This commit is contained in:
tilman 2020-04-16 20:35:55 +02:00
parent 25504d0b68
commit 353661ecf5

View File

@ -2,8 +2,6 @@
# edl21.sh reads data from the EDL21 electricity meter and writes it up to a MySQL/MariaDB. # edl21.sh reads data from the EDL21 electricity meter and writes it up to a MySQL/MariaDB.
# https://code.hw12.org/tilman/edl21 # https://code.hw12.org/tilman/edl21
# #
# Version 0.6 - 05.06.2019
#
# License GPL3.0 or later # License GPL3.0 or later
# https://code.hw12.org/tilman/edl21/src/branch/master/LICENSE # https://code.hw12.org/tilman/edl21/src/branch/master/LICENSE
@ -21,7 +19,8 @@ DB_USER="dbuser";
DB_PASS="dbpasswd"; DB_PASS="dbpasswd";
DB_HOST="dbhost"; DB_HOST="dbhost";
DB_NAME="dbname"; DB_NAME="dbname";
DB_TAB="dbtable"; DB_TAB="EdlData";
DB_TAB_SNAP="EdlSnapshot";
#Get date and round to nearest 5min (for harmonized use with data from other scripts in pChart) #Get date and round to nearest 5min (for harmonized use with data from other scripts in pChart)
DATE_RAW=$(/bin/date +%s); DATE_RAW=$(/bin/date +%s);
@ -105,7 +104,8 @@ echo $DATE";"$DATE_N5M";"$STRING_180";"$STRING_280";"$STRING_PWR_IN";"$STRING_PW
#Send data to database #Send data to database
mysql -u $DB_USER -p$DB_PASS -h $DB_HOST -D $DB_NAME <<EOF mysql -u $DB_USER -p$DB_PASS -h $DB_HOST -D $DB_NAME <<EOF
INSERT INTO $DB_TAB (TimeStamp,Nearest5min,zaehlerstand_in,zaehlerstand_out,active_in,active_out) VALUES ('$DATE','$DATE_N5M','$STRING_180','$STRING_280','$STRING_PWR_IN','$STRING_PWR_OUT'); INSERT INTO $DB_TAB (TimeStamp,Nearest5min,zaehlerstand_in,zaehlerstand_out,active_in,active_out) VALUES ('${DATE}','${DATE_N5M}','${STRING_180}','${STRING_280}','${STRING_PWR_IN}','${STRING_PWR_OUT}');
UPDATE $DB_TAB_SNAP SET TimeStamp='${DATE}',Nearest5min='${DATE_N5M}',zaehlerstand_in='${STRING_180}',zaehlerstand_out='${STRING_280}',active_in='${STRING_PWR_IN}',active_out='${STRING_PWR_OUT}';
EOF EOF
#Delete temporary file #Delete temporary file