Skip to content

Commit

Permalink
Fix Batt_json and Values for JSON Parameters in UpdateConfig.sh (sna…
Browse files Browse the repository at this point in the history
…ptec#1074)

* Fix Batt_json and Values for UpdateConfig JSON PArameters

Batt_jason had a problem in SOC Line as htmlspecialcharacters were not masked.
It is necessary to keep jq Filter Statements in single quotes so double qoutes are not interpreted by the bash.
  • Loading branch information
DetMoerk authored Feb 18, 2021
1 parent 192d00a commit c669d0f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions runs/updateConfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -339,19 +339,19 @@ updateConfig(){
echo "evnotifytokenlp2=token" >> $ConfigFile
fi
if ! grep -Fq "wrjsonwatt=" $ConfigFile; then
echo "wrjsonwatt=.watt" >> $ConfigFile
echo "wrjsonwatt='.watt'" >> $ConfigFile
fi
if ! grep -Fq "wrjsonkwh=" $ConfigFile; then
echo "wrjsonkwh=.kwh" >> $ConfigFile
echo "wrjsonkwh='.kwh'" >> $ConfigFile
fi
if ! grep -Fq "wrjsonurl=" $ConfigFile; then
echo "wrjsonurl=http://192.168.0.12/solar_api" >> $ConfigFile
fi
if ! grep -Fq "wr2jsonwatt=" $ConfigFile; then
echo "wr2jsonwatt=.watt" >> $ConfigFile
echo "wr2jsonwatt='.watt'" >> $ConfigFile
fi
if ! grep -Fq "wr2jsonkwh=" $ConfigFile; then
echo "wr2jsonkwh=.kwh" >> $ConfigFile
echo "wr2jsonkwh='.kwh'" >> $ConfigFile
fi
if ! grep -Fq "wr2jsonurl=" $ConfigFile; then
echo "wr2jsonurl=http://192.168.0.12/solar_api" >> $ConfigFile
Expand All @@ -378,13 +378,13 @@ updateConfig(){
echo "mpm3pmpvlanip=192.168.1.12" >> $ConfigFile
fi
if ! grep -Fq "bezugjsonwatt=" $ConfigFile; then
echo "bezugjsonwatt=.watt" >> $ConfigFile
echo "bezugjsonwatt='.watt'" >> $ConfigFile
fi
if ! grep -Fq "bezugjsonkwh=" $ConfigFile; then
echo "bezugjsonkwh=.kwh" >> $ConfigFile
echo "bezugjsonkwh='.kwh'" >> $ConfigFile
fi
if ! grep -Fq "einspeisungjsonkwh=" $ConfigFile; then
echo "einspeisungjsonkwh=.kwh" >> $ConfigFile
echo "einspeisungjsonkwh='.kwh'" >> $ConfigFile
fi
if ! grep -Fq "bezugjsonurl=" $ConfigFile; then
echo "bezugjsonurl=http://192.168.0.12/solar_api" >> $ConfigFile
Expand Down Expand Up @@ -445,10 +445,10 @@ updateConfig(){
echo "battjsonurl=192.168.0.10/speicher" >> $ConfigFile
fi
if ! grep -Fq "battjsonsoc"=" $ConfigFile; then
echo "speichersoc_json=.RSOC" >> $ConfigFile
echo "speichersoc_json='.RSOC'" >> $ConfigFile
fi
if ! grep -Fq "battjsonwatt"=" $ConfigFile; then
echo "battjsonwatt=.Consumption_W" >> $ConfigFile
echo "battjsonwatt='.Consumption_Wi'" >> $ConfigFile
fi
if ! grep -Fq "soc_tesla_username=" $ConfigFile; then
echo "[email protected]" >> $ConfigFile
Expand Down
2 changes: 1 addition & 1 deletion web/settings/modulconfigbat.php
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ function getCookie(cname) {
<div class="form-row mb-1">
<label for="battjsonsoc" class="col-md-4 col-form-label">Json Abfrage für SoC</label>
<div class="col">
<input class="form-control" type="text" name="battjsonsoc" id="battjsonsoc" value="<?php echo $battjsonsocold ?>">
<input class="form-control" type="text" name="battjsonsoc" id="battjsonsoc" value="<?php echo htmlspecialchars($battjsonsocold) ?>">
<span class="form-text small">
Der hier eingetragene Befehl reduziert die Json Abfrage auf das wesentliche. Im Hintergrund wird der Befehl jq benutzt.<br>
Ist die Json Antwort z.B. <span class="text-info">{"PowerInstalledPeak":4655, "PowerProduced":132, "PowerOut":897.08172362555717, "PowerSelfSupplied":234.9182763744428}</span>
Expand Down

0 comments on commit c669d0f

Please sign in to comment.