Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Commit

Permalink
add rfid tags to ladelog, mpm3pm to evu kit pv modul, sdm120 verbrauc…
Browse files Browse the repository at this point in the history
…her wh fix, add verbraucher to live graph
  • Loading branch information
snaptec committed Jul 1, 2019
1 parent 83e061b commit 4ed0360
Show file tree
Hide file tree
Showing 23 changed files with 422 additions and 62 deletions.
32 changes: 28 additions & 4 deletions graphing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,35 @@ echo $ladeleistung >> /var/www/html/openWB/ramdisk/ev-live.graph
echo $soc >> /var/www/html/openWB/ramdisk/soc-live.graph
date +%H:%M >> /var/www/html/openWB/ramdisk/time-live.graph
echo $hausverbrauch >> /var/www/html/openWB/ramdisk/hausverbrauch-live.graph
if (( verbraucher1_aktiv == 1 )); then
echo $verbraucher1_watt >> /var/www/html/openWB/ramdisk/verbraucher1-live.graph
fi
if (( verbraucher2_aktiv == 1 )); then
echo $verbraucher2_watt >> /var/www/html/openWB/ramdisk/verbraucher2-live.graph
fi


if [[ $livegraph =~ $re ]] ; then
livegraph=$((livegraph * 6 ))
if ! [[ $livegraph =~ $re ]] ; then
livegraph="30"
fi
fi
echo $(date +%H:%M:%S),$wattbezugint,$ladeleistung,$pvgraph,$ladeleistunglp1,$ladeleistunglp2,$ladeleistung,$speicherleistung,$speichersoc,$soc,$soc1,$hausverbrauch >> /var/www/html/openWB/ramdisk/all-live.graph
echo $(date +%H:%M:%S),$wattbezugint,$ladeleistung,$pvgraph,$ladeleistunglp1,$ladeleistunglp2,$ladeleistung,$speicherleistung,$speichersoc,$soc,$soc1,$hausverbrauch > /var/www/html/openWB/ramdisk/all-live.graph?incremental=y
echo $(date +%H:%M:%S),$wattbezugint,$ladeleistung,$pvgraph,$ladeleistunglp1,$ladeleistunglp2,$ladeleistung,$speicherleistung,$speichersoc,$soc,$soc1,$hausverbrauch,$verbraucher1_watt,$verbraucher2_watt >> /var/www/html/openWB/ramdisk/all-live.graph
echo $(date +%H:%M:%S),$wattbezugint,$ladeleistung,$pvgraph,$ladeleistunglp1,$ladeleistunglp2,$ladeleistung,$speicherleistung,$speichersoc,$soc,$soc1,$hausverbrauch,$verbraucher1_watt,$verbraucher2_watt > /var/www/html/openWB/ramdisk/all-live.graph?incremental=y
echo "$(tail -$livegraph /var/www/html/openWB/ramdisk/all-live.graph)" > /var/www/html/openWB/ramdisk/all-live.graph
echo "$(tail -$livegraph /var/www/html/openWB/ramdisk/hausverbrauch-live.graph)" > /var/www/html/openWB/ramdisk/hausverbrauch-live.graph
echo "$(tail -$livegraph /var/www/html/openWB/ramdisk/pv-live.graph)" > /var/www/html/openWB/ramdisk/pv-live.graph
echo "$(tail -$livegraph /var/www/html/openWB/ramdisk/soc-live.graph)" > /var/www/html/openWB/ramdisk/soc-live.graph
echo "$(tail -$livegraph /var/www/html/openWB/ramdisk/evu-live.graph)" > /var/www/html/openWB/ramdisk/evu-live.graph
echo "$(tail -$livegraph /var/www/html/openWB/ramdisk/ev-live.graph)" > /var/www/html/openWB/ramdisk/ev-live.graph
echo "$(tail -$livegraph /var/www/html/openWB/ramdisk/ev1-live.graph)" > /var/www/html/openWB/ramdisk/ev1-live.graph
if (( verbraucher1_aktiv == 1 )); then
echo "$(tail -$livegraph /var/www/html/openWB/ramdisk/verbraucher1-live.graph)" > /var/www/html/openWB/ramdisk/verbraucher1-live.graph
fi
if (( verbraucher2_aktiv == 1 )); then
echo "$(tail -$livegraph /var/www/html/openWB/ramdisk/verbraucher2-live.graph)" > /var/www/html/openWB/ramdisk/verbraucher2-live.graph
fi
if (( lastmanagement == 1 )); then
echo "$(tail -$livegraph /var/www/html/openWB/ramdisk/ev2-live.graph)" > /var/www/html/openWB/ramdisk/ev2-live.graph
fi
Expand Down Expand Up @@ -68,6 +81,12 @@ if (( graphtimer == 1 )); then
if (( lastmanagement == 1 )); then
echo $ladeleistunglp2 >> /var/www/html/openWB/ramdisk/ev2.graph
fi
if (( verbraucher1_aktiv == 1 )); then
echo $verbraucher1_watt >> /var/www/html/openWB/ramdisk/verbraucher1.graph
fi
if (( verbraucher2_aktiv == 1 )); then
echo $verbraucher2_watt >> /var/www/html/openWB/ramdisk/verbraucher2.graph
fi
if (( dpseed == "3" )); then
livegraphtime="240"
else
Expand All @@ -80,7 +99,12 @@ if (( graphtimer == 1 )); then
echo "$(tail -$livegraphtime /var/www/html/openWB/ramdisk/ev.graph)" > /var/www/html/openWB/ramdisk/ev.graph
echo "$(tail -$livegraphtime /var/www/html/openWB/ramdisk/ev1.graph)" > /var/www/html/openWB/ramdisk/ev1.graph
echo "$(tail -$livegraphtime /var/www/html/openWB/ramdisk/hausverbrauch.graph)" > /var/www/html/openWB/ramdisk/hausverbrauch.graph

if (( verbraucher1_aktiv == 1 )); then
echo "$(tail -$livegraph /var/www/html/openWB/ramdisk/verbraucher1.graph)" > /var/www/html/openWB/ramdisk/verbraucher1.graph
fi
if (( verbraucher2_aktiv == 1 )); then
echo "$(tail -$livegraph /var/www/html/openWB/ramdisk/verbraucher2.graph)" > /var/www/html/openWB/ramdisk/verbraucher2.graph
fi
if (( lastmanagement == 1 )); then
echo "$(tail -$livegraphtime /var/www/html/openWB/ramdisk/ev2.graph)" > /var/www/html/openWB/ramdisk/ev2.graph
fi
Expand All @@ -93,7 +117,7 @@ if (( graphtimer == 1 )); then
echo "$(tail -$livegraphtime /var/www/html/openWB/ramdisk/soc1.graph)" > /var/www/html/openWB/ramdisk/soc1.graph
fi
#beta testing
echo $(date +%H:%M:%S),$wattbezugint,$ladeleistung,$pvgraph,$ladeleistunglp1,$ladeleistunglp2,$ladeleistung,$speicherleistung,$speichersoc,$soc,$soc1,$hausverbrauch >> /var/www/html/openWB/ramdisk/all.graph
echo $(date +%H:%M:%S),$wattbezugint,$ladeleistung,$pvgraph,$ladeleistunglp1,$ladeleistunglp2,$ladeleistung,$speicherleistung,$speichersoc,$soc,$soc1,$hausverbrauch,$verbraucher1_watt,$verbraucher2_watt >> /var/www/html/openWB/ramdisk/all.graph
echo "$(tail -$livegraphtime /var/www/html/openWB/ramdisk/all.graph)" > /var/www/html/openWB/ramdisk/all.graph
#end beta testing

Expand Down
51 changes: 25 additions & 26 deletions hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,14 @@ if (( verbraucher1_aktiv == "1")); then
if [[ $verbraucher1_typ == "http" ]]; then
verbraucher1_watt=$(curl --connect-timeout 3 -s $verbraucher1_urlw )
rekwh='^[-+]?[0-9]+\.?[0-9]*$'
if ! [[ $verbraucher1_watt =~ $rekwh ]] ; then
verbraucher1_watt="0"
if ! [[ $verbraucher1_watt == $rekwh ]] ; then
echo $verbraucher1_watt > /var/www/html/openWB/ramdisk/verbraucher1_watt
fi
echo $verbraucher1_watt > /var/www/html/openWB/ramdisk/verbraucher1_watt
verbraucher1_wh=$(curl --connect-timeout 3 -s $verbraucher1_urlh &)
if ! [[ $verbraucher1_wh =~ $rekwh ]] ; then
verbraucher1_wh="0"
if ! [[ $verbraucher1_wh == $rekwh ]] ; then
echo $verbraucher1_wh > /var/www/html/openWB/ramdisk/verbraucher1_wh
fi
echo $verbraucher1_wh > /var/www/html/openWB/ramdisk/verbraucher1_wh

fi
if [[ $verbraucher1_typ == "mpm3pm" ]]; then
if [[ $verbraucher1_source == *"dev"* ]]; then
Expand All @@ -140,34 +139,32 @@ if (( verbraucher1_aktiv == "1")); then
verbraucher1_out=$(curl --connect-timeout 3 -s $verbraucher1_ip/cm?cmnd=Status%208 )
rekwh='^[-+]?[0-9]+\.?[0-9]*$'
verbraucher1_watt=$(echo $verbraucher1_out | jq '.StatusSNS.ENERGY.Power')
if ! [[ $verbraucher1_watt =~ $rekwh ]] ; then
verbraucher1_watt="0"
if [ ! -z "$verbraucher1_watt" ]; then
if ! [[ $verbraucher1_watt == $rekwh ]] ; then
echo $verbraucher1_watt > /var/www/html/openWB/ramdisk/verbraucher1_watt
fi
fi
echo $verbraucher1_watt > /var/www/html/openWB/ramdisk/verbraucher1_watt
verbraucher1_wh=$(echo $verbraucher1_out | jq '.StatusSNS.ENERGY.Total')
verbraucher1_totalwh=$(echo "scale=0;(($verbraucher1_wh * 1000) + $verbraucher1_tempwh) / 1" | bc)
if ! [[ $verbraucher1_totalwh =~ $rekwh ]] ; then
verbraucher1_totalwh="0"
if [ ! -z "$verbraucher1_totalwh" ]; then
if ! [[ $verbraucher1_totalwh == $rekwh ]] ; then
echo $verbraucher1_totalwh > /var/www/html/openWB/ramdisk/verbraucher1_wh
fi
fi
echo $verbraucher1_totalwh > /var/www/html/openWB/ramdisk/verbraucher1_wh
fi


fi
if (( verbraucher2_aktiv == "1")); then
echo "1" > /var/www/html/openWB/ramdisk/verbraucher2vorhanden
if [[ $verbraucher2_typ == "http" ]]; then
verbraucher2_watt=$(curl --connect-timeout 3 -s $verbraucher2_urlw )
rekwh='^[-+]?[0-9]+\.?[0-9]*$'
if ! [[ $verbraucher2_watt =~ $rekwh ]] ; then
verbraucher2_watt="0"
if ! [[ $verbraucher2_watt == $rekwh ]] ; then
echo $verbraucher2_watt > /var/www/html/openWB/ramdisk/verbraucher2_watt
fi
echo $verbraucher2_watt > /var/www/html/openWB/ramdisk/verbraucher2_watt
verbraucher2_wh=$(curl --connect-timeout 3 -s $verbraucher2_urlh &)
if ! [[ $verbraucher2_wh =~ $rekwh ]] ; then
verbraucher2_wh="0"
if ! [[ $verbraucher2_wh == $rekwh ]] ; then
echo $verbraucher2_wh > /var/www/html/openWB/ramdisk/verbraucher2_wh
fi
echo $verbraucher2_wh > /var/www/html/openWB/ramdisk/verbraucher2_wh
fi
if [[ $verbraucher2_typ == "mpm3pm" ]]; then
if [[ $verbraucher2_source == *"dev"* ]]; then
Expand All @@ -187,16 +184,18 @@ if (( verbraucher2_aktiv == "1")); then
verbraucher2_out=$(curl --connect-timeout 3 -s $verbraucher2_ip/cm?cmnd=Status%208 )
rekwh='^[-+]?[0-9]+\.?[0-9]*$'
verbraucher2_watt=$(echo $verbraucher2_out | jq '.StatusSNS.ENERGY.Power')
if ! [[ $verbraucher1_watt =~ $rekwh ]] ; then
verbraucher2_watt="0"
if [ ! -z "$verbraucher2_watt" ]; then
if ! [[ $verbraucher2_watt == $rekwh ]] ; then
echo $verbraucher2_watt > /var/www/html/openWB/ramdisk/verbraucher2_watt
fi
fi
echo $verbraucher2_watt > /var/www/html/openWB/ramdisk/verbraucher2_watt
verbraucher2_wh=$(echo $verbraucher2_out | jq '.StatusSNS.ENERGY.Total')
verbraucher2_totalwh=$(echo "scale=0;(($verbraucher2_wh * 1000) + $verbraucher2_tempwh) / 1" | bc)
if ! [[ $verbraucher2_totalwh =~ $rekwh ]] ; then
verbraucher2_totalwh="0"
if [ ! -z "$verbraucher2_totalwh" ]; then
if ! [[ $verbraucher2_totalwh == $rekwh ]] ; then
echo $verbraucher2_totalwh > /var/www/html/openWB/ramdisk/verbraucher2_wh
fi
fi
echo $verbraucher2_totalwh > /var/www/html/openWB/ramdisk/verbraucher2_wh
echo 0 > /var/www/html/openWB/ramdisk/verbraucher2_whe
fi

Expand Down
6 changes: 4 additions & 2 deletions ladelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ soc=$(<ramdisk/soc)
soc1=$(<ramdisk/soc1)
nachtladenstate=$(</var/www/html/openWB/ramdisk/nachtladenstate)
nachtladen2state=$(</var/www/html/openWB/ramdisk/nachtladen2state)
rfidlp1=$(<ramdisk/rfidlp1)
rfidlp2=$(<ramdisk/rfidlp2)
if (( nachtladenstate == 0 )) || (( nachtladen2state == 0 )); then
lmodus=$(</var/www/html/openWB/ramdisk/lademodus)
else
Expand Down Expand Up @@ -83,7 +85,7 @@ else
if (( ladedauer > 60 )); then
ladedauerh=$((ladedauer / 60))
laderest=$((ladedauer % 60))
sed -i '1i'$start,$jetzt,$gelrlp1,$bishergeladen,$ladegeschw,$ladedauerh' H '$laderest' Min,1',$lademodus web/ladelog
sed -i '1i'$start,$jetzt,$gelrlp1,$bishergeladen,$ladegeschw,$ladedauerh' H '$laderest' Min,1',$lademodus,$rfidlp1 web/ladelog
if ((pushbenachrichtigung == "1")) ; then
if ((pushbstopl == "1")) ; then
./runs/pushover.sh "$lp1name Ladung gestoppt. $bishergeladen kWh in $ladedauerh H $laderest Min mit durchschnittlich $ladegeschw kW geladen$soctext"
Expand Down Expand Up @@ -169,7 +171,7 @@ else
if (( ladedauers1 > 60 )); then
ladedauerhs1=$((ladedauers1 / 60))
laderests1=$((ladedauers1 % 60))
sed -i '1i'$starts1,$jetzts1,$gelrlp2,$bishergeladens1,$ladegeschws1,$ladedauerhs1' H '$laderests1' Min,2',$lademodus web/ladelog
sed -i '1i'$starts1,$jetzts1,$gelrlp2,$bishergeladens1,$ladegeschws1,$ladedauerhs1' H '$laderests1' Min,2',$lademodus,$rfidlp2 web/ladelog
if ((pushbenachrichtigung == "1")) ; then
if ((pushbstopl == "1")) ; then
./runs/pushover.sh "$lp2name Ladung gestoppt. $bishergeladens1 kWh in $ladedauerhs1 H $laderests1 Min mit durchschnittlich $ladegeschws1 kW geladen$soctext1"
Expand Down
2 changes: 1 addition & 1 deletion loadvars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ else
lla1=0
lla2=0
lla3=0
ladeleistung=800
ladeleistung=0
llkwh=0
llkwhges=$llkwh
fi
Expand Down
13 changes: 8 additions & 5 deletions modules/verbraucher/sdm120remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,24 @@

resp = client.read_input_registers(0x0048,2, unit=sdmid)
vwh = struct.unpack('>f',struct.pack('>HH',*resp.registers))
vwh = float("%.3f" % vwh[0])

vwh1 = vwh.split(",")[0]
vwh2 = float(vwh1) * int(1000)
vwh3 = str(vwh2)
vwhstring = "/var/www/html/openWB/ramdisk/verbraucher%s_wh" % (verbrauchernr)
f = open(vwhstring, 'w')
f.write(str(vwh))
f.write(str(vwh3))
f.close()


resp = client.read_input_registers(0x004a,2, unit=sdmid)
vwhe = struct.unpack('>f',struct.pack('>HH',*resp.registers))
vwhe = float("%.3f" % vwhe[0])
vwhe1 = vwhe.split(",")[0]
vwhe2 = float(vwhe1) * int(1000)
vwhe3 = str(vwhe2)

vwhestring = "/var/www/html/openWB/ramdisk/verbraucher%s_whe" % (verbrauchernr)
f = open(vwhestring, 'w')
f.write(str(vwhe))
f.write(str(vwhe3))
f.close()


Expand Down
8 changes: 8 additions & 0 deletions modules/wr_ethmpm3pmaevu/main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
. /var/www/html/openWB/openwb.conf

sudo python /var/www/html/openWB/modules/wr_ethmpm3pmaevu/readmpm3pm.py
pvwatt=$(</var/www/html/openWB/ramdisk/pvwatt)
echo $pvwatt


61 changes: 61 additions & 0 deletions modules/wr_ethmpm3pmaevu/readmpm3pm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/python
import sys
import os
import time
import getopt
import struct
from pymodbus.client.sync import ModbusTcpClient
client = ModbusTcpClient('192.168.193.15', port=8899)
#from pymodbus.transaction import ModbusRtuFramer
#client = ModbusTcpClient('192.168.0.7', port=8899, framer=ModbusRtuFramer)





######
resp = client.read_input_registers(0x0004,4, unit=8)
value1 = resp.registers[0]
value2 = resp.registers[1]
all = format(value1, '04x') + format(value2, '04x')
ikwh = int(struct.unpack('>i', all.decode('hex'))[0])

#resp = client.read_input_registers(0x0004,2, unit=sdmid)
#ikwh = resp.registers[1]
ikwh = float(ikwh) * 10
f = open('/var/www/html/openWB/ramdisk/pvkwh', 'w')
f.write(str(ikwh))
f.close()

resp = client.read_input_registers(0x0E,2, unit=8)
lla1 = resp.registers[1]
lla1 = float(lla1) / 100
f = open('/var/www/html/openWB/ramdisk/pva1', 'w')
f.write(str(lla1))
f.close()

resp = client.read_input_registers(0x10,2, unit=8)
lla2 = resp.registers[1]
lla2 = float(lla2) / 100
f = open('/var/www/html/openWB/ramdisk/pva2', 'w')
f.write(str(lla2))
f.close()

resp = client.read_input_registers(0x12,2, unit=8)
lla3 = resp.registers[1]
lla3 = float(lla3) / 100
f = open('/var/www/html/openWB/ramdisk/pva3', 'w')
f.write(str(lla3))
f.close()

#total watt
resp = client.read_input_registers(0x26,2, unit=8)
value1 = resp.registers[0]
value2 = resp.registers[1]
all = format(value1, '04x') + format(value2, '04x')
final = int(struct.unpack('>i', all.decode('hex'))[0]) / 100
f = open('/var/www/html/openWB/ramdisk/pvwatt', 'w')
f.write(str(final))
f.close()


10 changes: 8 additions & 2 deletions regel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ source evsedintest.sh
source hook.sh
source u1p3p.sh
source nrgkickcheck.sh
source rfidtag.sh
date=$(date)
re='^-?[0-9]+$'
#ladelog ausfuehren
Expand Down Expand Up @@ -78,6 +79,10 @@ fi


#######################################
# check rfid
if [[ $rfidakt == "1" ]]; then
rfid
fi
#goe mobility check
goecheck
# nrgkick mobility check
Expand All @@ -100,6 +105,8 @@ evsedintest

#u1p3p switch
u1p3pswitch
#hooks - externe geraete
hook
#Graphing
graphing

Expand All @@ -120,8 +127,7 @@ if [[ $dspeed == "3" ]]; then
echo 0 > ramdisk/5sec
fi
fi
#hooks - externe geraete
hook


#evse modbus check
evsemodbustimer=$(<ramdisk/evsemodbustimer)
Expand Down
15 changes: 15 additions & 0 deletions rfidtag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

rfid() {
lasttag=$(<ramdisk/readtag)
if [[ $lasttag != "0" ]]; then
if [ $lasttag == $rfidlp1c1 ] || [ $lasttag == $rfidlp1c2 ] || [ $lasttag == $rfidlp1c3 ] ; then
echo $lasttag > ramdisk/rfidlp1
fi
if [ $lasttag == $rfidlp2c1 ] || [ $lasttag == $rfidlp2c2 ] || [ $lasttag == $rfidlp2c3 ] ; then
echo $lasttag > ramdisk/rfidlp2
fi
echo $lasttag > ramdisk/rfidlasttag
echo 0 > ramdisk/readtag
fi
}
10 changes: 9 additions & 1 deletion runs/atreboot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ echo 0 > /var/www/html/openWB/ramdisk/progevsedinlp12000
echo 0 > /var/www/html/openWB/ramdisk/progevsedinlp12007
echo 0 > /var/www/html/openWB/ramdisk/progevsedinlp22000
echo 0 > /var/www/html/openWB/ramdisk/progevsedinlp22007
echo 0 > /var/www/html/openWB/ramdisk/readtag
echo 0 > /var/www/html/openWB/ramdisk/rfidlp1
echo 0 > /var/www/html/openWB/ramdisk/rfidlp2


touch /var/www/html/openWB/ramdisk/wattbezug
touch /var/www/html/openWB/ramdisk/ladestatus
touch /var/www/html/openWB/ramdisk/lademodus
Expand Down Expand Up @@ -1445,7 +1450,10 @@ if ! grep -Fq "httpll_a3_url=" /var/www/html/openWB/openwb.conf
then
echo "httpll_a3_url='http://url'" >> /var/www/html/openWB/openwb.conf
fi

if ! grep -Fq "rfidakt=" /var/www/html/openWB/openwb.conf
then
echo "rfidakt=0" >> /var/www/html/openWB/openwb.conf
fi


ethstate=$(</sys/class/net/eth0/carrier)
Expand Down
Loading

0 comments on commit 4ed0360

Please sign in to comment.