Skip to content

Commit

Permalink
Merge pull request snaptec#36 from snaptec/master
Browse files Browse the repository at this point in the history
Release 1.0
  • Loading branch information
snaptec authored Nov 25, 2018
2 parents 03bb23e + 76441bf commit 324bb96
Show file tree
Hide file tree
Showing 163 changed files with 2,159 additions and 4,578 deletions.
3 changes: 1 addition & 2 deletions ladelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ if (( ladeleistungs2 > 500 )); then
gelrlp3=$(echo "scale=3;$bishergeladens2 / $durchslp3 * 100" |bc)
gelrlp3=${gelrlp3%.*}
echo $gelrlp3 > ramdisk/gelrlp3
restzeitlp3=$(echo "scale=5;($lademkwhs2 - $bishergeladens2)/ $ladeleistungs2 * 1000" |bc)
restzeitlp3=$(echo "scale=6;($lademkwhs2 - $bishergeladens2)/ $ladeleistungs2 * 1000 * 60" |bc)
restzeitlp3=${restzeitlp3%.*}
if (( restzeitlp3 > 60 )); then
restzeitlp3h=$((restzeitlp3 / 60))
Expand All @@ -141,7 +141,6 @@ if (( ladeleistungs2 > 500 )); then
else
echo "$restzeitlp3 Min" > ramdisk/restzeitlp3
fi

else
touch ramdisk/ladeustarts2
echo -e $(date +%d.%m.%y-%H:%M) > ramdisk/ladeustarts2
Expand Down
8 changes: 8 additions & 0 deletions modules/bezug_solaredge/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/bezug_solaredge/solaredge.py $solaredgeip
wattbezug=$(</var/www/html/openWB/ramdisk/wattbezug)
echo $wattbezug
75 changes: 75 additions & 0 deletions modules/bezug_solaredge/solaredge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/python
import sys
import os
import time
import getopt
import socket
import ConfigParser
import struct
import binascii
ipaddress = str(sys.argv[1])
from pymodbus.client.sync import ModbusTcpClient
client = ModbusTcpClient(ipaddress, port=502)


resp= client.read_holding_registers(40206,1,unit=1)
value1 = resp.registers[0]
all = format(value1, '04x')
final = int(struct.unpack('>h', all.decode('hex'))[0]) * -1
f = open('/var/www/html/openWB/ramdisk/wattbezug', 'w')
f.write(str(final))
f.close()

resp= client.read_holding_registers(40084,2,unit=1)
multipli = resp.registers[0]
multiplint = format(multipli, '04x')
fmultiplint = int(struct.unpack('>h', multiplint.decode('hex'))[0])

respw= client.read_holding_registers(40083,2,unit=1)
value1w = respw.registers[0]
allw = format(value1w, '04x')
rawprodw = finalw = int(struct.unpack('>h', allw.decode('hex'))[0]) * -1
if fmultiplint == -1:
rawprodw = rawprodw / 10
if fmultiplint == -2:
rawprodw = rawprodw / 100
if fmultiplint == -3:
rawprodw = rawprodw / 1000
if fmultiplint == -4:
rawprodw = rawprodw / 10000
f = open('/var/www/html/openWB/ramdisk/pvwatt', 'w')
f.write(str(rawprodw))
f.close()

resp= client.read_holding_registers(40093,2,unit=1)
value1 = resp.registers[0]
value2 = resp.registers[1]
all = format(value1, '04x') + format(value2, '04x')
final = int(struct.unpack('>i', all.decode('hex'))[0])
f = open('/var/www/html/openWB/ramdisk/pvkwh', 'w')
f.write(str(final))
f.close()
pvkwhk= final / 1000
f = open('/var/www/html/openWB/ramdisk/pvkwhk', 'w')
f.write(str(pvkwhk))
f.close()


resp= client.read_holding_registers(40234,2,unit=1)
value1 = resp.registers[0]
value2 = resp.registers[1]
all = format(value1, '04x') + format(value2, '04x')
final = int(struct.unpack('>i', all.decode('hex'))[0])
f = open('/var/www/html/openWB/ramdisk/bezugkwh', 'w')
f.write(str(final))
f.close()

resp= client.read_holding_registers(40226,2,unit=1)
value1 = resp.registers[0]
value2 = resp.registers[1]
all = format(value1, '04x') + format(value2, '04x')
final = int(struct.unpack('>i', all.decode('hex'))[0])
f = open('/var/www/html/openWB/ramdisk/einspeisungkwh', 'w')
f.write(str(final))
f.close()

46 changes: 46 additions & 0 deletions modules/goelp1/main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
. /var/www/html/openWB/openwb.conf
re='^-?[0-9]+$'
rekwh='^[-+]?[0-9]+\.?[0-9]*$'

output=$(curl --connect-timeout $goetimeoutlp1 -s http://$goeiplp1/status)
if [[ $? == "0" ]] ; then
watt=$(echo $output | jq -r '.nrg[11]')
watt=$(echo "scale=0;$watt * 10 /1" |bc)
if [[ $watt =~ $re ]] ; then
echo $watt > /var/www/html/openWB/ramdisk/llaktuell
fi
lla1=$(echo $output | jq -r '.nrg[4]')
lla1=$(echo "scale=0;$lla1 / 10" |bc)
if [[ $lla1 =~ $re ]] ; then
echo $lla1 > /var/www/html/openWB/ramdisk/lla1
fi
lla2=$(echo $output | jq -r '.nrg[5]')
lla2=$(echo "scale=0;$lla2 / 10" |bc)
if [[ $lla2 =~ $re ]] ; then
echo $lla2 > /var/www/html/openWB/ramdisk/lla2
fi
lla3=$(echo $output | jq -r '.nrg[6]')
lla3=$(echo "scale=0;$lla3 / 10" |bc)
if [[ $lla3 =~ $re ]] ; then
echo $lla3 > /var/www/html/openWB/ramdisk/lla3
fi
llv1=$(echo $output | jq -r '.nrg[0]')
if [[ $lla1 =~ $re ]] ; then
echo $llv1 > /var/www/html/openWB/ramdisk/llv1
fi
llv2=$(echo $output | jq -r '.nrg[1]')
if [[ $lla2 =~ $re ]] ; then
echo $llv2 > /var/www/html/openWB/ramdisk/llv2
fi
llv3=$(echo $output | jq -r '.nrg[2]')
if [[ $lla3 =~ $re ]] ; then
echo $llv3 > /var/www/html/openWB/ramdisk/llv3
fi

llkwh=$(echo $output | jq -r '.eto')
llkwh=$(echo "scale=3;$llkwh / 10" |bc)
if [[ $llkwh =~ $rekwh ]] ; then
echo $llkwh > /var/www/html/openWB/ramdisk/llkwh
fi
fi
46 changes: 46 additions & 0 deletions modules/goelp2/main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
. /var/www/html/openWB/openwb.conf
re='^-?[0-9]+$'
rekwh='^[-+]?[0-9]+\.?[0-9]*$'

output=$(curl --connect-timeout $goetimeoutlp2 -s http://$goeiplp2/status)
if [[ $? == "0" ]] ; then
watt=$(echo $output | jq -r '.nrg[11]')
watt=$(echo "scale=0;$watt * 10 /1" |bc)
if [[ $watt =~ $re ]] ; then
echo $watt > /var/www/html/openWB/ramdisk/llaktuells1
fi
lla1=$(echo $output | jq -r '.nrg[4]')
lla1=$(echo "scale=0;$lla1 / 10" |bc)
if [[ $lla1 =~ $re ]] ; then
echo $lla1 > /var/www/html/openWB/ramdisk/llas11
fi
lla2=$(echo $output | jq -r '.nrg[5]')
lla2=$(echo "scale=0;$lla2 / 10" |bc)
if [[ $lla2 =~ $re ]] ; then
echo $lla2 > /var/www/html/openWB/ramdisk/llas12
fi
lla3=$(echo $output | jq -r '.nrg[6]')
lla3=$(echo "scale=0;$lla3 / 10" |bc)
if [[ $lla3 =~ $re ]] ; then
echo $lla3 > /var/www/html/openWB/ramdisk/llas13
fi
llv1=$(echo $output | jq -r '.nrg[0]')
if [[ $lla1 =~ $re ]] ; then
echo $llv1 > /var/www/html/openWB/ramdisk/llvs11
fi
llv2=$(echo $output | jq -r '.nrg[1]')
if [[ $lla2 =~ $re ]] ; then
echo $llv2 > /var/www/html/openWB/ramdisk/llvs12
fi
llv3=$(echo $output | jq -r '.nrg[2]')
if [[ $lla3 =~ $re ]] ; then
echo $llv3 > /var/www/html/openWB/ramdisk/llvs13
fi

llkwh=$(echo $output | jq -r '.eto')
llkwh=$(echo "scale=3;$llkwh / 10" |bc)
if [[ $llkwh =~ $rekwh ]] ; then
echo $llkwh > /var/www/html/openWB/ramdisk/llkwhs1
fi
fi
46 changes: 46 additions & 0 deletions modules/goelp3/main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
. /var/www/html/openWB/openwb.conf
re='^-?[0-9]+$'
rekwh='^[-+]?[0-9]+\.?[0-9]*$'

output=$(curl --connect-timeout $goetimeoutlp3 -s http://$goeiplp3/status)
if [[ $? == "0" ]] ; then
watt=$(echo $output | jq -r '.nrg[11]')
watt=$(echo "scale=0;$watt * 10 /1" |bc)
if [[ $watt =~ $re ]] ; then
echo $watt > /var/www/html/openWB/ramdisk/llaktuells2
fi
lla1=$(echo $output | jq -r '.nrg[4]')
lla1=$(echo "scale=0;$lla1 / 10" |bc)
if [[ $lla1 =~ $re ]] ; then
echo $lla1 > /var/www/html/openWB/ramdisk/llas21
fi
lla2=$(echo $output | jq -r '.nrg[5]')
lla2=$(echo "scale=0;$lla2 / 10" |bc)
if [[ $lla2 =~ $re ]] ; then
echo $lla2 > /var/www/html/openWB/ramdisk/llas22
fi
lla3=$(echo $output | jq -r '.nrg[6]')
lla3=$(echo "scale=0;$lla3 / 10" |bc)
if [[ $lla3 =~ $re ]] ; then
echo $lla3 > /var/www/html/openWB/ramdisk/llas23
fi
llv1=$(echo $output | jq -r '.nrg[0]')
if [[ $lla1 =~ $re ]] ; then
echo $llv1 > /var/www/html/openWB/ramdisk/llvs21
fi
llv2=$(echo $output | jq -r '.nrg[1]')
if [[ $lla2 =~ $re ]] ; then
echo $llv2 > /var/www/html/openWB/ramdisk/llvs22
fi
llv3=$(echo $output | jq -r '.nrg[2]')
if [[ $lla3 =~ $re ]] ; then
echo $llv3 > /var/www/html/openWB/ramdisk/llvs23
fi

llkwh=$(echo $output | jq -r '.eto')
llkwh=$(echo "scale=3;$llkwh / 10" |bc)
if [[ $llkwh =~ $rekwh ]] ; then
echo $llkwh > /var/www/html/openWB/ramdisk/llkwhs2
fi
fi
10 changes: 5 additions & 5 deletions modules/sdm120modbusll/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ rekwh='^[-+]?[0-9]+\.?[0-9]*$'

if [[ $modbusevsesource = *virtual* ]]
then
if ps ax |grep -v grep |grep "socat pty,link=$modbusevsesource,raw tcp:$modbusevselanip:26" > /dev/null
if ps ax |grep -v grep |grep "socat pty,link=$sdm630modbusllsource,raw tcp:$sdm630modbuslllanip:26" > /dev/null
then
echo "test" > /dev/null
else
sudo socat pty,link=$modbusevsesource,raw tcp:$modbusevselanip:26 &
sudo socat pty,link=$sdm630modbusllsource,raw tcp:$sdm630modbuslllanip:26 &
fi
else
echo "echo" > /dev/null
fi

if [[ $sdm120modbusllid1 != "none" ]] && [[ $sdm120modbusllid2 != "none" ]] && [[ $sdm120modbusllid3 != "none" ]] ; then
n=0
output=$(sudo python /var/www/html/openWB/modules/sdm120modbusll/readsdm3.py $modbusevsesource $sdm120modbusllid1 $sdm120modbusllid2 $sdm120modbusllid3)
output=$(sudo python /var/www/html/openWB/modules/sdm120modbusll/readsdm3.py $sdm630modbusllsource $sdm120modbusllid1 $sdm120modbusllid2 $sdm120modbusllid3)
while read -r line; do
if (( $n == 0 )); then
llv1=$(echo "$line" | cut -c2- )
Expand Down Expand Up @@ -99,7 +99,7 @@ if [[ $sdm120modbusllid1 != "none" ]] && [[ $sdm120modbusllid2 != "none" ]] && [
else
if [[ $sdm120modbusll2id != "none" ]] ; then
n=0
output=$(sudo python /var/www/html/openWB/modules/sdm120modbusll/readsdm1.py $modbusevsesource $sdm120modbusllid1)
output=$(sudo python /var/www/html/openWB/modules/sdm120modbusll/readsdm1.py $sdm630modbusllsource $sdm120modbusllid1)
while read -r line; do
if (( $n == 0 )); then
llv1=$(echo "$line" | cut -c2- )
Expand Down Expand Up @@ -131,7 +131,7 @@ else
fi
else
n=0
output=$(sudo python /var/www/html/openWB/modules/sdm120modbusll/readsdm2.py $modbusevsesource $sdm120modbusllid1 $sdm120modbusllid2)
output=$(sudo python /var/www/html/openWB/modules/sdm120modbusll/readsdm2.py $sdm630modbusllsource $sdm120modbusllid1 $sdm120modbusllid2)
while read -r line; do
if (( $n == 0 )); then
llv1=$(echo "$line" | cut -c2- )
Expand Down
4 changes: 2 additions & 2 deletions modules/sdm120modbusll/readsdm3.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
print(struct.unpack('>f',struct.pack('>HH',*resp.registers)))
resp = client.read_input_registers(0x0156,2, unit=sdmid)
print(struct.unpack('>f',struct.pack('>HH',*resp.registers)))
time.sleep(0.3)
time.sleep(0.5)
resp = client.read_input_registers(0x00,2, unit=sdm2id)
print(struct.unpack('>f',struct.pack('>HH',*resp.registers)))
resp = client.read_input_registers(0x06,2, unit=sdm2id)
Expand All @@ -38,7 +38,7 @@
print(struct.unpack('>f',struct.pack('>HH',*resp.registers)))
resp = client.read_input_registers(0x0156,2, unit=sdm2id)
print(struct.unpack('>f',struct.pack('>HH',*resp.registers)))
time.sleep(0.3)
time.sleep(0.5)
resp = client.read_input_registers(0x00,2, unit=sdm3id)
print(struct.unpack('>f',struct.pack('>HH',*resp.registers)))
resp = client.read_input_registers(0x06,2, unit=sdm3id)
Expand Down
12 changes: 6 additions & 6 deletions modules/sdm120modbuslls1/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
re='^-?[0-9]+$'
rekwh='^[-+]?[0-9]+\.?[0-9]*$'

if [[ $sdm120modbusllsources1 = *virtual* ]]
if [[ $sdm120lp2source = *virtual* ]]
then
if ps ax |grep -v grep |grep "socat pty,link=$evsesources1,raw tcp:$evselanips1:26" > /dev/null
if ps ax |grep -v grep |grep "socat pty,link=$sdm120lp2source,raw tcp:$lllaniplp2:26" > /dev/null
then
echo "test" > /dev/null
else
sudo socat pty,link=$evsesources1,raw tcp:$evselanips1:26 &
sudo socat pty,link=$sdm120lp2source,raw tcp:$lllaniplp2:26 &
fi
else
echo "echo" > /dev/null
fi

if [[ $sdm120modbusllid1s1 != "none" ]] && [[ $sdm120modbusllid2s1 != "none" ]] && [[ $sdm120modbusllid3s1 != "none" ]] ; then
n=0
output=$(sudo python /var/www/html/openWB/modules/sdm120modbuslls1/readsdm3.py $evsesources1 $sdm120modbusllid1s1 $sdm120modbusllid2s1 $sdm120modbusllid3s1)
output=$(sudo python /var/www/html/openWB/modules/sdm120modbuslls1/readsdm3.py $sdm120lp2source $sdm120modbusllid1s1 $sdm120modbusllid2s1 $sdm120modbusllid3s1)
while read -r line; do
if (( $n == 0 )); then
llv1=$(echo "$line" | cut -c2- )
Expand Down Expand Up @@ -99,7 +99,7 @@ if [[ $sdm120modbusllid1s1 != "none" ]] && [[ $sdm120modbusllid2s1 != "none" ]]
else
if [[ $sdm120modbusll2ids1 != "none" ]] ; then
n=0
output=$(sudo python /var/www/html/openWB/modules/sdm120modbuslls1/readsdm3.py $evsesources1 $sdm120modbusllid1s1 $sdm120modbusllid2s1)
output=$(sudo python /var/www/html/openWB/modules/sdm120modbuslls1/readsdm3.py $sdm120lp2source $sdm120modbusllid1s1 $sdm120modbusllid2s1)
while read -r line; do
if (( $n == 0 )); then
llv1=$(echo "$line" | cut -c2- )
Expand Down Expand Up @@ -157,7 +157,7 @@ else
fi
else
n=0
output=$(sudo python /var/www/html/openWB/modules/sdm120modbuslls1/readsdm3.py $evsesources1 $sdm120modbusllid1s1)
output=$(sudo python /var/www/html/openWB/modules/sdm120modbuslls1/readsdm3.py $sdm120lp2source $sdm120modbusllid1s1)
while read -r line; do
if (( $n == 0 )); then
llv1=$(echo "$line" | cut -c2- )
Expand Down
2 changes: 1 addition & 1 deletion modules/sdm120modbuslls1/readsdm3.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
sdmid = int(sys.argv[2])
sdm2id = int(sys.argv[3])
sdm3id = int(sys.argv[4])
time.sleep(0.2)
time.sleep(0.3)
resp = client.read_input_registers(0x00,2, unit=sdmid)
print(struct.unpack('>f',struct.pack('>HH',*resp.registers)))
time.sleep(0.1)
Expand Down
12 changes: 6 additions & 6 deletions modules/sdm120modbuslls2/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
re='^-?[0-9]+$'
rekwh='^[-+]?[0-9]+\.?[0-9]*$'

if [[ $sdm120modbusllsources2 = *virtual* ]]
if [[ $sdm120lp3source = *virtual* ]]
then
if ps ax |grep -v grep |grep "socat pty,link=$evsesources2,raw tcp:$evselanips2:26" > /dev/null
if ps ax |grep -v grep |grep "socat pty,link=$sdm120lp3source,raw tcp:$lllaniplp3:26" > /dev/null
then
echo "test" > /dev/null
else
sudo socat pty,link=$evsesources2,raw tcp:$evselanips2:26 &
sudo socat pty,link=$sdm120lp3source,raw tcp:$lllaniplp3:26 &
fi
else
echo "echo" > /dev/null
fi

if [[ $sdm120modbusllid1s2 != "none" ]] && [[ $sdm120modbusllid2s2 != "none" ]] && [[ $sdm120modbusllid3s2 != "none" ]] ; then
n=0
output=$(sudo python /var/www/html/openWB/modules/sdm120modbuslls2/readsdm3.py $evsesources2 $sdm120modbusllid1s2 $sdm120modbusllid2s2 $sdm120modbusllid3s2)
output=$(sudo python /var/www/html/openWB/modules/sdm120modbuslls2/readsdm3.py $sdm120lp3source $sdm120modbusllid1s2 $sdm120modbusllid2s2 $sdm120modbusllid3s2)
while read -r line; do
if (( $n == 0 )); then
llv1=$(echo "$line" | cut -c2- )
Expand Down Expand Up @@ -99,7 +99,7 @@ if [[ $sdm120modbusllid1s2 != "none" ]] && [[ $sdm120modbusllid2s2 != "none" ]]
else
if [[ $sdm120modbusll2ids2 != "none" ]] ; then
n=0
output=$(sudo python /var/www/html/openWB/modules/sdm120modbuslls2/readsdm3.py $evsesources2 $sdm120modbusllid1s2 $sdm120modbusllid2s2)
output=$(sudo python /var/www/html/openWB/modules/sdm120modbuslls2/readsdm3.py $sdm120lp3source $sdm120modbusllid1s2 $sdm120modbusllid2s2)
while read -r line; do
if (( $n == 0 )); then
llv1=$(echo "$line" | cut -c2- )
Expand Down Expand Up @@ -157,7 +157,7 @@ else
fi
else
n=0
output=$(sudo python /var/www/html/openWB/modules/sdm120modbuslls2/readsdm3.py $evsesources2 $sdm120modbusllid1s2)
output=$(sudo python /var/www/html/openWB/modules/sdm120modbuslls2/readsdm3.py $sdm120lp3source $sdm120modbusllid1s2)
while read -r line; do
if (( $n == 0 )); then
llv1=$(echo "$line" | cut -c2- )
Expand Down
Loading

0 comments on commit 324bb96

Please sign in to comment.