From 5ee05aec621c83938bdcb2ee9ffbed2e5d0bfc9f Mon Sep 17 00:00:00 2001 From: Lutz Bender Date: Mon, 12 Jul 2021 10:17:37 +0200 Subject: [PATCH] remove unneeded imports, formating --- modules/bezug_alphaess/main.sh | 1 - modules/bezug_alphaess/readalpha.py | 18 +- modules/bezug_alphaess/readv123.py | 18 +- modules/bezug_carlogavazzilan/main.sh | 1 - modules/bezug_carlogavazzilan/readgavazzi.py | 25 +- modules/bezug_e3dc/e3dc.py | 117 ++++--- modules/bezug_ethmpm3pm/main.sh | 2 - modules/bezug_ethmpm3pm/readlovato.py | 27 +- modules/bezug_ethmpm3pm/readmpm3pm.py | 46 ++- modules/bezug_ethmpm3pm/readsdm.py | 31 +- modules/bezug_fems/main.sh | 6 - modules/bezug_fronius_s0/main.sh | 12 +- modules/bezug_http/main.sh | 10 +- modules/bezug_janitza/main.sh | 1 - modules/bezug_janitza/readjanitza.py | 15 +- modules/bezug_json/main.sh | 11 +- modules/bezug_kostalpiko/main.sh | 13 +- .../bezug_kostalplenticoreem300haus/main.sh | 28 +- modules/bezug_ksem/readksem.py | 8 +- modules/bezug_lgessv1/main.sh | 4 +- modules/bezug_mpm3pm/main.sh | 2 - modules/bezug_mpm3pm/readmpm3pm.py | 33 +- modules/bezug_powerdog/powerdog.py | 17 +- modules/bezug_powerfox/main.sh | 3 - modules/bezug_rct/main.sh | 4 +- modules/bezug_rct/rct.py | 6 +- modules/bezug_rct/rct_read.py | 6 +- modules/bezug_sbs25/main.sh | 6 - modules/bezug_sbs25/sbs25.py | 26 +- modules/bezug_siemens/main.sh | 2 - modules/bezug_siemens/siemens.py | 18 +- modules/bezug_smartfox/main.sh | 37 +- modules/bezug_smartme/main.sh | 2 +- modules/bezug_solaredge/main.sh | 2 - modules/bezug_solaredge/solaredge.py | 64 ++-- modules/bezug_solarlog/main.sh | 4 - modules/bezug_solarview/main.sh | 210 ++++++------ modules/bezug_solarwatt/main.sh | 1 - modules/bezug_solarworld/main.sh | 2 +- modules/bezug_solax/solax.py | 16 +- modules/bezug_sonneneco/main.sh | 1 - modules/bezug_sungrow/main.sh | 3 +- modules/bezug_sungrow/sungrow.py | 19 +- modules/bezug_varta/main.sh | 5 - modules/bezug_varta/varta.py | 19 +- modules/bezug_victrongx/main.sh | 6 - modules/bezug_victrongx/victron.py | 31 +- modules/extopenwb/main.sh | 15 +- modules/fsm63a3modbusll/main.sh | 8 - modules/fsm63a3modbusll/readfsm63a3.py | 11 +- modules/goelp1/main.sh | 9 +- modules/goelp2/main.sh | 9 +- modules/goelp3/main.sh | 9 +- modules/httpll/main.sh | 16 +- modules/keballlp1/check502.py | 8 +- modules/keballlp1/info.py | 31 +- modules/keballlp1/main.sh | 320 +++++++++--------- modules/keballlp1/setcurrkeba.py | 24 +- modules/mpm3pmethll/main.sh | 3 - modules/mpm3pmethll/readmpm3pm.py | 17 +- modules/mpm3pmethllframer/main.sh | 3 - modules/mpm3pmethllframer/readmpm3pm.py | 18 +- modules/mpm3pmethlls2/main.sh | 4 +- modules/mpm3pmethlls2/readmpm3pm.py | 17 +- modules/mpm3pmll/main.sh | 2 - modules/mpm3pmll/readall.py | 20 +- modules/mpm3pmll/readmpm3pm.py | 19 +- modules/mpm3pmlllp1/main.sh | 4 +- modules/mpm3pmlllp1/readmpm3pm.py | 17 +- modules/mpm3pmlllp2/main.sh | 4 +- modules/mpm3pmlllp2/readmpm3pm.py | 17 +- modules/mpm3pmlllp3/main.sh | 4 +- modules/mpm3pmlllp3/readmpm3pm.py | 17 +- modules/mpm3pmlllp4/main.sh | 2 - modules/mpm3pmlllp4/readmpm3pm.py | 17 +- modules/mpm3pmlllp5/main.sh | 4 +- modules/mpm3pmlllp5/readmpm3pm.py | 16 +- modules/mpm3pmlllp6/main.sh | 4 +- modules/mpm3pmlllp6/readmpm3pm.py | 16 +- modules/mpm3pmlllp7/main.sh | 2 - modules/mpm3pmlllp7/readmpm3pm.py | 16 +- modules/mpm3pmlllp8/main.sh | 2 - modules/mpm3pmlllp8/readmpm3pm.py | 17 +- modules/mpm3pmlls1/main.sh | 3 - modules/mpm3pmlls1/readmpm3pm.py | 20 +- modules/mpm3pmlls2/main.sh | 3 - modules/mpm3pmlls2/readmpm3pm.py | 20 +- modules/mpm3pmpv/main.sh | 4 - modules/mpm3pmpv/readmpm3pm.py | 28 +- modules/mpm3pmspeicher/main.sh | 4 - modules/mpm3pmspeicher/readmpm3pm.py | 24 +- modules/mpm3pmtripple/main.sh | 3 - modules/mpm3pmtripple/readmpm3pm.py | 21 +- modules/mpm3pmtripplelp2/main.sh | 1 - modules/nrgkicklp1/main.sh | 4 - modules/nrgkicklp2/main.sh | 18 +- modules/sdm120modbusSocket/main.sh | 2 +- modules/sdm120modbusSocket/readsdm.py | 14 +- modules/sdm120modbusll/main.sh | 15 +- modules/sdm120modbusll/readsdm1.py | 24 +- modules/sdm120modbusll/readsdm2.py | 28 +- modules/sdm120modbusll/readsdm3.py | 27 +- modules/sdm120modbuslls1/main.sh | 15 +- modules/sdm120modbuslls1/readsdm1.py | 24 +- modules/sdm120modbuslls1/readsdm2.py | 30 +- modules/sdm120modbuslls1/readsdm3.py | 29 +- modules/sdm120modbuslls2/main.sh | 13 +- modules/sdm120modbuslls2/readsdm1.py | 24 +- modules/sdm120modbuslls2/readsdm2.py | 30 +- modules/sdm120modbuslls2/readsdm3.py | 29 +- modules/sdm630modbusbezug/main.sh | 84 ++--- modules/sdm630modbusbezug/readsdm.py | 23 +- modules/sdm630modbusll/main.sh | 166 ++++----- modules/sdm630modbusll/readsdm.py | 27 +- modules/sdm630modbuslls1/main.sh | 49 ++- modules/sdm630modbuslls1/readsdm.py | 27 +- modules/sdm630modbuslls2/main.sh | 17 +- modules/sdm630modbuslls2/readsdm.py | 26 +- modules/sdm630modbuswr/main.sh | 5 - modules/sdm630modbuswr/readsdm.py | 27 +- modules/simpleevsewifi/main.sh | 66 ++-- modules/simpleevsewifis1/main.sh | 66 ++-- modules/simpleevsewifis2/main.sh | 3 +- modules/smaemd_bezug/main.sh | 11 +- modules/smaemd_ll/main.sh | 4 - modules/smaemd_pv/main.sh | 1 - modules/speicher_alphaess/readalpha.py | 55 ++- modules/speicher_alphaess/readv123.py | 54 ++- modules/speicher_e3dc/e3dc.py | 44 +-- modules/speicher_e3dc/e3dcfarm.py | 38 +-- modules/speicher_e3dc/main.sh | 2 +- modules/speicher_fems/main.sh | 7 +- modules/speicher_fronius/main.sh | 7 +- modules/speicher_http/main.sh | 2 - modules/speicher_json/main.sh | 4 +- modules/speicher_lgessv1/main.sh | 2 +- modules/speicher_mpm3pm/main.sh | 4 - modules/speicher_mpm3pm/readmpm3pm.py | 19 +- modules/speicher_mpm3pm/readsdm120.py | 22 +- modules/speicher_mpm3pm/readsdm630.py | 22 +- modules/speicher_saxpower/main.sh | 3 - modules/speicher_saxpower/saxpower.py | 27 +- modules/speicher_sbs25/main.sh | 2 - modules/speicher_sbs25/sbs25.py | 23 +- modules/speicher_siemens/main.sh | 2 - modules/speicher_siemens/siemens.py | 24 +- modules/speicher_solaredge/main.sh | 5 +- modules/speicher_solaredge/solaredge.py | 21 +- modules/speicher_solax/solax.py | 25 +- modules/speicher_sonneneco/main.sh | 27 +- modules/speicher_studer/studer_speicher.py | 19 +- modules/speicher_sungrow/sungrow.py | 24 +- modules/speicher_sunnyisland/main.sh | 2 - modules/speicher_sunnyisland/sbs25.py | 23 +- modules/speicher_sunnyisland/sunnyisland.py | 28 +- modules/speicher_tesvoltsma/main.sh | 2 - modules/speicher_tesvoltsma/tripower.py | 21 +- modules/speicher_varta/main.sh | 12 +- modules/speicher_varta/varta.py | 22 +- modules/speicher_victron/main.sh | 7 - modules/speicher_victron/victron_speicher.py | 72 ++-- modules/twcmanagerlp1/main.sh | 4 - modules/verbraucher/abb-b23remote.py | 18 +- modules/verbraucher/mpm3pmlocal.py | 21 +- modules/verbraucher/mpm3pmremote.py | 22 +- modules/verbraucher/sdm120local.py | 22 +- modules/verbraucher/sdm120remote.py | 26 +- modules/verbraucher/sdm630local.py | 20 +- modules/verbraucher/sdm630remote.py | 16 +- modules/vzlogger/main.sh | 1 - modules/vzloggerpv/main.sh | 2 - modules/wr2_ethlovato/main.sh | 2 - modules/wr2_ethlovato/readlovato.py | 36 +- modules/wr2_ethlovato/readmpm3pm.py | 24 +- modules/wr2_ethlovato/readsdm.py | 26 +- modules/wr2_ethlovatoaevu/main.sh | 3 - modules/wr2_ethlovatoaevu/readlovato.py | 35 +- modules/wr2_ethlovatoaevu/readmpm3pm.py | 24 +- modules/wr2_ethlovatoaevu/readsdm.py | 26 +- modules/wr2_ethsdm120/main.sh | 2 - modules/wr2_ethsdm120/readsdm120.py | 24 +- modules/wr2_kostalpiko/main.sh | 18 +- modules/wr2_kostalpikovar2/main.sh | 57 ++-- modules/wr2_kostalsteca/main.sh | 1 - modules/wr2_smamodbus/main.sh | 6 - modules/wr2_smamodbus/sma.py | 26 +- modules/wr2_solaredge/main.sh | 1 - modules/wr2_solaredge/solaredge.py | 29 +- modules/wr2_solax/solax.py | 18 +- modules/wr2_victron/main.sh | 4 - modules/wr2_victron/victron.py | 21 +- modules/wr_discovergy/main.sh | 2 - modules/wr_ethmpm3pmaevu/main.sh | 2 - modules/wr_ethmpm3pmaevu/readlovato.py | 34 +- modules/wr_ethmpm3pmaevu/readmpm3pm.py | 24 +- modules/wr_ethmpm3pmaevu/readsdm.py | 25 +- modules/wr_ethsdm120/main.sh | 2 - modules/wr_ethsdm120/readsdm120.py | 22 +- modules/wr_fronius/main.sh | 6 +- modules/wr_http/main.sh | 6 +- modules/wr_huawei/huawei.py | 43 ++- modules/wr_huawei/main.sh | 3 - modules/wr_kostalpiko/main.sh | 19 +- modules/wr_kostalpikovar2/main.sh | 62 ++-- modules/wr_lgessv1/main.sh | 2 +- .../wr_plenticore/read_kostalplenticore.py | 14 +- modules/wr_powerdog/main.sh | 2 +- modules/wr_powerdog/powerdog.py | 19 +- modules/wr_pvkit/readlovato.py | 29 +- modules/wr_pvkit/readmpm3pm.py | 18 +- modules/wr_pvkit/readsdm.py | 17 +- modules/wr_shelly/main.sh | 8 +- modules/wr_siemens/main.sh | 3 - modules/wr_siemens/siemens.py | 19 +- modules/wr_smartme/main.sh | 21 +- modules/wr_solaredge/main.sh | 1 - modules/wr_solaredge/solaredge.py | 36 +- modules/wr_solaredge/solaredge2.py | 37 +- modules/wr_solaredge/solaredge2wr.py | 42 ++- modules/wr_solaredge/solaredge3.py | 28 +- modules/wr_solaredge/solaredge4.py | 43 ++- modules/wr_solaredge/solaredgeall.py | 47 ++- modules/wr_solarlog/main.sh | 6 - modules/wr_solarview/main.sh | 227 +++++++------ modules/wr_solarworld/main.sh | 4 +- modules/wr_solax/solax.py | 18 +- modules/wr_studer/main.sh | 3 - modules/wr_studer/studer_wr.py | 24 +- modules/wr_sungrow/sungrow.py | 18 +- modules/wr_tripower9000/main.sh | 18 +- modules/wr_tripower9000/tri9000.py | 26 +- modules/wr_tripower9000/tri90002.py | 50 ++- modules/wr_tripower9000/tri90003.py | 38 +-- modules/wr_tripower9000/tri90004.py | 47 ++- modules/wr_victron/main.sh | 4 - modules/wr_victron/victron.py | 20 +- modules/wr_youless120/main.sh | 14 +- 237 files changed, 2211 insertions(+), 2870 deletions(-) diff --git a/modules/bezug_alphaess/main.sh b/modules/bezug_alphaess/main.sh index f83d9211c..62ced0778 100755 --- a/modules/bezug_alphaess/main.sh +++ b/modules/bezug_alphaess/main.sh @@ -7,4 +7,3 @@ fi wattbezug=$(i', all.decode('hex'))[0]) voltage1 = float("%.1f" % voltage1) / 10 f = open('/var/www/html/openWB/ramdisk/evuv1', 'w') f.write(str(voltage1)) f.close() + resp = client.read_input_registers(0x02,2, unit=sdmid) all = format(resp.registers[1], '04x') + format(resp.registers[0], '04x') voltage2 = float(struct.unpack('>i', all.decode('hex'))[0]) @@ -26,11 +27,11 @@ f = open('/var/www/html/openWB/ramdisk/evuv2', 'w') f.write(str(voltage2)) f.close() + resp = client.read_input_registers(0x04,2, unit=sdmid) all = format(resp.registers[1], '04x') + format(resp.registers[0], '04x') voltage3 = float(struct.unpack('>i', all.decode('hex'))[0]) voltage3 = float("%.1f" % voltage3) / 10 - f = open('/var/www/html/openWB/ramdisk/evuv3', 'w') f.write(str(voltage3)) f.close() @@ -50,7 +51,6 @@ f = open('/var/www/html/openWB/ramdisk/bezugw2', 'w') f.write(str(finalw2)) f.close() - resp = client.read_input_registers(0x16,2, unit=sdmid) all = format(resp.registers[1], '04x') + format(resp.registers[0], '04x') finalw3 = int(struct.unpack('>i', all.decode('hex'))[0] / 10) @@ -58,16 +58,11 @@ f = open('/var/www/html/openWB/ramdisk/bezugw3', 'w') f.write(str(finalw3)) f.close() - - finalw= finalw1 + finalw2 + finalw3 f = open('/var/www/html/openWB/ramdisk/wattbezug', 'w') f.write(str(finalw)) f.close() - - - #ampere l1 resp = client.read_input_registers(0x0C,2, unit=sdmid) all = format(resp.registers[1], '04x') + format(resp.registers[0], '04x') @@ -79,12 +74,12 @@ else: f.write(str(lla1)) f.close() + #ampere l2 resp = client.read_input_registers(0x0E,2, unit=sdmid) all = format(resp.registers[1], '04x') + format(resp.registers[0], '04x') lla1 = float(struct.unpack('>i', all.decode('hex'))[0]) lla2 = float("%.1f" % lla1) / 1000 - f = open('/var/www/html/openWB/ramdisk/bezuga2', 'w') if finalw2 < 0: f.write(str(-lla2)) @@ -97,7 +92,6 @@ all = format(resp.registers[1], '04x') + format(resp.registers[0], '04x') lla1 = float(struct.unpack('>i', all.decode('hex'))[0]) lla3 = float("%.1f" % lla1) / 1000 - f = open('/var/www/html/openWB/ramdisk/bezuga3', 'w') if finalw3 < 0: f.write(str(-lla3)) @@ -108,12 +102,9 @@ #evuhz resp = client.read_input_registers(0x33,2, unit=sdmid) hz = resp.registers[0] / 10 - evuhz = float("%.2f" % hz) if evuhz > 100: evuhz=float(evuhz / 10) f = open('/var/www/html/openWB/ramdisk/evuhz', 'w') f.write(str(evuhz)) f.close() - - diff --git a/modules/bezug_e3dc/e3dc.py b/modules/bezug_e3dc/e3dc.py index 52bd9a146..d17b25965 100755 --- a/modules/bezug_e3dc/e3dc.py +++ b/modules/bezug_e3dc/e3dc.py @@ -1,17 +1,19 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -ipaddress = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusTcpClient + +ipaddress = str(sys.argv[1]) + client = ModbusTcpClient(ipaddress, port=502) -#evu punkt +# evu punkt resp= client.read_holding_registers(40073,2,unit=1) value1 = resp.registers[0] value2 = resp.registers[1] @@ -20,11 +22,11 @@ f = open('/var/www/html/openWB/ramdisk/wattbezug', 'w') f.write(str(final)) f.close() -# + volt=230 resp= client.read_holding_registers(40128,4,unit=1) -#print >>f1,(resp.registers) +# print >>f1,(resp.registers) value1 = resp.registers[0] all = format(value1, '04x') @@ -40,52 +42,49 @@ finale3 = int(struct.unpack('>h', all.decode('hex'))[0]) if finale0 == 1: -# f1 = open('/var/www/html/openWB/ramdisk/logtest2', 'a') -# print >>f1,('e3dc zaehler %1d l1 %6d l2 %6d l3 %6d Watt' % (finale0,finale1,finale2,finale3)) - if finale1 > 0: - finala1=finale1/volt - else: - finala1 = 0 - - if finale2 > 0: - finala2=finale2/volt - else: - finala2 = 0 - - if finale3 > 0: - finala3=finale3/volt - else: - finala3 = 0 -# print >>f1,('e3dc zaehler %1d l1 %6d l2 %6d l3 %6d Amp' % (finale0,finala1,finala2,finala3)) -# volt - f = open('/var/www/html/openWB/ramdisk/evuv1', 'w') - f.write(str(volt)) - f.close() - f = open('/var/www/html/openWB/ramdisk/evuv2', 'w') - f.write(str(volt)) - f.close() - f = open('/var/www/html/openWB/ramdisk/evuv3', 'w') - f.write(str(volt)) - f.close() -#watt pro phase - f = open('/var/www/html/openWB/ramdisk/bezugw1', 'w') - f.write(str(finale1)) - f.close() - f = open('/var/www/html/openWB/ramdisk/bezugw2', 'w') - f.write(str(finale2)) - f.close() - f = open('/var/www/html/openWB/ramdisk/bezugw3', 'w') - f.write(str(finale3)) - f.close() -#amp pro phase - f = open('/var/www/html/openWB/ramdisk/bezuga1', 'w') - f.write(str(finala1)) - f.close() - f = open('/var/www/html/openWB/ramdisk/bezuga2', 'w') - f.write(str(finala2)) - f.close() - f = open('/var/www/html/openWB/ramdisk/bezuga3', 'w') - f.write(str(finala3)) - f.close() -#f1.close() - + # f1 = open('/var/www/html/openWB/ramdisk/logtest2', 'a') + # print >>f1,('e3dc zaehler %1d l1 %6d l2 %6d l3 %6d Watt' % (finale0,finale1,finale2,finale3)) + if finale1 > 0: + finala1=finale1/volt + else: + finala1 = 0 + if finale2 > 0: + finala2=finale2/volt + else: + finala2 = 0 + if finale3 > 0: + finala3=finale3/volt + else: + finala3 = 0 + # print >>f1,('e3dc zaehler %1d l1 %6d l2 %6d l3 %6d Amp' % (finale0,finala1,finala2,finala3)) + # volt + f = open('/var/www/html/openWB/ramdisk/evuv1', 'w') + f.write(str(volt)) + f.close() + f = open('/var/www/html/openWB/ramdisk/evuv2', 'w') + f.write(str(volt)) + f.close() + f = open('/var/www/html/openWB/ramdisk/evuv3', 'w') + f.write(str(volt)) + f.close() + # watt pro phase + f = open('/var/www/html/openWB/ramdisk/bezugw1', 'w') + f.write(str(finale1)) + f.close() + f = open('/var/www/html/openWB/ramdisk/bezugw2', 'w') + f.write(str(finale2)) + f.close() + f = open('/var/www/html/openWB/ramdisk/bezugw3', 'w') + f.write(str(finale3)) + f.close() + # amp pro phase + f = open('/var/www/html/openWB/ramdisk/bezuga1', 'w') + f.write(str(finala1)) + f.close() + f = open('/var/www/html/openWB/ramdisk/bezuga2', 'w') + f.write(str(finala2)) + f.close() + f = open('/var/www/html/openWB/ramdisk/bezuga3', 'w') + f.write(str(finala3)) + f.close() + # f1.close() diff --git a/modules/bezug_ethmpm3pm/main.sh b/modules/bezug_ethmpm3pm/main.sh index 72e63d451..546faa779 100755 --- a/modules/bezug_ethmpm3pm/main.sh +++ b/modules/bezug_ethmpm3pm/main.sh @@ -8,5 +8,3 @@ else fi wattbezug=$(i', all.decode('hex'))[0] / 100) @@ -54,15 +46,14 @@ f.close() finalw= finalw1 + finalw2 + finalw3 -#total watt -#resp = client.read_input_registers(0x0039,2, unit=0x02) -#all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') -#finalw = int(struct.unpack('>i', all.decode('hex'))[0] / 100) +# total watt +# resp = client.read_input_registers(0x0039,2, unit=0x02) +# all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') +# finalw = int(struct.unpack('>i', all.decode('hex'))[0] / 100) f = open('/var/www/html/openWB/ramdisk/wattbezug', 'w') f.write(str(finalw)) f.close() - #ampere l1 resp = client.read_input_registers(0x0007, 2, unit=0x02) all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') diff --git a/modules/bezug_ethmpm3pm/readmpm3pm.py b/modules/bezug_ethmpm3pm/readmpm3pm.py index 592be719f..ea373af0b 100755 --- a/modules/bezug_ethmpm3pm/readmpm3pm.py +++ b/modules/bezug_ethmpm3pm/readmpm3pm.py @@ -1,18 +1,14 @@ #!/usr/bin/python -import sys -import os -import time -import getopt +# 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) - - +client = ModbusTcpClient('192.168.193.15', port=8899) -#Voltage +# Voltage resp = client.read_input_registers(0x08,4, unit=5) voltage1 = resp.registers[1] voltage1 = float(voltage1) / 10 @@ -43,7 +39,8 @@ f = open('/var/www/html/openWB/ramdisk/bezugkwh', 'w') f.write(str(ikwh)) f.close() -#phasen watt + +# phasen watt resp = client.read_input_registers(0x14,2, unit=5) value1 = resp.registers[0] value2 = resp.registers[1] @@ -69,31 +66,31 @@ f.write(str(finalw3)) f.close() -#resp = client.read_input_registers(0x0E,2, unit=5) -#lla1 = resp.registers[1] -#lla1 = float(lla1) / 100 +# resp = client.read_input_registers(0x0E,2, unit=5) +# lla1 = resp.registers[1] +# lla1 = float(lla1) / 100 lla1=round(float(float(finalw1) / float(voltage1)), 2) f = open('/var/www/html/openWB/ramdisk/bezuga1', 'w') f.write(str(lla1)) f.close() -#resp = client.read_input_registers(0x10,2, unit=5) -#lla2 = resp.registers[1] -#lla2 = float(lla2) / 100 +# resp = client.read_input_registers(0x10,2, unit=5) +# lla2 = resp.registers[1] +# lla2 = float(lla2) / 100 lla2=round(float(float(finalw2) / float(voltage2)), 2) f = open('/var/www/html/openWB/ramdisk/bezuga2', 'w') f.write(str(lla2)) f.close() -#resp = client.read_input_registers(0x12,2, unit=5) -#lla3 = resp.registers[1] -#lla3 = float(lla3) / 100 +# resp = client.read_input_registers(0x12,2, unit=5) +# lla3 = resp.registers[1] +# lla3 = float(lla3) / 100 lla3=round(float(float(finalw3) / float(voltage3)), 2) f = open('/var/www/html/openWB/ramdisk/bezuga3', 'w') f.write(str(lla3)) f.close() -#total watt +# total watt resp = client.read_input_registers(0x26,2, unit=5) value1 = resp.registers[0] value2 = resp.registers[1] @@ -103,7 +100,7 @@ f.write(str(final)) f.close() -#export kwh +# export kwh resp = client.read_input_registers(0x0004,4, unit=5) value1 = resp.registers[0] value2 = resp.registers[1] @@ -113,7 +110,8 @@ f = open('/var/www/html/openWB/ramdisk/einspeisungkwh', 'w') f.write(str(ekwh)) f.close() -#evuhz + +# evuhz resp = client.read_input_registers(0x2c,4, unit=5) value1 = resp.registers[0] value2 = resp.registers[1] @@ -124,7 +122,7 @@ f.write(str(hz)) f.close() -#Power Factor +# Power Factor resp = client.read_input_registers(0x20,4, unit=5) value1 = resp.registers[0] value2 = resp.registers[1] diff --git a/modules/bezug_ethmpm3pm/readsdm.py b/modules/bezug_ethmpm3pm/readsdm.py index ac40d853e..3a0c3afd8 100755 --- a/modules/bezug_ethmpm3pm/readsdm.py +++ b/modules/bezug_ethmpm3pm/readsdm.py @@ -1,16 +1,15 @@ #!/usr/bin/python -import sys -import os -import time -import getopt +# import sys +# import os +# import time +# import getopt import struct from pymodbus.client.sync import ModbusTcpClient + client = ModbusTcpClient('192.168.193.15', port=8899) sdmid = 115 - - -#Voltage +# Voltage resp = client.read_input_registers(0x00,2, unit=sdmid) voltage = struct.unpack('>f',struct.pack('>HH',*resp.registers))[0] voltage1 = float("%.1f" % voltage) @@ -30,16 +29,13 @@ f.write(str(voltage3)) f.close() - - -#phasen watt +# phasen watt resp = client.read_input_registers(0x0C,2, unit=sdmid) llw1 = struct.unpack('>f',struct.pack('>HH',*resp.registers))[0] finalw1 = int(llw1) f = open('/var/www/html/openWB/ramdisk/bezugw1', 'w') f.write(str(finalw1)) f.close() - resp = client.read_input_registers(0x0E,2, unit=sdmid) llw1 = struct.unpack('>f',struct.pack('>HH',*resp.registers))[0] finalw2 = int(llw1) @@ -58,8 +54,7 @@ f.write(str(finalw)) f.close() - -#ampere l1 +# ampere l1 resp = client.read_input_registers(0x06,2, unit=sdmid) lla1 = float(struct.unpack('>f',struct.pack('>HH',*resp.registers))[0]) lla1 = float("%.1f" % lla1) @@ -70,7 +65,7 @@ f.write(str(lla1)) f.close() -#ampere l2 +# ampere l2 resp = client.read_input_registers(0x08,2, unit=sdmid) lla1 = float(struct.unpack('>f',struct.pack('>HH',*resp.registers))[0]) lla2 = float("%.1f" % lla1) @@ -81,7 +76,7 @@ f.write(str(lla2)) f.close() -#ampere l3 +# ampere l3 resp = client.read_input_registers(0x0A,2, unit=sdmid) lla1 = float(struct.unpack('>f',struct.pack('>HH',*resp.registers))[0]) lla3 = float("%.1f" % lla1) @@ -92,7 +87,7 @@ f.write(str(lla3)) f.close() -#evuhz +# evuhz resp = client.read_input_registers(0x46,2, unit=sdmid) hz = struct.unpack('>f',struct.pack('>HH',*resp.registers))[0] evuhz = float("%.2f" % hz) @@ -101,7 +96,8 @@ f = open('/var/www/html/openWB/ramdisk/evuhz', 'w') f.write(str(evuhz)) f.close() -#Power Factor + +# Power Factor resp = client.read_input_registers(0x1E,2, unit=sdmid) evu1pf = struct.unpack('>f',struct.pack('>HH',*resp.registers))[0] evu1pf = float("%.2f" % evu1pf) @@ -122,4 +118,3 @@ f = open('/var/www/html/openWB/ramdisk/evupf3', 'w') f.write(str(evu3pf)) f.close() - diff --git a/modules/bezug_fems/main.sh b/modules/bezug_fems/main.sh index eaf5184ce..e8f185032 100644 --- a/modules/bezug_fems/main.sh +++ b/modules/bezug_fems/main.sh @@ -9,7 +9,6 @@ evua1=$(curl --connect-timeout 2 -s "http://x:$femskacopw@$femsip:8084/rest/chan evua2=$(curl --connect-timeout 2 -s "http://x:$femskacopw@$femsip:8084/rest/channel/meter0/CurrentL2" | jq .value) evua3=$(curl --connect-timeout 2 -s "http://x:$femskacopw@$femsip:8084/rest/channel/meter0/CurrentL3" | jq .value) - echo $watt > /var/www/html/openWB/ramdisk/wattbezug echo $evuv1 > /var/www/html/openWB/ramdisk/evuv1 echo $evuv2 > /var/www/html/openWB/ramdisk/evuv2 @@ -19,9 +18,4 @@ echo $ewh > /var/www/html/openWB/ramdisk/einspeisungkwh echo $evua1 > /var/www/html/openWB/ramdisk/bezuga1 echo $evua2 > /var/www/html/openWB/ramdisk/bezuga2 echo $evua3 > /var/www/html/openWB/ramdisk/bezuga3 - - - - echo $watt - diff --git a/modules/bezug_fronius_s0/main.sh b/modules/bezug_fronius_s0/main.sh index 3f00a5b62..cefc816b7 100755 --- a/modules/bezug_fronius_s0/main.sh +++ b/modules/bezug_fronius_s0/main.sh @@ -1,7 +1,7 @@ #!/bin/bash -#Auslesen eines Fronius Symo WR mit Fronius Smartmeter über die integrierte JSON-API des WR. -#Rückgabewert ist die aktuelle Einspeiseleistung (negativ) oder Bezugsleistung (positiv) +# Auslesen eines Fronius Symo WR mit Fronius Smartmeter über die integrierte JSON-API des WR. +# Rückgabewert ist die aktuelle Einspeiseleistung (negativ) oder Bezugsleistung (positiv) # Einspeiseleistung: PV-Leistung > Verbrauch, es wird Strom eingespeist # Bezugsleistug: PV-Leistung < Verbrauch, es wird Strom aus dem Netz bezogen @@ -20,13 +20,13 @@ wattb=$(( pvwatt + wattbezug )) re='^[0-9]+$' ra='^-[0-9]+$' if ! [[ $wattbezug =~ $re ]] ; then - if ! [[ $wattbezug =~ $ra ]] ; then - wattbezug="0" - fi + if ! [[ $wattbezug =~ $ra ]] ; then + wattbezug="0" + fi fi echo $wattbezug -#zur weiteren verwendung im webinterface +# zur weiteren verwendung im webinterface echo $wattbezug > /var/www/html/openWB/ramdisk/wattbezug # Summe der vom Netz bezogene Energie total in Wh # nur für Smartmeter im Einspeisepunkt! diff --git a/modules/bezug_http/main.sh b/modules/bezug_http/main.sh index 6fc588bc6..ac56d0dd1 100755 --- a/modules/bezug_http/main.sh +++ b/modules/bezug_http/main.sh @@ -1,12 +1,10 @@ #!/bin/bash - -wattbezug=$(curl --connect-timeout 10 -s $bezug_http_w_url) - re='^-?[0-9]+$' +wattbezug=$(curl --connect-timeout 10 -s $bezug_http_w_url) if ! [[ $wattbezug =~ $re ]] ; then - wattbezug="0" + wattbezug="0" fi echo $wattbezug echo $wattbezug > /var/www/html/openWB/ramdisk/wattbezug @@ -31,7 +29,3 @@ if [[ $bezug_http_l3_url != "none" ]]; then l3a=$(curl --connect-timeout 5 -s $bezug_http_l3_url) echo $l3a > /var/www/html/openWB/ramdisk/bezuga3 fi - - - - diff --git a/modules/bezug_janitza/main.sh b/modules/bezug_janitza/main.sh index 1da9121ee..ab862cf36 100644 --- a/modules/bezug_janitza/main.sh +++ b/modules/bezug_janitza/main.sh @@ -3,4 +3,3 @@ python /var/www/html/openWB/modules/bezug_janitza/readjanitza.py $bezug1_ip wattbezug=$(f',struct.pack('>HH',*rq.registers))[0] voltage2 = int(voltage) f = open('/var/www/html/openWB/ramdisk/wattbezug', 'w') f.write(str(voltage2)) f.close() - - diff --git a/modules/bezug_json/main.sh b/modules/bezug_json/main.sh index 15ab74da6..407458a6a 100755 --- a/modules/bezug_json/main.sh +++ b/modules/bezug_json/main.sh @@ -7,7 +7,6 @@ MODULEDIR=$(cd `dirname $0` && pwd) DMOD="MAIN" Debug=$debug - #For development only #Debug=1 @@ -22,19 +21,17 @@ openwbDebugLog ${DMOD} 1 "Watt: ${evuwatt}" echo $evuwatt > /var/www/html/openWB/ramdisk/wattbezug if [ ! -z "${bezugjsonkwh}" ]; then - evuikwh=$(echo $answer | jq -r "$bezugjsonkwh") + evuikwh=$(echo $answer | jq -r "$bezugjsonkwh") else - evuikwh=0 + evuikwh=0 fi - openwbDebugLog ${DMOD} 1 "BezugkWh: ${evuikwh}" echo $evuikwh > /var/www/html/openWB/ramdisk/bezugkwh if [ ! -z "${einspeisungjsonkwh}" ]; then - evuekwh=$(echo $answer | jq -r "$einspeisungjsonkwh") + evuekwh=$(echo $answer | jq -r "$einspeisungjsonkwh") else - evuekwh=0 + evuekwh=0 fi openwbDebugLog ${DMOD} 1 "EinspeiskWh: ${evuekwh}" echo $evuekwh > /var/www/html/openWB/ramdisk/einspeisungkwh - diff --git a/modules/bezug_kostalpiko/main.sh b/modules/bezug_kostalpiko/main.sh index c4b6611fe..0490bd460 100755 --- a/modules/bezug_kostalpiko/main.sh +++ b/modules/bezug_kostalpiko/main.sh @@ -7,10 +7,9 @@ pvwatttmp=$(curl --connect-timeout 3 -s $wrkostalpikoip/api/dxs.json?dxsEntries= #aktuelle Ausgangsleistung am WR [W] pvwatt=$(echo $pvwatttmp | jq '.dxsEntries[0].value' | sed 's/\..*$//') -if [ $pvwatt > 5 ] - then - pvwatt=$(echo "$pvwatt*-1" |bc) -fi +if [ $pvwatt > 5 ] ; then + pvwatt=$(echo "$pvwatt*-1" |bc) +fi #zur weiteren verwendung im webinterface echo $pvwatt > /var/www/html/openWB/ramdisk/pvwatt @@ -30,7 +29,6 @@ else wattbezug=$(echo "$bezugw1+$bezugw2+$bezugw3+$pvwatt" |bc) fi - echo $wattbezug echo $wattbezug > /var/www/html/openWB/ramdisk/wattbezug bezuga1=$(echo "scale=2 ; $bezugw1 / 225" | bc) @@ -39,8 +37,3 @@ bezuga3=$(echo "scale=2 ; $bezugw3 / 225" | bc) echo $bezuga1 > /var/www/html/openWB/ramdisk/bezuga1 echo $bezuga2 > /var/www/html/openWB/ramdisk/bezuga2 echo $bezuga3 > /var/www/html/openWB/ramdisk/bezuga3 - - - - - diff --git a/modules/bezug_kostalplenticoreem300haus/main.sh b/modules/bezug_kostalplenticoreem300haus/main.sh index 1b100c45b..dbcf4fdc5 100755 --- a/modules/bezug_kostalplenticoreem300haus/main.sh +++ b/modules/bezug_kostalplenticoreem300haus/main.sh @@ -18,21 +18,21 @@ # Unterscheidung EM300 Sensorposition zur Bestimmung Bezug EVU if [ $kostalplenticorehaus -eq 1 ]; then - # EM300 Sensorposition 2 (am EVU-Übergabepunkt = grid connection) - # Bezug EVU wurde bereits im wr_plenticore Modul aus den Modbus-Registern gelesen - "cp" /var/www/html/openWB/ramdisk/temp_wattbezug /var/www/html/openWB/ramdisk/wattbezug + # EM300 Sensorposition 2 (am EVU-Übergabepunkt = grid connection) + # Bezug EVU wurde bereits im wr_plenticore Modul aus den Modbus-Registern gelesen + "cp" /var/www/html/openWB/ramdisk/temp_wattbezug /var/www/html/openWB/ramdisk/wattbezug else - # EM300 Sensorposition 1 (im Hausverbrauchszweig = home consumption) - # Werte aus (temporärer) ramdisk lesen - # aktueller Hausverbrauch - Home_consumption=$( /var/www/html/openWB/ramdisk/wattbezug fi diff --git a/modules/bezug_ksem/readksem.py b/modules/bezug_ksem/readksem.py index eba380540..c84ca2a30 100644 --- a/modules/bezug_ksem/readksem.py +++ b/modules/bezug_ksem/readksem.py @@ -1,9 +1,9 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import struct +# import os +# import time +# import getopt +# import struct from pymodbus.client.sync import ModbusTcpClient from pymodbus.constants import Endian from pymodbus.payload import BinaryPayloadDecoder diff --git a/modules/bezug_lgessv1/main.sh b/modules/bezug_lgessv1/main.sh index 2c6cffef5..14f709fe2 100755 --- a/modules/bezug_lgessv1/main.sh +++ b/modules/bezug_lgessv1/main.sh @@ -25,13 +25,13 @@ fi # z.b. wenn das System neu gestartet wurde, dann wird ein Dummykey an- # gelegt if test -f "/var/www/html/openWB/ramdisk/ess_session_key"; then - session_key=$(sed -n '1p' /var/www/html/openWB/ramdisk/ess_session_key) + session_key=$(sed -n '1p' /var/www/html/openWB/ramdisk/ess_session_key) else session_key=" " fi # ## JSON-Objekt vom PCS abholen. Es können folgende JSON-Objekte zurück gegeben werden: -# +# # 1. Wenn der Sessionkey nicht korrekt bzw. wenn die Session abgelaufen ist, dann wird ein # JSON-Objekt mit einem Attribut "auth_key" zurück gegeben # 2. Der Sessionkey ist gültig, dann erhält man ein JSON-Objekt mit den wichtigsten Attribute. diff --git a/modules/bezug_mpm3pm/main.sh b/modules/bezug_mpm3pm/main.sh index 7e79730c0..624f3f623 100755 --- a/modules/bezug_mpm3pm/main.sh +++ b/modules/bezug_mpm3pm/main.sh @@ -31,6 +31,4 @@ if (( mpm3pmevuhaus == 1 )); then echo $bezuga1 > /var/www/html/openWB/ramdisk/bezuga1 echo $bezuga2 > /var/www/html/openWB/ramdisk/bezuga2 echo $bezuga3 > /var/www/html/openWB/ramdisk/bezuga3 - fi - diff --git a/modules/bezug_mpm3pm/readmpm3pm.py b/modules/bezug_mpm3pm/readmpm3pm.py index e22f99641..0aeb4c0c4 100755 --- a/modules/bezug_mpm3pm/readmpm3pm.py +++ b/modules/bezug_mpm3pm/readmpm3pm.py @@ -1,32 +1,29 @@ #!/usr/bin/python import sys -import os -import time -import getopt +# import os +# import time +# import getopt import struct -seradd = str(sys.argv[1]) from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) - +seradd = str(sys.argv[1]) sdmid = int(sys.argv[2]) -#Voltage +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) + +# Voltage resp = client.read_input_registers(0x08,4, unit=sdmid) voltage = resp.registers[1] voltage = float(voltage) / 10 f = open('/var/www/html/openWB/ramdisk/evuv1', 'w') f.write(str(voltage)) f.close() - resp = client.read_input_registers(0x0A,4, unit=sdmid) voltage = resp.registers[1] voltage = float(voltage) / 10 f = open('/var/www/html/openWB/ramdisk/evuv2', 'w') f.write(str(voltage)) f.close() - resp = client.read_input_registers(0x0C,4, unit=sdmid) voltage = resp.registers[1] voltage = float(voltage) / 10 @@ -34,6 +31,7 @@ f.write(str(voltage)) f.close() +# import kWh resp = client.read_input_registers(0x0002,4, unit=sdmid) value1 = resp.registers[0] value2 = resp.registers[1] @@ -43,20 +41,20 @@ f = open('/var/www/html/openWB/ramdisk/bezugkwh', 'w') f.write(str(ikwh)) f.close() + +# phasen strom resp = client.read_input_registers(0x0E,2, unit=sdmid) lla1 = resp.registers[1] lla1 = float(lla1) / 100 f = open('/var/www/html/openWB/ramdisk/bezuga1', 'w') f.write(str(lla1)) f.close() - resp = client.read_input_registers(0x10,2, unit=sdmid) lla2 = resp.registers[1] lla2 = float(lla2) / 100 f = open('/var/www/html/openWB/ramdisk/bezuga2', 'w') f.write(str(lla2)) f.close() - resp = client.read_input_registers(0x12,2, unit=sdmid) lla3 = resp.registers[1] lla3 = float(lla3) / 100 @@ -64,7 +62,7 @@ f.write(str(lla3)) f.close() -#phasen watt +# phasen watt resp = client.read_input_registers(0x14,2, unit=sdmid) value1 = resp.registers[0] value2 = resp.registers[1] @@ -89,7 +87,8 @@ f = open('/var/www/html/openWB/ramdisk/bezugw3', 'w') f.write(str(final)) f.close() -#total watt + +# total watt resp = client.read_input_registers(0x26,2, unit=sdmid) value1 = resp.registers[0] value2 = resp.registers[1] @@ -99,8 +98,7 @@ f.write(str(final)) f.close() -#export kwh - +# export kwh resp = client.read_input_registers(0x0004,4, unit=sdmid) value1 = resp.registers[0] value2 = resp.registers[1] @@ -110,7 +108,8 @@ f = open('/var/www/html/openWB/ramdisk/einspeisungkwh', 'w') f.write(str(ekwh)) f.close() -#evuhz + +# evuhz resp = client.read_input_registers(0x2c,4, unit=sdmid) value1 = resp.registers[0] value2 = resp.registers[1] diff --git a/modules/bezug_powerdog/powerdog.py b/modules/bezug_powerdog/powerdog.py index abedb58d7..a65c54fcf 100644 --- a/modules/bezug_powerdog/powerdog.py +++ b/modules/bezug_powerdog/powerdog.py @@ -1,14 +1,16 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -ipaddress = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusTcpClient + +ipaddress = str(sys.argv[1]) + client = ModbusTcpClient(ipaddress, port=502) #new @@ -38,4 +40,3 @@ f = open('/var/www/html/openWB/ramdisk/wattbezug', 'w') f.write(str(final)) f.close() - diff --git a/modules/bezug_powerfox/main.sh b/modules/bezug_powerfox/main.sh index b0faa44af..bdf211c58 100644 --- a/modules/bezug_powerfox/main.sh +++ b/modules/bezug_powerfox/main.sh @@ -1,16 +1,13 @@ #!/bin/bash output=$(curl --connect-timeout 3 -s -u $powerfoxuser:"$powerfoxpass" "https://backend.powerfox.energy/api/2.0/my/$powerfoxid/current") - einspeisungwh=$(echo $output | jq '.A_Minus') echo $einspeisungwh > /var/www/html/openWB/ramdisk/einspeisungkwh bezugwh=$(echo $output | jq '.A_Plus') echo $bezugwh > /var/www/html/openWB/ramdisk/bezugkwh - watt=$(echo $output | jq '.Watt') echo $watt > /var/www/html/openWB/ramdisk/wattbezug - echo $watt diff --git a/modules/bezug_rct/main.sh b/modules/bezug_rct/main.sh index ddfa0fe05..be7adf58f 100755 --- a/modules/bezug_rct/main.sh +++ b/modules/bezug_rct/main.sh @@ -1,4 +1,5 @@ #!/bin/bash + wattbezug=$(echo "scale=0; $(python /var/www/html/openWB/modules/bezug_rct/rct_read.py --ip=$bezug1_ip --name='g_sync.p_ac_sc_sum')/1" | bc) watt1=$(echo "scale=0; $(python /var/www/html/openWB/modules/bezug_rct/rct_read.py --ip=$bezug1_ip --id='0x27BE51D9')/230/1" | bc) watt2=$(echo "scale=0; $(python /var/www/html/openWB/modules/bezug_rct/rct_read.py --ip=$bezug1_ip --id='0xF5584F90')/230/1" | bc) @@ -7,6 +8,5 @@ echo $watt1 > /var/www/html/openWB/ramdisk/bezuga1 echo $watt2 > /var/www/html/openWB/ramdisk/bezuga2 echo $watt3 > /var/www/html/openWB/ramdisk/bezuga3 - echo $wattbezug > /var/www/html/openWB/ramdisk/wattbezug -echo $wattbezug \ No newline at end of file +echo $wattbezug diff --git a/modules/bezug_rct/rct.py b/modules/bezug_rct/rct.py index 25e97d431..a997f8eee 100644 --- a/modules/bezug_rct/rct.py +++ b/modules/bezug_rct/rct.py @@ -11,7 +11,7 @@ import select import struct import binascii -import time +# import time import operator class rct_id(): @@ -463,8 +463,8 @@ def init(argv): bVerbose = True id_tab_setup() - param_len = 0; - desc_len = 0; + param_len = 0 + desc_len = 0 for obj in id_tab: if len(obj.name) > param_len: param_len = len(obj.name) diff --git a/modules/bezug_rct/rct_read.py b/modules/bezug_rct/rct_read.py index cd83f4a21..4902a5ed4 100644 --- a/modules/bezug_rct/rct_read.py +++ b/modules/bezug_rct/rct_read.py @@ -19,11 +19,9 @@ def main(): value = rct.read(clientsocket, obj.id) if rct.dbglog(fmt.format(obj.id, obj.name), value) == False: - print value - + print(value) rct.close(clientsocket) - sys.exit(0) - + if __name__ == "__main__": main() \ No newline at end of file diff --git a/modules/bezug_sbs25/main.sh b/modules/bezug_sbs25/main.sh index afa96cb4d..3929c5f80 100755 --- a/modules/bezug_sbs25/main.sh +++ b/modules/bezug_sbs25/main.sh @@ -1,12 +1,6 @@ #!/bin/bash - - sudo python /var/www/html/openWB/modules/bezug_sbs25/sbs25.py $sbs25ip wattbezug=$(i', all.decode('hex'))[0]) if bezug > 5: - final=bezug + final=bezug else: - final=einsp * -1 + final=einsp * -1 f = open('/var/www/html/openWB/ramdisk/wattbezug', 'w') f.write(str(final)) f.close() - - - - diff --git a/modules/bezug_siemens/main.sh b/modules/bezug_siemens/main.sh index 0fdc317fb..10b7cd833 100755 --- a/modules/bezug_siemens/main.sh +++ b/modules/bezug_siemens/main.sh @@ -1,7 +1,5 @@ #!/bin/bash - - python /var/www/html/openWB/modules/bezug_siemens/siemens.py $bezug1_ip wattbezug=$( W) wattbezug=$(awk -F'[<>]' '//{print $3}' <<< $xml) wattbezug="${wattbezug::-2}" - wattbezug1=$(awk -F'[<>]' '//{print $3}' <<< $xml) - wattbezug2=$(awk -F'[<>]' '//{print $3}' <<< $xml) - wattbezug3=$(awk -F'[<>]' '//{print $3}' <<< $xml) #Zählerstand Import(kWh) @@ -88,13 +85,13 @@ bezuga3=$(awk -F'[<>]' '//{print $3}' <<< $xml) #Prüfen ob Werte gültig re='^[-+]?[0-9]+\.?[0-9]*$' if ! [[ $wattbezug =~ $re ]] ; then - wattbezug=$(h', all.decode('hex'))[0]) * -1 - + sf = resp.registers[4] sf = format(sf, '04x') fsf = int(struct.unpack('>h', sf.decode('hex'))[0]) @@ -37,12 +39,10 @@ final = final / 1000 if fsf == -4: final = final / 10000 - + f = open('/var/www/html/openWB/ramdisk/wattbezug', 'w') f.write(str(final)) f.close() - - resp= client.read_holding_registers(40194,2,unit=slaveid) multipli = resp.registers[0] @@ -61,7 +61,6 @@ all = format(value1, '04x') finala3 = int(struct.unpack('>h', all.decode('hex'))[0]) - resp= client.read_holding_registers(40194,2,unit=slaveid) mult2ipli = resp.registers[0] mult2iplint = format(mult2ipli, '04x') @@ -120,7 +119,6 @@ f.close() #voltage - resp= client.read_holding_registers(40196,1,unit=slaveid) value1 = resp.registers[0] all = format(value1, '04x') @@ -144,13 +142,12 @@ f.write(str(finale3)) f.close() - #watt pro phase +#watt pro phase resp= client.read_holding_registers(40207,1,unit=slaveid) value1 = resp.registers[0] all = format(value1, '04x') finale1 = int(struct.unpack('>h', all.decode('hex'))[0]) * -1 - resp= client.read_holding_registers(40208,1,unit=slaveid) value1 = resp.registers[0] all = format(value1, '04x') @@ -160,8 +157,6 @@ all = format(value1, '04x') finale3 = int(struct.unpack('>h', all.decode('hex'))[0]) * -1 - - f = open('/var/www/html/openWB/ramdisk/bezugw1', 'w') f.write(str(finale1)) f.close() @@ -172,51 +167,42 @@ f.write(str(finale3)) f.close() - - #hz - - resp= client.read_holding_registers(40204,1,unit=slaveid) value1 = resp.registers[0] all = format(value1, '04x') finalhz = int(struct.unpack('>h', all.decode('hex'))[0]) - resp= client.read_holding_registers(40205,1,unit=slaveid) multipli = resp.registers[0] multiplint = format(multipli, '04x') fmuliplint = int(struct.unpack('>h', multiplint.decode('hex'))[0]) if fmultiplint == 4: - finalhz = finalhz * 1000 + finalhz = finalhz * 1000 if fmultiplint == 3: - finalhz = finalhz * 100 + finalhz = finalhz * 100 if fmultiplint == 2: - finalhz = finalhz * 10 + finalhz = finalhz * 10 if fmultiplint == 1: - finalhz = finalhz * 1 + finalhz = finalhz * 1 if fmultiplint == 0: - finalhz = finalhz / 10 + finalhz = finalhz / 10 if fmultiplint == -1: - finalhz = finalhz / 100 + finalhz = finalhz / 100 if fmultiplint == -2: - finalhz = finalhz / 1000 + finalhz = finalhz / 1000 if fmultiplint == -3: - finalhz = finalhz / 10000 + finalhz = finalhz / 10000 if fmultiplint == -4: - finalhz = finalhz / 100000 + finalhz = finalhz / 100000 if fmultiplint == -5: - finalhz = finalhz / 1000000 - + finalhz = finalhz / 1000000 + f = open('/var/www/html/openWB/ramdisk/evuhz', 'w') f.write(str(finalhz)) f.close() - - - - #resp= client.read_holding_registers(40084,2,unit=1) #multipli = resp.registers[0] #multiplint = format(multipli, '04x') @@ -251,7 +237,6 @@ #f.write(str(pvkwhk)) #f.close() - resp= client.read_holding_registers(40234,2,unit=slaveid) value1 = resp.registers[0] value2 = resp.registers[1] @@ -269,4 +254,3 @@ f = open('/var/www/html/openWB/ramdisk/einspeisungkwh', 'w') f.write(str(final)) f.close() - diff --git a/modules/bezug_solarlog/main.sh b/modules/bezug_solarlog/main.sh index 39d9d0c0d..29c67de9d 100755 --- a/modules/bezug_solarlog/main.sh +++ b/modules/bezug_solarlog/main.sh @@ -1,8 +1,5 @@ #!/bin/bash - - - answer=$(curl -d {\"801\":{\"170\":null}} --connect-timeout 5 -s $bezug_solarlog_ip/getjp) pvwatt=$(echo $answer | jq '."801"."170"."101"' ) @@ -23,4 +20,3 @@ echo $pvwatt > /var/www/html/openWB/ramdisk/pvwatt echo $pvkwh > /var/www/html/openWB/ramdisk/pvkwh pvkwhk=$(echo "$pvkwh*1000" |bc) echo $pvkwhk > /var/www/html/openWB/ramdisk/pvkwhk - diff --git a/modules/bezug_solarview/main.sh b/modules/bezug_solarview/main.sh index e72a7e8d0..29f39ab62 100755 --- a/modules/bezug_solarview/main.sh +++ b/modules/bezug_solarview/main.sh @@ -8,125 +8,123 @@ openwb_home=/var/www/html/openWB target="$openwb_home/ramdisk" - # Checks if [ -z "$solarview_hostname" ]; then - log "Missing required variable 'solarview_hostname'" - return 1 + log "Missing required variable 'solarview_hostname'" + return 1 fi if [ "${solarview_port}" ]; then - if [ "$solarview_port" -lt 1 ] || [ "$solarview_port" -gt 65535 ]; then - log "Invalid value '$solarview_port' for variable 'solarview_port'" - return 1 - fi + if [ "$solarview_port" -lt 1 ] || [ "$solarview_port" -gt 65535 ]; then + log "Invalid value '$solarview_port' for variable 'solarview_port'" + return 1 + fi fi command_bezug='22*' command_einspeisung='21*' log() { - echo "[bezug_solarview] $*" >>"$target/openWB.log" + echo "[bezug_solarview] $*" >>"$target/openWB.log" } request() { - command="$1" - port="${solarview_port:-15000}" - timeout="${solarview_timeout:-1}" - - response=$(echo "$command" | nc -w "$timeout" "$solarview_hostname" "$port") - return_code="$?" - if [ "$return_code" -ne 0 ]; then - log "Error: request to SolarView failed. Details: return-code: '$return_code', host: '$solarview_hostname', port: '$port', timeout: '$timeout'" - return "$return_code" - fi - - [ "$debug" -ne 0 ] && log "Raw response: $response" - # - # Format: {WR,Tag,Monat,Jahr,Stunde,Minute,KDY,KMT,KYR,KT0,PAC,UDC,IDC,UDCB,IDCB,UDCC,IDCC,UDCD,IDCD,TKK},Checksum - # Beispiele: {22,09,09,2019,10,37,0001.2,00024,000903,00007817,01365,000,000.0,000,000.0,000,000.0,000,000.0,00},: - # {21,09,09,2019,10,37,0002.3,00141,004233,00029525,01365,000,000.0,000,000.0,000,000.0,000,000.0,00},; - # - # Bedeutung (siehe SolarView-Dokumentation): - # KDY= Tagesertrag (kWh) - # KMT= Monatsertrag (kWh) - # KYR= Jahresertrag (kWh) - # KT0= Gesamtertrag (kWh) - # PAC= Generatorleistung in W - # UDC, UDCB, UDCC, UDCD= Generator-Spannungen in Volt pro MPP-Tracker - # IDC, IDCB, IDCC, IDCD= Generator-Ströme in Ampere pro MPP-Tracker - # TKK= Temperatur Wechselrichter - - # Geschweifte Klammern und Checksumme entfernen - values="${response#*\{}" - values="${values%\}*}" - - # Werte auslesen und verarbeiten - local LANG=C - echo "$values" | while IFS=',' read -r WR Tag Monat Jahr Stunde Minute KDY KMT KYR KT0 PAC UDC IDC UDCB IDCB UDCC IDCC UDCD IDCD TKK - do - - # Werte formatiert in Variablen speichern - id="$WR" - timestamp="$Jahr-$Monat-$Tag $Stunde:$Minute" - # PAC = '-0357' bedeutet: 357 W Bezug, 0 W Einspeisung - # PAC = '0246' bedeutet: 0 W Bezug, 246 W Einspeisung - power=$( awk "BEGIN{print -1 * $PAC}") - energy_day=$( awk "BEGIN{print 1000 * $KDY}") - energy_month=$(awk "BEGIN{print 1000 * $KMT}") - energy_year=$( awk "BEGIN{print 1000 * $KYR}") - energy_total=$(awk "BEGIN{print 1000 * $KT0}") - mpptracker1_voltage=$(printf "%.0f" "$UDC") - mpptracker1_current=$(printf "%.1f" "$IDC") - mpptracker2_voltage=$(printf "%.0f" "$UDCB") - mpptracker2_current=$(printf "%.1f" "$IDCB") - mpptracker3_voltage=$(printf "%.0f" "$UDCC") - mpptracker3_current=$(printf "%.1f" "$IDCC") - mpptracker4_voltage=$(printf "%.0f" "$UDCD") - mpptracker4_current=$(printf "%.1f" "$IDCD") - temperature=$( printf "%.0f" "$TKK") - - if [ "$debug" -ne 0 ]; then - # Werte ausgeben - log "ID: $id" - log "Zeitpunkt: $timestamp" - log "Temperatur: $temperature °C" - log "Leistung: $power W" - log "Energie:" - log " Tag: $energy_day Wh" - log " Monat: $energy_month Wh" - log " Jahr: $energy_year Wh" - log " Gesamt: $energy_total Wh" - log "Generator-MPP-Tracker-1" - log " Spannung: $mpptracker1_voltage V" - log " Strom: $mpptracker1_current A" - log "Generator-MPP-Tracker-2" - log " Spannung: $mpptracker2_voltage V" - log " Strom: $mpptracker2_current A" - log "Generator-MPP-Tracker-3" - log " Spannung: $mpptracker3_voltage V" - log " Strom: $mpptracker3_current A" - log "Generator-MPP-Tracker-4" - log " Spannung: $mpptracker4_voltage V" - log " Strom: $mpptracker4_current A" - fi - - # Werte speichern - if [ "$command" = "$command_einspeisung" ]; then - echo "$energy_total" >"$target/einspeisungkwh" - elif [ "$command" = "$command_bezug" ]; then - echo "$power" >"$target/wattbezug" - echo "$energy_total" >"$target/bezugkwh" - echo "$grid1_current" >"$target/bezuga1" - echo "$grid2_current" >"$target/bezuga2" - echo "$grid3_current" >"$target/bezuga3" - echo "$grid1_voltage" >"$target/evuv1" - echo "$grid2_voltage" >"$target/evuv2" - echo "$grid3_voltage" >"$target/evuv3" - fi - - # Aktuelle Leistung an der Aufrufer zurückliefern - echo "$power" - done + command="$1" + port="${solarview_port:-15000}" + timeout="${solarview_timeout:-1}" + + response=$(echo "$command" | nc -w "$timeout" "$solarview_hostname" "$port") + return_code="$?" + if [ "$return_code" -ne 0 ]; then + log "Error: request to SolarView failed. Details: return-code: '$return_code', host: '$solarview_hostname', port: '$port', timeout: '$timeout'" + return "$return_code" + fi + + [ "$debug" -ne 0 ] && log "Raw response: $response" + # + # Format: {WR,Tag,Monat,Jahr,Stunde,Minute,KDY,KMT,KYR,KT0,PAC,UDC,IDC,UDCB,IDCB,UDCC,IDCC,UDCD,IDCD,TKK},Checksum + # Beispiele: {22,09,09,2019,10,37,0001.2,00024,000903,00007817,01365,000,000.0,000,000.0,000,000.0,000,000.0,00},: + # {21,09,09,2019,10,37,0002.3,00141,004233,00029525,01365,000,000.0,000,000.0,000,000.0,000,000.0,00},; + # + # Bedeutung (siehe SolarView-Dokumentation): + # KDY= Tagesertrag (kWh) + # KMT= Monatsertrag (kWh) + # KYR= Jahresertrag (kWh) + # KT0= Gesamtertrag (kWh) + # PAC= Generatorleistung in W + # UDC, UDCB, UDCC, UDCD= Generator-Spannungen in Volt pro MPP-Tracker + # IDC, IDCB, IDCC, IDCD= Generator-Ströme in Ampere pro MPP-Tracker + # TKK= Temperatur Wechselrichter + + # Geschweifte Klammern und Checksumme entfernen + values="${response#*\{}" + values="${values%\}*}" + + # Werte auslesen und verarbeiten + local LANG=C + echo "$values" | while IFS=',' read -r WR Tag Monat Jahr Stunde Minute KDY KMT KYR KT0 PAC UDC IDC UDCB IDCB UDCC IDCC UDCD IDCD TKK + do + # Werte formatiert in Variablen speichern + id="$WR" + timestamp="$Jahr-$Monat-$Tag $Stunde:$Minute" + # PAC = '-0357' bedeutet: 357 W Bezug, 0 W Einspeisung + # PAC = '0246' bedeutet: 0 W Bezug, 246 W Einspeisung + power=$( awk "BEGIN{print -1 * $PAC}") + energy_day=$( awk "BEGIN{print 1000 * $KDY}") + energy_month=$(awk "BEGIN{print 1000 * $KMT}") + energy_year=$( awk "BEGIN{print 1000 * $KYR}") + energy_total=$(awk "BEGIN{print 1000 * $KT0}") + mpptracker1_voltage=$(printf "%.0f" "$UDC") + mpptracker1_current=$(printf "%.1f" "$IDC") + mpptracker2_voltage=$(printf "%.0f" "$UDCB") + mpptracker2_current=$(printf "%.1f" "$IDCB") + mpptracker3_voltage=$(printf "%.0f" "$UDCC") + mpptracker3_current=$(printf "%.1f" "$IDCC") + mpptracker4_voltage=$(printf "%.0f" "$UDCD") + mpptracker4_current=$(printf "%.1f" "$IDCD") + temperature=$( printf "%.0f" "$TKK") + + if [ "$debug" -ne 0 ]; then + # Werte ausgeben + log "ID: $id" + log "Zeitpunkt: $timestamp" + log "Temperatur: $temperature °C" + log "Leistung: $power W" + log "Energie:" + log " Tag: $energy_day Wh" + log " Monat: $energy_month Wh" + log " Jahr: $energy_year Wh" + log " Gesamt: $energy_total Wh" + log "Generator-MPP-Tracker-1" + log " Spannung: $mpptracker1_voltage V" + log " Strom: $mpptracker1_current A" + log "Generator-MPP-Tracker-2" + log " Spannung: $mpptracker2_voltage V" + log " Strom: $mpptracker2_current A" + log "Generator-MPP-Tracker-3" + log " Spannung: $mpptracker3_voltage V" + log " Strom: $mpptracker3_current A" + log "Generator-MPP-Tracker-4" + log " Spannung: $mpptracker4_voltage V" + log " Strom: $mpptracker4_current A" + fi + + # Werte speichern + if [ "$command" = "$command_einspeisung" ]; then + echo "$energy_total" >"$target/einspeisungkwh" + elif [ "$command" = "$command_bezug" ]; then + echo "$power" >"$target/wattbezug" + echo "$energy_total" >"$target/bezugkwh" + echo "$grid1_current" >"$target/bezuga1" + echo "$grid2_current" >"$target/bezuga2" + echo "$grid3_current" >"$target/bezuga3" + echo "$grid1_voltage" >"$target/evuv1" + echo "$grid2_voltage" >"$target/evuv2" + echo "$grid3_voltage" >"$target/evuv3" + fi + + # Aktuelle Leistung an der Aufrufer zurückliefern + echo "$power" + done } request "$command_einspeisung" >/dev/null diff --git a/modules/bezug_solarwatt/main.sh b/modules/bezug_solarwatt/main.sh index 0f4333bad..2a7fd14fb 100644 --- a/modules/bezug_solarwatt/main.sh +++ b/modules/bezug_solarwatt/main.sh @@ -14,7 +14,6 @@ DebugLog(){ fi } - if (( $solarwattmethod == 0 )); then #Abruf über Energy Manager sresponse=$(curl --connect-timeout 3 -s "http://${speicher1_ip}/rest/kiwigrid/wizard/devices") diff --git a/modules/bezug_solarworld/main.sh b/modules/bezug_solarworld/main.sh index 351593423..65b4e69b0 100644 --- a/modules/bezug_solarworld/main.sh +++ b/modules/bezug_solarworld/main.sh @@ -14,7 +14,7 @@ bezug_watt=$(LC_ALL=C printf "%.0f\n" $(echo "$em_in_watt - $em_out_watt" | bc)) ra='^-?[0-9]+$' if ! [[ $bezug_watt =~ $ra ]] ; then - bezug_watt="0" + bezug_watt="0" fi echo $bezug_watt echo $bezug_watt > /var/www/html/openWB/ramdisk/wattbezug diff --git a/modules/bezug_solax/solax.py b/modules/bezug_solax/solax.py index 617b03d4c..d3555070d 100644 --- a/modules/bezug_solax/solax.py +++ b/modules/bezug_solax/solax.py @@ -1,13 +1,11 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import struct -import binascii - - +# import os +# import time +# import getopt +# import socket +# import struct +# import binascii from pymodbus.client.sync import ModbusTcpClient from pymodbus.factory import ClientDecoder @@ -29,7 +27,7 @@ def signed16(result, addr): def signed32(result, addr): val = unsigned32(result, addr) if val > 2147483647: - val -= 4294967295 + val -= 4294967295 return val ipaddress = str(sys.argv[1]) diff --git a/modules/bezug_sonneneco/main.sh b/modules/bezug_sonneneco/main.sh index 82586a3a3..cfd3d1dbf 100644 --- a/modules/bezug_sonneneco/main.sh +++ b/modules/bezug_sonneneco/main.sh @@ -12,7 +12,6 @@ if (( sonnenecoalternativ == 2 )); then echo $wattbezug > /var/www/html/openWB/ramdisk/wattbezug echo $wattbezug else - if (( sonnenecoalternativ == 1 )); then speicherantwort=$(curl --connect-timeout 5 -s "$sonnenecoip/api/v1/status") wattbezug=$(echo $speicherantwort | jq .GridFeedIn_W) diff --git a/modules/bezug_sungrow/main.sh b/modules/bezug_sungrow/main.sh index 9d401edb6..366ecdcf4 100644 --- a/modules/bezug_sungrow/main.sh +++ b/modules/bezug_sungrow/main.sh @@ -1,6 +1,5 @@ #!/bin/bash - + python /var/www/html/openWB/modules/bezug_sungrow/sungrow.py $speicher1_ip $sungrowsr wattbezug=$(i', all.decode('hex'))[0]) - else: resp= client.read_input_registers(13009,2,unit=1) value1 = resp.registers[0] @@ -29,5 +30,3 @@ f = open('/var/www/html/openWB/ramdisk/wattbezug', 'w') f.write(str(final)) f.close() - - diff --git a/modules/bezug_varta/main.sh b/modules/bezug_varta/main.sh index 60217ef3f..dc794e46d 100755 --- a/modules/bezug_varta/main.sh +++ b/modules/bezug_varta/main.sh @@ -1,10 +1,5 @@ #!/bin/bash - - python /var/www/html/openWB/modules/bezug_varta/varta.py $vartaspeicherip wattbezug=$( /var/www/html/openWB/ramdisk/llv1 echo $VPhase2 > /var/www/html/openWB/ramdisk/llv2 @@ -44,8 +43,6 @@ if [[ $(wc -l /var/www/html/openWB/ramdisk/chargestat soc=$( /var/www/html/openWB/ramdisk/llvs11 @@ -60,7 +57,6 @@ if [[ $(wc -l /var/www/html/openWB/ramdisk/chargestats1 soc=$( /var/www/html/openWB/ramdisk/llvs21 @@ -73,7 +69,6 @@ if [[ $(wc -l /var/www/html/openWB/ramdisk/llkwhs2 echo $boolPlugStat > /var/www/html/openWB/ramdisk/plugstatlp3 echo $boolChargeStat > /var/www/html/openWB/ramdisk/chargestatlp3 - fi if (( chargep > "3" ));then echo $VPhase1 > /var/www/html/openWB/ramdisk/llv1lp$chargep @@ -86,7 +81,6 @@ if [[ $(wc -l /var/www/html/openWB/ramdisk/llkwhlp$chargep echo $boolPlugStat > /var/www/html/openWB/ramdisk/plugstatlp$chargep echo $boolChargeStat > /var/www/html/openWB/ramdisk/chargestatlp$chargep - fi if ! [ -z $LastScannedRfidTag ] && [ $LastScannedRfidTag -ge "3" ]; then echo $LastScannedRfidTag > /var/www/html/openWB/ramdisk/readtag @@ -100,13 +94,11 @@ if [[ $(wc -l /var/www/html/openWB/ramdisk/errcounterextopenwb - else - openwbModulePublishState "LP" 1 "Keine Daten vom LP erhalten, IP Korrekt?" $chargep - openwbDebugLog "MAIN" 0 "Keine Daten von externe openWB LP $chargep empfangen" + openwbModulePublishState "LP" 1 "Keine Daten vom LP erhalten, IP Korrekt?" $chargep + openwbDebugLog "MAIN" 0 "Keine Daten von externe openWB LP $chargep empfangen" errcounter=$( /var/www/html/openWB/ramdisk/errcounterextopenwb @@ -114,4 +106,3 @@ else echo "Fehler bei Auslesung externe openWB LP $chargep, Netzwerk oder Konfiguration prüfen" > /var/www/html/openWB/ramdisk/lastregelungaktiv fi fi - diff --git a/modules/fsm63a3modbusll/main.sh b/modules/fsm63a3modbusll/main.sh index b06ae4ada..b6dc0c297 100755 --- a/modules/fsm63a3modbusll/main.sh +++ b/modules/fsm63a3modbusll/main.sh @@ -1,12 +1,5 @@ #!/bin/bash -### TODO: The following variables need to be added to "openwb.conf": -# fsm63a3modbusllsource=... (e.g. "/dev/ttyUSB0") -# fsm63a3modbusllid=... (e.g. "2") -### Furthermore the following value in "openwb.conf" has to be set manually: -# ladeleistungmodul=fsm63a3modbusll -### If once all three values can be set up via the GUI (needs to be done by snaptec), these 6 lines can be deleted. - if [[ $fsm63a3llsource = *virtual* ]] then if ps ax |grep -v grep |grep "socat pty,link=$fsm63a3llsource,raw tcp:$fsm63a3modbuslllanip:26" > /dev/null @@ -23,4 +16,3 @@ fi ramdiskpath="/var/www/html/openWB/ramdisk" sudo python /var/www/html/openWB/modules/fsm63a3modbusll/readfsm63a3.py $fsm63a3modbusllsource $fsm63a3modbusllid $ramdiskpath - diff --git a/modules/fsm63a3modbusll/readfsm63a3.py b/modules/fsm63a3modbusll/readfsm63a3.py index 50b0b8fdc..655b63bd7 100755 --- a/modules/fsm63a3modbusll/readfsm63a3.py +++ b/modules/fsm63a3modbusll/readfsm63a3.py @@ -3,7 +3,7 @@ from pymodbus.client.sync import ModbusSerialClient from pymodbus.payload import BinaryPayloadDecoder from pymodbus.constants import Endian -import math +# import math # Set debug to "1" to enable debugging messages debug = 0 @@ -59,8 +59,7 @@ # value = [decoded_value, decoded_value_string] value_dict = {} -client = ModbusSerialClient(method = "rtu", port=mb_port, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) +client = ModbusSerialClient(method = "rtu", port=mb_port, baudrate=9600, stopbits=1, bytesize=8, timeout=1) #client.connect() @@ -78,9 +77,7 @@ decoded_value = 0 decoded_value_str = '0' else: - decoder = BinaryPayloadDecoder.fromRegisters(result.registers, - byteorder=Endian.Big, - wordorder=Endian.Big) + decoder = BinaryPayloadDecoder.fromRegisters(result.registers, byteorder=Endian.Big, wordorder=Endian.Big) # Check the datatype (default is unsigned int 32 bit) if value[4] == 'U16': decoded_value_raw = decoder.decode_16bit_uint() @@ -108,5 +105,5 @@ f = open(ramdiskpath + '/' + value[0], 'w') f.write(value_dict[value[0]][1]) f.close() - + #client.close() diff --git a/modules/goelp1/main.sh b/modules/goelp1/main.sh index 3d90ff2b3..e81cb7a39 100755 --- a/modules/goelp1/main.sh +++ b/modules/goelp1/main.sh @@ -36,7 +36,6 @@ if [[ $? == "0" ]] ; then if [[ $llv3 =~ $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 @@ -48,10 +47,10 @@ if [[ $? == "0" ]] ; then echo $rfid > /var/www/html/openWB/ramdisk/readtag echo $rfid > /var/www/html/openWB/ramdisk/tmpgoelp1rfid fi -#car status 1 Ladestation bereit, kein Auto -#car status 2 Auto lädt -#car status 3 Warte auf Fahrzeug -#car status 4 Ladung beendet, Fahrzeug verbunden + #car status 1 Ladestation bereit, kein Auto + #car status 2 Auto lädt + #car status 3 Warte auf Fahrzeug + #car status 4 Ladung beendet, Fahrzeug verbunden car=$(echo $output | jq -r '.car') if [[ $car == "1" ]] ; then echo 0 > /var/www/html/openWB/ramdisk/plugstat diff --git a/modules/goelp2/main.sh b/modules/goelp2/main.sh index 076fa41d8..d61ddf587 100755 --- a/modules/goelp2/main.sh +++ b/modules/goelp2/main.sh @@ -36,16 +36,15 @@ if [[ $? == "0" ]] ; then if [[ $llv3 =~ $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 -#car status 1 Ladestation bereit, kein Auto -#car status 2 Auto lädt -#car status 3 Warte auf Fahrzeug -#car status 4 Ladung beendet, Fahrzeug verbunden + #car status 1 Ladestation bereit, kein Auto + #car status 2 Auto lädt + #car status 3 Warte auf Fahrzeug + #car status 4 Ladung beendet, Fahrzeug verbunden car=$(echo $output | jq -r '.car') if [[ $car == "1" ]] ; then echo 0 > /var/www/html/openWB/ramdisk/plugstats1 diff --git a/modules/goelp3/main.sh b/modules/goelp3/main.sh index 94c2ec270..75a87c1cc 100755 --- a/modules/goelp3/main.sh +++ b/modules/goelp3/main.sh @@ -36,16 +36,15 @@ if [[ $? == "0" ]] ; then if [[ $llv3 =~ $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 -#car status 1 Ladestation bereit, kein Auto -#car status 2 Auto lädt -#car status 3 Warte auf Fahrzeug -#car status 4 Ladung beendet, Fahrzeug verbunden + #car status 1 Ladestation bereit, kein Auto + #car status 2 Auto lädt + #car status 3 Warte auf Fahrzeug + #car status 4 Ladung beendet, Fahrzeug verbunden car=$(echo $output | jq -r '.car') if [[ $car == "1" ]] ; then echo 0 > /var/www/html/openWB/ramdisk/plugstatlp3 diff --git a/modules/httpll/main.sh b/modules/httpll/main.sh index 6867fc223..f61155a07 100755 --- a/modules/httpll/main.sh +++ b/modules/httpll/main.sh @@ -4,40 +4,38 @@ re='^[-+]?[0-9]+\.?[0-9]*$' r2e='^-?[0-9]+$' wattll=$(curl --connect-timeout 3 -s $httpll_w_url) if ! [[ $wattll =~ $re ]] ; then - wattll="0" + wattll="0" fi echo $wattll > /var/www/html/openWB/ramdisk/llaktuell kwhll=$(curl --connect-timeout 3 -s $httpll_kwh_url) if ! [[ $kwhll =~ $re ]] ; then - kwhll="0" + kwhll="0" fi echo $kwhll > /var/www/html/openWB/ramdisk/llkwh a1ll=$(curl --connect-timeout 3 -s $httpll_a1_url) if ! [[ $a1ll =~ $re ]] ; then - a1ll="0" + a1ll="0" fi echo $a1ll > /var/www/html/openWB/ramdisk/lla1 a2ll=$(curl --connect-timeout 3 -s $httpll_a2_url) if ! [[ $a2ll =~ $re ]] ; then - a1ll="0" + a1ll="0" fi echo $a2ll > /var/www/html/openWB/ramdisk/lla2 a3ll=$(curl --connect-timeout 3 -s $httpll_a3_url) if ! [[ $a3ll =~ $re ]] ; then - a3ll="0" + a3ll="0" fi echo $a3ll > /var/www/html/openWB/ramdisk/lla3 plugstat=$(curl --connect-timeout 2 -s $httpll_ip/plugstat) chargestat=$(curl --connect-timeout 2 -s $httpll_ip/chargestat) if ! [[ $plugstat =~ $r2e ]] ; then - plugstat="0" + plugstat="0" fi if ! [[ $chargestat =~ $r2e ]] ; then - chargestat="0" + chargestat="0" fi echo $plugstat > /var/www/html/openWB/ramdisk/plugstat echo $chargestat > /var/www/html/openWB/ramdisk/chargestat - - diff --git a/modules/keballlp1/check502.py b/modules/keballlp1/check502.py index 9cc4bcb43..bf96b3949 100644 --- a/modules/keballlp1/check502.py +++ b/modules/keballlp1/check502.py @@ -1,19 +1,23 @@ #!/usr/bin/python3 import sys -import os +# import os import time -import getopt +# import getopt import socket + named_tuple = time.localtime() # getstruct_time time_string = time.strftime("%m/%d/%Y, %H:%M:%S check502.py", named_tuple) + ipaddress = str(sys.argv[1]) file_string= '/var/www/html/openWB/ramdisk/port_502_' + ipaddress + try: f = open( file_string , 'r') port =int(f.read()) f.close() except: port = 9 + if (port == 1) or (port == 0): pass else: diff --git a/modules/keballlp1/info.py b/modules/keballlp1/info.py index f655e7b72..209f2d20f 100644 --- a/modules/keballlp1/info.py +++ b/modules/keballlp1/info.py @@ -1,21 +1,25 @@ #!/usr/bin/python3 import sys -import os +# import os import time import json -import getopt -import socket -import struct -import codecs -import binascii +# import getopt +# import socket +# import struct +# import codecs +# import binascii from pymodbus.client.sync import ModbusTcpClient from pymodbus.constants import Endian from pymodbus.payload import BinaryPayloadDecoder + named_tuple = time.localtime() # getstruct_time time_string = time.strftime("%m/%d/%Y, %H:%M:%S keba info.py", named_tuple) + lpnumber=int(sys.argv[1]) ipaddress=str(sys.argv[2]) + client = ModbusTcpClient(ipaddress, port=502) + # total energy 1036 resp= client.read_holding_registers(1036,2,unit=255) if (lpnumber ==1): @@ -28,6 +32,7 @@ powerc = str(final3) f.write(powerc) f.close() + # active power 1020 resp= client.read_holding_registers(1020,2,unit=255) if (lpnumber ==1): @@ -40,6 +45,7 @@ power = str(final3) f.write(power) f.close() + # voltage l1 1040 resp= client.read_holding_registers(1040,2,unit=255) if (lpnumber ==1): @@ -52,6 +58,7 @@ v1 = str(final3) f.write(v1) f.close() + # voltage l2 1042 resp= client.read_holding_registers(1042,2,unit=255) if (lpnumber ==1): @@ -64,6 +71,7 @@ v2 = str(final3) f.write(v2) f.close() + # voltage l3 1044 resp= client.read_holding_registers(1044,2,unit=255) if (lpnumber ==1): @@ -76,6 +84,7 @@ v3 = str(final3) f.write(v3) f.close() + # amp l1 1008 resp= client.read_holding_registers(1008,2,unit=255) if (lpnumber ==1): @@ -88,6 +97,7 @@ a1= str(final3) f.write(a1) f.close() + # amp l2 1010 resp= client.read_holding_registers(1010,2,unit=255) if (lpnumber ==1): @@ -100,6 +110,7 @@ a2= str(final3) f.write(a2) f.close() + # amp l3 1012 resp= client.read_holding_registers(1012,2,unit=255) if (lpnumber ==1): @@ -112,6 +123,7 @@ a3= str(final3) f.write(a3) f.close() + # charging state 1000 resp= client.read_holding_registers(1000,2,unit=255) if (lpnumber ==1): @@ -127,6 +139,7 @@ chargestat = 0 f.write(str(chargestat)) f.close() + # cabel state 1004 resp= client.read_holding_registers(1004,2,unit=255) if (lpnumber ==1): @@ -142,31 +155,37 @@ plugstat = 0 f.write(str(plugstat)) f.close() + # maxcurr 1100 resp= client.read_holding_registers(1100,2,unit=255) decoder = BinaryPayloadDecoder.fromRegisters(resp.registers,byteorder=Endian.Big,wordorder=Endian.Big) final2 = float( decoder.decode_32bit_uint()) / 1000 maxcur = "%.f" % final2 + # max supported curr 1110 resp= client.read_holding_registers(1110,2,unit=255) decoder = BinaryPayloadDecoder.fromRegisters(resp.registers,byteorder=Endian.Big,wordorder=Endian.Big) final2 = float( decoder.decode_32bit_uint()) / 1000 supcur = "%.f" % final2 + # hwinfo 1016 resp= client.read_holding_registers(1016,2,unit=255) decoder = BinaryPayloadDecoder.fromRegisters(resp.registers,byteorder=Endian.Big,wordorder=Endian.Big) final2 = float( decoder.decode_32bit_uint()) hwinfo= "%.f" % final2 + # error info 1006 resp= client.read_holding_registers(1006,2,unit=255) decoder = BinaryPayloadDecoder.fromRegisters(resp.registers,byteorder=Endian.Big,wordorder=Endian.Big) final2 = float( decoder.decode_32bit_uint()) errinfo= "%8X" % int(final2) + # rfid info 1500 resp= client.read_holding_registers(1500,2,unit=255) decoder = BinaryPayloadDecoder.fromRegisters(resp.registers,byteorder=Endian.Big,wordorder=Endian.Big) final2 = float( decoder.decode_32bit_uint()) rfidinfo= "%8X" % int(final2) + answer = '{"maxcur":' + str(maxcur) + ',"supcur":' + str(supcur) + ',"hwinfo":' + str(hwinfo) + ',"Error":' + str(errinfo) + ',"plugstat":' + str(plugstat) + ',"chargestat":' + str(chargestat) + ',"rfid":' + str(rfidinfo) + ',"powerc":' + powerc + ',"power":' + power + ',"V1":' + v1 + ',"V2":' + v2 + ',"V3":' + v3 + ',"A1":' + a1 + ',"A2":' + a2 + ',"A3":' + a3 +'} ' if (lpnumber ==1): f = open('/var/www/html/openWB/ramdisk/kebainfolp1', 'w') diff --git a/modules/keballlp1/main.sh b/modules/keballlp1/main.sh index b385d4ca6..70973d5eb 100644 --- a/modules/keballlp1/main.sh +++ b/modules/keballlp1/main.sh @@ -14,174 +14,174 @@ esac sudo python3 /var/www/html/openWB/modules/keballlp1/check502.py $ipadr >> /var/www/html/openWB/ramdisk/port.log 2>&1 modbus=$(> /var/www/html/openWB/ramdisk/port.log - sudo python3 /var/www/html/openWB/modules/keballlp1/info.py $CHARGEPOINT $ipadr >> /var/www/html/openWB/ramdisk/port.log 2>&1 + #echo "startet kebanow $CHARGEPOINT $ipadr " >> /var/www/html/openWB/ramdisk/port.log + sudo python3 /var/www/html/openWB/modules/keballlp1/info.py $CHARGEPOINT $ipadr >> /var/www/html/openWB/ramdisk/port.log 2>&1 else - # echo " modbus aus / chargepoint both" - rekwh='^[-+]?[0-9]+\.?[0-9]*$' - re='^-?[0-9]+$' - counter=0 - while [[ -e /var/www/html/openWB/ramdisk/kebasync && $counter < 4 ]]; do - sleep 1 - counter=$((counter + 1)) - done - echo 0 > /var/www/html/openWB/ramdisk/kebasync - if [[ $counter == "4" ]] ; then - dtime=$(date +"%T") - echo " $dtime keba sleep overrun " - fi + # echo " modbus aus / chargepoint both" + rekwh='^[-+]?[0-9]+\.?[0-9]*$' + re='^-?[0-9]+$' + counter=0 + while [[ -e /var/www/html/openWB/ramdisk/kebasync && $counter < 4 ]]; do + sleep 1 + counter=$((counter + 1)) + done + echo 0 > /var/www/html/openWB/ramdisk/kebasync + if [[ $counter == "4" ]] ; then dtime=$(date +"%T") - #echo " $dtime keba1 status $kebaiplp1 " - nc -ul 7090 >/var/www/html/openWB/ramdisk/keballlp$CHARGEPOINT & - pidnc=$! - disown + echo " $dtime keba sleep overrun " + fi + dtime=$(date +"%T") + #echo " $dtime keba1 status $kebaiplp1 " + nc -ul 7090 >/var/www/html/openWB/ramdisk/keballlp$CHARGEPOINT & + pidnc=$! + disown - echo -n "report 3" | socat - UDP-DATAGRAM:$ipadr:7090 - sleep 1 - outputte1=$(tr -d '\0' /var/www/html/openWB/ramdisk/keballlr3lp$CHARGEPOINT - output=$(echo $outputte1 | tr -d '\n' | sed 's/\}.*/\}/') - echo $output > /var/www/html/openWB/ramdisk/keballlr3xlp$CHARGEPOINT - echo -n > /var/www/html/openWB/ramdisk/keballlp$CHARGEPOINT - #read plug and chargingstatus - echo -n "report 2" | socat - UDP-DATAGRAM:$ipadr:7090 - sleep 1 - outputte1=$(tr -d '\0' /var/www/html/openWB/ramdisk/keballlr2lp$CHARGEPOINT - output1=$(echo $outputte1 | tr -d '\n' | sed 's/\}.*/\}/') - echo $output1 > /var/www/html/openWB/ramdisk/keballlr2xlp$CHARGEPOINT - kill $pidnc - rm /var/www/html/openWB/ramdisk/keballlp$CHARGEPOINT - rm /var/www/html/openWB/ramdisk/kebasync - rep3=$(echo $output | jq '.ID') - rep2=$(echo $output1 | jq '.ID') - rep3="${rep3%\"}" - rep3="${rep3#\"}" - rep2="${rep2%\"}" - rep2="${rep2#\"}" - if [[ $CHARGEPOINT == "1" ]] ; then - if [[ $rep3 == "3" ]] ; then - watt=$(echo $output | jq '.P') - watt=$(echo "($watt / 1000)/1" |bc) - if [[ $watt =~ $rekwh ]] ; then - echo $watt > /var/www/html/openWB/ramdisk/llaktuell - fi - lla1=$(echo $output | jq '.I1') - lla1=$(echo "scale=2;$lla1 / 1000" |bc) - lla2=$(echo $output | jq '.I2') - lla2=$(echo "scale=2;$lla2 / 1000" |bc) - lla3=$(echo $output | jq '.I3') - lla3=$(echo "scale=2;$lla3 / 1000" |bc) - if [[ $lla1 =~ $rekwh ]] ; then - echo $lla1 > /var/www/html/openWB/ramdisk/lla1 - fi - if [[ $lla2 =~ $rekwh ]] ; then - echo $lla2 > /var/www/html/openWB/ramdisk/lla2 - fi - if [[ $lla3 =~ $rekwh ]] ; then - echo $lla3 > /var/www/html/openWB/ramdisk/lla3 - fi - llv1=$(echo $output | jq '.U1') - llv2=$(echo $output | jq '.U2') - llv3=$(echo $output | jq '.U3') - if [[ $llv1 =~ $re ]] ; then - echo $llv1 > /var/www/html/openWB/ramdisk/llv1 - fi - if [[ $llv2 =~ $re ]] ; then - echo $llv2 > /var/www/html/openWB/ramdisk/llv2 - fi - if [[ $llv3 =~ $re ]] ; then - echo $llv3 > /var/www/html/openWB/ramdisk/llv3 - fi - chargedwh=$(echo $output | jq '."E pres"') - # totalwh=$(echo $output | jq '."E total"') - # llwh=$(echo $chargedwh + $totalwh | bc) + echo -n "report 3" | socat - UDP-DATAGRAM:$ipadr:7090 + sleep 1 + outputte1=$(tr -d '\0' /var/www/html/openWB/ramdisk/keballlr3lp$CHARGEPOINT + output=$(echo $outputte1 | tr -d '\n' | sed 's/\}.*/\}/') + echo $output > /var/www/html/openWB/ramdisk/keballlr3xlp$CHARGEPOINT + echo -n > /var/www/html/openWB/ramdisk/keballlp$CHARGEPOINT + #read plug and chargingstatus + echo -n "report 2" | socat - UDP-DATAGRAM:$ipadr:7090 + sleep 1 + outputte1=$(tr -d '\0' /var/www/html/openWB/ramdisk/keballlr2lp$CHARGEPOINT + output1=$(echo $outputte1 | tr -d '\n' | sed 's/\}.*/\}/') + echo $output1 > /var/www/html/openWB/ramdisk/keballlr2xlp$CHARGEPOINT + kill $pidnc + rm /var/www/html/openWB/ramdisk/keballlp$CHARGEPOINT + rm /var/www/html/openWB/ramdisk/kebasync + rep3=$(echo $output | jq '.ID') + rep2=$(echo $output1 | jq '.ID') + rep3="${rep3%\"}" + rep3="${rep3#\"}" + rep2="${rep2%\"}" + rep2="${rep2#\"}" + if [[ $CHARGEPOINT == "1" ]] ; then + if [[ $rep3 == "3" ]] ; then + watt=$(echo $output | jq '.P') + watt=$(echo "($watt / 1000)/1" |bc) + if [[ $watt =~ $rekwh ]] ; then + echo $watt > /var/www/html/openWB/ramdisk/llaktuell + fi + lla1=$(echo $output | jq '.I1') + lla1=$(echo "scale=2;$lla1 / 1000" |bc) + lla2=$(echo $output | jq '.I2') + lla2=$(echo "scale=2;$lla2 / 1000" |bc) + lla3=$(echo $output | jq '.I3') + lla3=$(echo "scale=2;$lla3 / 1000" |bc) + if [[ $lla1 =~ $rekwh ]] ; then + echo $lla1 > /var/www/html/openWB/ramdisk/lla1 + fi + if [[ $lla2 =~ $rekwh ]] ; then + echo $lla2 > /var/www/html/openWB/ramdisk/lla2 + fi + if [[ $lla3 =~ $rekwh ]] ; then + echo $lla3 > /var/www/html/openWB/ramdisk/lla3 + fi + llv1=$(echo $output | jq '.U1') + llv2=$(echo $output | jq '.U2') + llv3=$(echo $output | jq '.U3') + if [[ $llv1 =~ $re ]] ; then + echo $llv1 > /var/www/html/openWB/ramdisk/llv1 + fi + if [[ $llv2 =~ $re ]] ; then + echo $llv2 > /var/www/html/openWB/ramdisk/llv2 + fi + if [[ $llv3 =~ $re ]] ; then + echo $llv3 > /var/www/html/openWB/ramdisk/llv3 + fi + chargedwh=$(echo $output | jq '."E pres"') + # totalwh=$(echo $output | jq '."E total"') + # llwh=$(echo $chargedwh + $totalwh | bc) - llwh=$(echo $output | jq '."E total"') - llkwh=$(echo "scale=3;$llwh / 10000" | bc -l) - if [[ $llkwh =~ $rekwh ]] ; then - echo $llkwh > /var/www/html/openWB/ramdisk/llkwh - fi - fi - if [[ $rep2 == "2" ]] ; then - newplug=$(echo $output1 | jq '.Plug') - newstatus=$(echo $output1 | jq '.State') + llwh=$(echo $output | jq '."E total"') + llkwh=$(echo "scale=3;$llwh / 10000" | bc -l) + if [[ $llkwh =~ $rekwh ]] ; then + echo $llkwh > /var/www/html/openWB/ramdisk/llkwh + fi + fi + if [[ $rep2 == "2" ]] ; then + newplug=$(echo $output1 | jq '.Plug') + newstatus=$(echo $output1 | jq '.State') #echo $output1 > /var/www/html/openWB/ramdisk/kebaoutput1 #Plug Status 3 Kabel ist eingesteckt an der Ladestation, kein Auto #Plug Status 7 Kabel ist eingesteckt Ladestation und Auto verriegelt. #Status 2 ready for charging #Status 3 charging - if [[ $newplug == "7" ]] ; then - echo 1 > /var/www/html/openWB/ramdisk/plugstat - else - echo 0 > /var/www/html/openWB/ramdisk/plugstat - fi - if [[ $newstatus == "3" ]] ; then - echo 1 > /var/www/html/openWB/ramdisk/chargestat - else - echo 0 > /var/www/html/openWB/ramdisk/chargestat - fi - fi - else - if [[ $rep3 == "3" ]] ; then - watt=$(echo $output | jq '.P') - watt=$(echo "($watt / 1000)/1" |bc) - if [[ $watt =~ $rekwh ]] ; then - echo $watt > /var/www/html/openWB/ramdisk/llaktuells1 - fi - lla1=$(echo $output | jq '.I1') - lla1=$(echo "scale=2;$lla1 / 1000" |bc) - lla2=$(echo $output | jq '.I2') - lla2=$(echo "scale=2;$lla2 / 1000" |bc) - lla3=$(echo $output | jq '.I3') - lla3=$(echo "scale=2;$lla3 / 1000" |bc) - if [[ $lla1 =~ $rekwh ]] ; then - echo $lla1 > /var/www/html/openWB/ramdisk/llas11 - fi - if [[ $lla2 =~ $rekwh ]] ; then - echo $lla2 > /var/www/html/openWB/ramdisk/llas12 - fi - if [[ $lla3 =~ $rekwh ]] ; then - echo $lla3 > /var/www/html/openWB/ramdisk/llas13 - fi - llv1=$(echo $output | jq '.U1') - llv2=$(echo $output | jq '.U2') - llv3=$(echo $output | jq '.U3') - if [[ $llv1 =~ $re ]] ; then - echo $llv1 > /var/www/html/openWB/ramdisk/llvs11 - fi - if [[ $llv2 =~ $re ]] ; then - echo $llv2 > /var/www/html/openWB/ramdisk/llvs12 - fi - if [[ $llv3 =~ $re ]] ; then - echo $llv3 > /var/www/html/openWB/ramdisk/llvs13 - fi - chargedwh=$(echo $output | jq '."E pres"') - # totalwh=$(echo $output | jq '."E total"') - # llwh=$(echo $chargedwh + $totalwh | bc) - llwh=$(echo $output | jq '."E total"') - llkwh=$(echo "scale=3;$llwh / 10000" | bc -l) - if [[ $llkwh =~ $rekwh ]] ; then - echo $llkwh > /var/www/html/openWB/ramdisk/llkwhs1 - fi - fi - if [[ $rep2 == "2" ]] ; then - newplug=$(echo $output1 | jq '.Plug') - newstatus=$(echo $output1 | jq '.State') - #Plug Status 3 Kabel ist eingesteckt an der Ladestation, kein Auto - #Plug Status 7 Kabel ist eingesteckt Ladestation und Auto verriegelt. - #Status 2 ready for charging - #Status 3 charging - if [[ $newplug == "7" ]] ; then - echo 1 > /var/www/html/openWB/ramdisk/plugstats1 - else - echo 0 > /var/www/html/openWB/ramdisk/plugstats1 - fi - if [[ $newstatus == "3" ]] ; then - echo 1 > /var/www/html/openWB/ramdisk/chargestats1 - else - echo 0 > /var/www/html/openWB/ramdisk/chargestats1 - fi - fi + if [[ $newplug == "7" ]] ; then + echo 1 > /var/www/html/openWB/ramdisk/plugstat + else + echo 0 > /var/www/html/openWB/ramdisk/plugstat + fi + if [[ $newstatus == "3" ]] ; then + echo 1 > /var/www/html/openWB/ramdisk/chargestat + else + echo 0 > /var/www/html/openWB/ramdisk/chargestat + fi + fi + else + if [[ $rep3 == "3" ]] ; then + watt=$(echo $output | jq '.P') + watt=$(echo "($watt / 1000)/1" |bc) + if [[ $watt =~ $rekwh ]] ; then + echo $watt > /var/www/html/openWB/ramdisk/llaktuells1 + fi + lla1=$(echo $output | jq '.I1') + lla1=$(echo "scale=2;$lla1 / 1000" |bc) + lla2=$(echo $output | jq '.I2') + lla2=$(echo "scale=2;$lla2 / 1000" |bc) + lla3=$(echo $output | jq '.I3') + lla3=$(echo "scale=2;$lla3 / 1000" |bc) + if [[ $lla1 =~ $rekwh ]] ; then + echo $lla1 > /var/www/html/openWB/ramdisk/llas11 + fi + if [[ $lla2 =~ $rekwh ]] ; then + echo $lla2 > /var/www/html/openWB/ramdisk/llas12 + fi + if [[ $lla3 =~ $rekwh ]] ; then + echo $lla3 > /var/www/html/openWB/ramdisk/llas13 + fi + llv1=$(echo $output | jq '.U1') + llv2=$(echo $output | jq '.U2') + llv3=$(echo $output | jq '.U3') + if [[ $llv1 =~ $re ]] ; then + echo $llv1 > /var/www/html/openWB/ramdisk/llvs11 + fi + if [[ $llv2 =~ $re ]] ; then + echo $llv2 > /var/www/html/openWB/ramdisk/llvs12 + fi + if [[ $llv3 =~ $re ]] ; then + echo $llv3 > /var/www/html/openWB/ramdisk/llvs13 + fi + chargedwh=$(echo $output | jq '."E pres"') + # totalwh=$(echo $output | jq '."E total"') + # llwh=$(echo $chargedwh + $totalwh | bc) + llwh=$(echo $output | jq '."E total"') + llkwh=$(echo "scale=3;$llwh / 10000" | bc -l) + if [[ $llkwh =~ $rekwh ]] ; then + echo $llkwh > /var/www/html/openWB/ramdisk/llkwhs1 + fi + fi + if [[ $rep2 == "2" ]] ; then + newplug=$(echo $output1 | jq '.Plug') + newstatus=$(echo $output1 | jq '.State') + #Plug Status 3 Kabel ist eingesteckt an der Ladestation, kein Auto + #Plug Status 7 Kabel ist eingesteckt Ladestation und Auto verriegelt. + #Status 2 ready for charging + #Status 3 charging + if [[ $newplug == "7" ]] ; then + echo 1 > /var/www/html/openWB/ramdisk/plugstats1 + else + echo 0 > /var/www/html/openWB/ramdisk/plugstats1 + fi + if [[ $newstatus == "3" ]] ; then + echo 1 > /var/www/html/openWB/ramdisk/chargestats1 + else + echo 0 > /var/www/html/openWB/ramdisk/chargestats1 + fi fi + fi fi diff --git a/modules/keballlp1/setcurrkeba.py b/modules/keballlp1/setcurrkeba.py index 79e06c6f9..994e10532 100644 --- a/modules/keballlp1/setcurrkeba.py +++ b/modules/keballlp1/setcurrkeba.py @@ -2,20 +2,23 @@ import sys import os import time -import json -import getopt -import socket -import struct -import codecs -import binascii +# import json +# import getopt +# import socket +# import struct +# import codecs +# import binascii from pymodbus.client.sync import ModbusTcpClient from pymodbus.constants import Endian from pymodbus.payload import BinaryPayloadDecoder + named_tuple = time.localtime() # getstruct_time time_string = time.strftime("%m/%d/%Y, %H:%M:%S keba setcurr.py", named_tuple) + file_string= '/var/www/html/openWB/ramdisk/keba_setcurr.log' + def getstat(ip): -# 1 enabled, 0 disable, 9 undef + # 1 enabled, 0 disable, 9 undef file_ip= '/var/www/html/openWB/ramdisk/keba_' + ip status = 9 if os.path.isfile(file_ip): @@ -23,28 +26,35 @@ def getstat(ip): status=int(f.read()) f.close() return status + def setstat(ip,status): file_ip= '/var/www/html/openWB/ramdisk/keba_' + ip f1 = open(file_ip, 'w') f1.write(str(status)) f1.close() + if os.path.isfile(file_string): f = open( file_string , 'a') else: f = open( file_string , 'w') + ipaddress=str(sys.argv[1]) newcurr=int(sys.argv[2]) + client = ModbusTcpClient(ipaddress, port=502) + # maxcurr state 1100 resp= client.read_holding_registers(1100,2,unit=255) decoder = BinaryPayloadDecoder.fromRegisters(resp.registers,byteorder=Endian.Big,wordorder=Endian.Big) final = float( decoder.decode_32bit_uint()) / 1000 oldcurr = int("%.f" % final) + # cabel state 1004 resp= client.read_holding_registers(1004,2,unit=255) decoder = BinaryPayloadDecoder.fromRegisters(resp.registers,byteorder=Endian.Big,wordorder=Endian.Big) final2 = float( decoder.decode_32bit_uint()) plugs = "%.f" % final2 + # max supported curr 1110 resp= client.read_holding_registers(1110,2,unit=255) decoder = BinaryPayloadDecoder.fromRegisters(resp.registers,byteorder=Endian.Big,wordorder=Endian.Big) diff --git a/modules/mpm3pmethll/main.sh b/modules/mpm3pmethll/main.sh index 158fb6642..bd53f9046 100755 --- a/modules/mpm3pmethll/main.sh +++ b/modules/mpm3pmethll/main.sh @@ -1,5 +1,2 @@ #!/bin/bash sudo python /var/www/html/openWB/modules/mpm3pmethll/readmpm3pm.py - - - diff --git a/modules/mpm3pmethll/readmpm3pm.py b/modules/mpm3pmethll/readmpm3pm.py index 9f2d7a9ab..61ab0af5e 100755 --- a/modules/mpm3pmethll/readmpm3pm.py +++ b/modules/mpm3pmethll/readmpm3pm.py @@ -1,16 +1,15 @@ #!/usr/bin/python -import sys -import os -import time -import getopt -import socket -import ConfigParser +# import sys +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii from pymodbus.client.sync import ModbusTcpClient -client = ModbusTcpClient('192.168.193.16', port=8899) - +client = ModbusTcpClient('192.168.193.16', port=8899) #resp = client.read_input_registers(0x0002,2, unit=5) #ikwh = resp.registers[1] diff --git a/modules/mpm3pmethllframer/main.sh b/modules/mpm3pmethllframer/main.sh index 3e0f5c01c..fa6346e2a 100755 --- a/modules/mpm3pmethllframer/main.sh +++ b/modules/mpm3pmethllframer/main.sh @@ -1,6 +1,3 @@ #!/bin/bash sudo python /var/www/html/openWB/modules/mpm3pmethllframer/readmpm3pm.py - - - diff --git a/modules/mpm3pmethllframer/readmpm3pm.py b/modules/mpm3pmethllframer/readmpm3pm.py index 17862e2a0..1710e6c34 100755 --- a/modules/mpm3pmethllframer/readmpm3pm.py +++ b/modules/mpm3pmethllframer/readmpm3pm.py @@ -1,18 +1,16 @@ #!/usr/bin/python -import sys -import os -import time -import getopt -import socket -import ConfigParser +# import sys +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii - - +# import binascii from pymodbus.transaction import ModbusRtuFramer from pymodbus.client.sync import ModbusTcpClient -client = ModbusTcpClient('192.168.193.18', port=8899, framer=ModbusRtuFramer) +client = ModbusTcpClient('192.168.193.18', port=8899, framer=ModbusRtuFramer) resp = client.read_input_registers(0x0002,4, unit=5) value1 = resp.registers[0] diff --git a/modules/mpm3pmethlls2/main.sh b/modules/mpm3pmethlls2/main.sh index 49bd56625..6f1b791ab 100755 --- a/modules/mpm3pmethlls2/main.sh +++ b/modules/mpm3pmethlls2/main.sh @@ -1,5 +1,3 @@ #!/bin/bash -sudo python /var/www/html/openWB/modules/mpm3pmethlls2/readmpm3pm.py - - +sudo python /var/www/html/openWB/modules/mpm3pmethlls2/readmpm3pm.py diff --git a/modules/mpm3pmethlls2/readmpm3pm.py b/modules/mpm3pmethlls2/readmpm3pm.py index 3c4d80660..0af13001d 100755 --- a/modules/mpm3pmethlls2/readmpm3pm.py +++ b/modules/mpm3pmethlls2/readmpm3pm.py @@ -1,16 +1,15 @@ #!/usr/bin/python -import sys -import os -import time -import getopt -import socket -import ConfigParser +# import sys +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii from pymodbus.client.sync import ModbusTcpClient -client = ModbusTcpClient('192.168.193.26', port=8899) - +client = ModbusTcpClient('192.168.193.26', port=8899) #resp = client.read_input_registers(0x0002,2, unit=5) #ikwh = resp.registers[1] diff --git a/modules/mpm3pmll/main.sh b/modules/mpm3pmll/main.sh index 0f28fdb0e..bb1b0295d 100755 --- a/modules/mpm3pmll/main.sh +++ b/modules/mpm3pmll/main.sh @@ -16,5 +16,3 @@ if [[ $mpm3pmllid = "0" ]]; then else python /var/www/html/openWB/modules/mpm3pmll/readmpm3pm.py $mpm3pmllsource $mpm3pmllid fi - - diff --git a/modules/mpm3pmll/readall.py b/modules/mpm3pmll/readall.py index 6b276c756..5dbe9693f 100755 --- a/modules/mpm3pmll/readall.py +++ b/modules/mpm3pmll/readall.py @@ -1,22 +1,23 @@ #!/usr/bin/python -import sys +# import sys import os import os.path -import time -import getopt -import socket -import ConfigParser +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusSerialClient + try: f = open('/dev/ttyUSB0') seradd = "/dev/ttyUSB0" f.close() except: seradd = "/dev/serial0" -from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) + +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) try: with open('/var/www/html/openWB/ramdisk/llmodulconfig', 'r') as value: @@ -311,4 +312,3 @@ f.write(str('failure')) f.close() #openwbModulePublishState "LP" 0 "Kein Fehler" 1 - diff --git a/modules/mpm3pmll/readmpm3pm.py b/modules/mpm3pmll/readmpm3pm.py index a198516b0..9d5c75fe2 100755 --- a/modules/mpm3pmll/readmpm3pm.py +++ b/modules/mpm3pmll/readmpm3pm.py @@ -2,19 +2,19 @@ import sys import os import os.path -import time -import getopt -import socket -import ConfigParser +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -seradd = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) - +seradd = str(sys.argv[1]) sdmid = int(sys.argv[2]) + +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) + if ( sdmid < 100 ): resp = client.read_input_registers(0x0002,4, unit=sdmid) value1 = resp.registers[0] @@ -187,4 +187,3 @@ f = open('/var/www/html/openWB/ramdisk/lp1Serial', 'w') f.write("0") f.close() - diff --git a/modules/mpm3pmlllp1/main.sh b/modules/mpm3pmlllp1/main.sh index a62e3a74f..aa8ddc324 100755 --- a/modules/mpm3pmlllp1/main.sh +++ b/modules/mpm3pmlllp1/main.sh @@ -1,5 +1,3 @@ #!/bin/bash -sudo python /var/www/html/openWB/modules/mpm3pmlllp1/readmpm3pm.py $mpmlp1ip $mpmlp1id - - +sudo python /var/www/html/openWB/modules/mpm3pmlllp1/readmpm3pm.py $mpmlp1ip $mpmlp1id diff --git a/modules/mpm3pmlllp1/readmpm3pm.py b/modules/mpm3pmlllp1/readmpm3pm.py index 7315db72b..77ee0c9b2 100755 --- a/modules/mpm3pmlllp1/readmpm3pm.py +++ b/modules/mpm3pmlllp1/readmpm3pm.py @@ -1,19 +1,19 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusTcpClient + ipadd = str(sys.argv[1]) idadd = int(sys.argv[2]) -from pymodbus.client.sync import ModbusTcpClient client = ModbusTcpClient(ipadd, port=8899) - if ( idadd < 100 ): #resp = client.read_input_registers(0x0002,2, unit=idadd) #ikwh = resp.registers[1] @@ -138,4 +138,3 @@ f = open('/var/www/html/openWB/ramdisk/llaktuell', 'w') f.write(str(llg)) f.close() - diff --git a/modules/mpm3pmlllp2/main.sh b/modules/mpm3pmlllp2/main.sh index 617cc8e8c..2b57226b3 100755 --- a/modules/mpm3pmlllp2/main.sh +++ b/modules/mpm3pmlllp2/main.sh @@ -1,5 +1,3 @@ #!/bin/bash -sudo python /var/www/html/openWB/modules/mpm3pmlllp2/readmpm3pm.py $mpmlp2ip $mpmlp2id - - +sudo python /var/www/html/openWB/modules/mpm3pmlllp2/readmpm3pm.py $mpmlp2ip $mpmlp2id diff --git a/modules/mpm3pmlllp2/readmpm3pm.py b/modules/mpm3pmlllp2/readmpm3pm.py index e9b3cbfb0..41973e0a7 100755 --- a/modules/mpm3pmlllp2/readmpm3pm.py +++ b/modules/mpm3pmlllp2/readmpm3pm.py @@ -1,19 +1,19 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusTcpClient + ipadd = str(sys.argv[1]) idadd = int(sys.argv[2]) -from pymodbus.client.sync import ModbusTcpClient client = ModbusTcpClient(ipadd, port=8899) - if ( idadd < 100 ): #resp = client.read_input_registers(0x0002,2, unit=idadd) #ikwh = resp.registers[1] @@ -138,4 +138,3 @@ f = open('/var/www/html/openWB/ramdisk/llaktuells1', 'w') f.write(str(llg)) f.close() - diff --git a/modules/mpm3pmlllp3/main.sh b/modules/mpm3pmlllp3/main.sh index 4f2cabc5d..be81a8dfc 100755 --- a/modules/mpm3pmlllp3/main.sh +++ b/modules/mpm3pmlllp3/main.sh @@ -1,5 +1,3 @@ #!/bin/bash -sudo python /var/www/html/openWB/modules/mpm3pmlllp3/readmpm3pm.py $mpmlp3ip $mpmlp3id - - +sudo python /var/www/html/openWB/modules/mpm3pmlllp3/readmpm3pm.py $mpmlp3ip $mpmlp3id diff --git a/modules/mpm3pmlllp3/readmpm3pm.py b/modules/mpm3pmlllp3/readmpm3pm.py index b7937ee91..8fb91b650 100755 --- a/modules/mpm3pmlllp3/readmpm3pm.py +++ b/modules/mpm3pmlllp3/readmpm3pm.py @@ -1,19 +1,19 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusTcpClient + ipadd = str(sys.argv[1]) idadd = int(sys.argv[2]) -from pymodbus.client.sync import ModbusTcpClient client = ModbusTcpClient(ipadd, port=8899) - if ( idadd < 100 ): #resp = client.read_input_registers(0x0002,2, unit=idadd) #ikwh = resp.registers[1] @@ -138,4 +138,3 @@ f = open('/var/www/html/openWB/ramdisk/llaktuells2', 'w') f.write(str(llg)) f.close() - diff --git a/modules/mpm3pmlllp4/main.sh b/modules/mpm3pmlllp4/main.sh index 1edcd035f..624bef179 100755 --- a/modules/mpm3pmlllp4/main.sh +++ b/modules/mpm3pmlllp4/main.sh @@ -4,5 +4,3 @@ if [[ $evseconlp4 == "extopenwb" ]]; then else sudo python /var/www/html/openWB/modules/mpm3pmlllp4/readmpm3pm.py $mpmlp4ip $mpmlp4id fi - - diff --git a/modules/mpm3pmlllp4/readmpm3pm.py b/modules/mpm3pmlllp4/readmpm3pm.py index 520a1ccb5..62e24a625 100755 --- a/modules/mpm3pmlllp4/readmpm3pm.py +++ b/modules/mpm3pmlllp4/readmpm3pm.py @@ -1,19 +1,19 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusTcpClient + ipadd = str(sys.argv[1]) idadd = int(sys.argv[2]) -from pymodbus.client.sync import ModbusTcpClient client = ModbusTcpClient(ipadd, port=8899) - if ( idadd < 100 ): #resp = client.read_input_registers(0x0002,2, unit=idadd) #ikwh = resp.registers[1] @@ -138,4 +138,3 @@ f = open('/var/www/html/openWB/ramdisk/llaktuelllp4', 'w') f.write(str(llg)) f.close() - diff --git a/modules/mpm3pmlllp5/main.sh b/modules/mpm3pmlllp5/main.sh index 57c2d2104..a7db68367 100755 --- a/modules/mpm3pmlllp5/main.sh +++ b/modules/mpm3pmlllp5/main.sh @@ -1,8 +1,6 @@ #!/bin/bash if [[ $evseconlp5 == "extopenwb" ]]; then - /var/www/html/openWB/modules/extopenwb/main.sh 5 $chargep5ip + /var/www/html/openWB/modules/extopenwb/main.sh 5 $chargep5ip else sudo python /var/www/html/openWB/modules/mpm3pmlllp5/readmpm3pm.py $mpmlp5ip $mpmlp5id fi - - diff --git a/modules/mpm3pmlllp5/readmpm3pm.py b/modules/mpm3pmlllp5/readmpm3pm.py index 4de4e7d92..53f1ccc88 100755 --- a/modules/mpm3pmlllp5/readmpm3pm.py +++ b/modules/mpm3pmlllp5/readmpm3pm.py @@ -1,19 +1,19 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusTcpClient + ipadd = str(sys.argv[1]) idadd = int(sys.argv[2]) -from pymodbus.client.sync import ModbusTcpClient client = ModbusTcpClient(ipadd, port=8899) - if ( idadd < 100 ): #resp = client.read_input_registers(0x0002,2, unit=idadd) #ikwh = resp.registers[1] diff --git a/modules/mpm3pmlllp6/main.sh b/modules/mpm3pmlllp6/main.sh index 4ee583057..78eae25f8 100755 --- a/modules/mpm3pmlllp6/main.sh +++ b/modules/mpm3pmlllp6/main.sh @@ -1,8 +1,6 @@ #!/bin/bash if [[ $evseconlp6 == "extopenwb" ]]; then /var/www/html/openWB/modules/extopenwb/main.sh 6 $chargep6ip -else +else sudo python /var/www/html/openWB/modules/mpm3pmlllp6/readmpm3pm.py $mpmlp6ip $mpmlp6id fi - - diff --git a/modules/mpm3pmlllp6/readmpm3pm.py b/modules/mpm3pmlllp6/readmpm3pm.py index 1ba150fac..6bd7d764c 100755 --- a/modules/mpm3pmlllp6/readmpm3pm.py +++ b/modules/mpm3pmlllp6/readmpm3pm.py @@ -1,19 +1,19 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusTcpClient + ipadd = str(sys.argv[1]) idadd = int(sys.argv[2]) -from pymodbus.client.sync import ModbusTcpClient client = ModbusTcpClient(ipadd, port=8899) - if ( idadd < 100 ): #resp = client.read_input_registers(0x0002,2, unit=idadd) #ikwh = resp.registers[1] diff --git a/modules/mpm3pmlllp7/main.sh b/modules/mpm3pmlllp7/main.sh index 02eb46094..66ae79ac2 100755 --- a/modules/mpm3pmlllp7/main.sh +++ b/modules/mpm3pmlllp7/main.sh @@ -4,5 +4,3 @@ if [[ $evseconlp7 == "extopenwb" ]]; then else sudo python /var/www/html/openWB/modules/mpm3pmlllp7/readmpm3pm.py $mpmlp7ip $mpmlp7id fi - - diff --git a/modules/mpm3pmlllp7/readmpm3pm.py b/modules/mpm3pmlllp7/readmpm3pm.py index 3782aabb3..2e103b51a 100755 --- a/modules/mpm3pmlllp7/readmpm3pm.py +++ b/modules/mpm3pmlllp7/readmpm3pm.py @@ -1,19 +1,19 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusTcpClient + ipadd = str(sys.argv[1]) idadd = int(sys.argv[2]) -from pymodbus.client.sync import ModbusTcpClient client = ModbusTcpClient(ipadd, port=8899) - if ( idadd < 100 ): #resp = client.read_input_registers(0x0002,2, unit=idadd) #ikwh = resp.registers[1] diff --git a/modules/mpm3pmlllp8/main.sh b/modules/mpm3pmlllp8/main.sh index b98288820..66a5d64dc 100755 --- a/modules/mpm3pmlllp8/main.sh +++ b/modules/mpm3pmlllp8/main.sh @@ -4,5 +4,3 @@ if [[ $evseconlp8 == "extopenwb" ]]; then else sudo python /var/www/html/openWB/modules/mpm3pmlllp8/readmpm3pm.py $mpmlp8ip $mpmlp8id fi - - diff --git a/modules/mpm3pmlllp8/readmpm3pm.py b/modules/mpm3pmlllp8/readmpm3pm.py index 3f7289e89..7a37a89bf 100755 --- a/modules/mpm3pmlllp8/readmpm3pm.py +++ b/modules/mpm3pmlllp8/readmpm3pm.py @@ -1,19 +1,19 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusTcpClient + ipadd = str(sys.argv[1]) idadd = int(sys.argv[2]) -from pymodbus.client.sync import ModbusTcpClient client = ModbusTcpClient(ipadd, port=8899) - if ( idadd < 100 ): #resp = client.read_input_registers(0x0002,2, unit=idadd) #ikwh = resp.registers[1] @@ -138,4 +138,3 @@ f = open('/var/www/html/openWB/ramdisk/llaktuelllp8', 'w') f.write(str(llg)) f.close() - diff --git a/modules/mpm3pmlls1/main.sh b/modules/mpm3pmlls1/main.sh index cd97ec041..f7fd7c4d4 100755 --- a/modules/mpm3pmlls1/main.sh +++ b/modules/mpm3pmlls1/main.sh @@ -12,6 +12,3 @@ else echo "echo" > /dev/null fi sudo python /var/www/html/openWB/modules/mpm3pmlls1/readmpm3pm.py $mpm3pmlls1source $mpm3pmlls1id - - - diff --git a/modules/mpm3pmlls1/readmpm3pm.py b/modules/mpm3pmlls1/readmpm3pm.py index a5170a93c..41f778387 100755 --- a/modules/mpm3pmlls1/readmpm3pm.py +++ b/modules/mpm3pmlls1/readmpm3pm.py @@ -1,20 +1,19 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -seradd = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) - +seradd = str(sys.argv[1]) idadd = int(sys.argv[2]) +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) + if ( idadd < 100 ): #resp = client.read_input_registers(0x0002,2, unit=idadd) #ikwh = resp.registers[1] @@ -139,4 +138,3 @@ f = open('/var/www/html/openWB/ramdisk/llaktuells1', 'w') f.write(str(llg)) f.close() - diff --git a/modules/mpm3pmlls2/main.sh b/modules/mpm3pmlls2/main.sh index 64848e816..0472d0033 100755 --- a/modules/mpm3pmlls2/main.sh +++ b/modules/mpm3pmlls2/main.sh @@ -12,6 +12,3 @@ else echo "echo" > /dev/null fi sudo python /var/www/html/openWB/modules/mpm3pmlls2/readmpm3pm.py $mpm3pmlls2source $mpm3pmlls2id - - - diff --git a/modules/mpm3pmlls2/readmpm3pm.py b/modules/mpm3pmlls2/readmpm3pm.py index 86bddc49f..146b8d747 100755 --- a/modules/mpm3pmlls2/readmpm3pm.py +++ b/modules/mpm3pmlls2/readmpm3pm.py @@ -1,20 +1,19 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -seradd = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) - +seradd = str(sys.argv[1]) sdmid = int(sys.argv[2]) +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) + resp = client.read_input_registers(0x0002,4, unit=sdmid) value1 = resp.registers[0] value2 = resp.registers[1] @@ -78,4 +77,3 @@ f = open('/var/www/html/openWB/ramdisk/llvs23', 'w') f.write(str(voltage)) f.close() - diff --git a/modules/mpm3pmpv/main.sh b/modules/mpm3pmpv/main.sh index 7647d695a..d3e115247 100755 --- a/modules/mpm3pmpv/main.sh +++ b/modules/mpm3pmpv/main.sh @@ -14,7 +14,3 @@ fi sudo python /var/www/html/openWB/modules/mpm3pmpv/readmpm3pm.py $mpm3pmpvsource $mpm3pmpvid pvwatt=$(i', all.decode('hex'))[0]) -#resp = client.read_input_registers(0x0004,2, unit=sdmid) -#ikwh = resp.registers[1] +# 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)) @@ -49,7 +48,7 @@ f.write(str(lla3)) f.close() -#total watt +# total watt resp = client.read_input_registers(0x26,2, unit=sdmid) value1 = resp.registers[0] value2 = resp.registers[1] @@ -58,6 +57,3 @@ f = open('/var/www/html/openWB/ramdisk/pvwatt', 'w') f.write(str(final)) f.close() - - - diff --git a/modules/mpm3pmspeicher/main.sh b/modules/mpm3pmspeicher/main.sh index 388a09fbe..f85f9aa87 100755 --- a/modules/mpm3pmspeicher/main.sh +++ b/modules/mpm3pmspeicher/main.sh @@ -12,7 +12,3 @@ else echo "echo" > /dev/null fi sudo python /var/www/html/openWB/modules/mpm3pmspeicher/readmpm3pm.py $mpm3pmspeichersource $mpm3pmspeicherid $mpm3pmspeicherpv - - - - diff --git a/modules/mpm3pmspeicher/readmpm3pm.py b/modules/mpm3pmspeicher/readmpm3pm.py index 75ec897aa..10479aadc 100755 --- a/modules/mpm3pmspeicher/readmpm3pm.py +++ b/modules/mpm3pmspeicher/readmpm3pm.py @@ -1,22 +1,21 @@ #!/usr/bin/python import sys import struct -seradd = str(sys.argv[1]) -pvflag = str(sys.argv[3]) from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) - +seradd = str(sys.argv[1]) sdmid = int(sys.argv[2]) +pvflag = str(sys.argv[3]) + +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) resp = client.read_input_registers(0x0004,4, unit=5) value1 = resp.registers[0] value2 = resp.registers[1] all = format(value1, '04x') + format(value2, '04x') ekwh = int(struct.unpack('>i', all.decode('hex'))[0]) -#resp = client.read_input_registers(0x0004,2, unit=sdmid) -#ekwh = resp.registers[1] +# resp = client.read_input_registers(0x0004,2, unit=sdmid) +# ekwh = resp.registers[1] ekwh = float(ekwh) /100 f = open('/var/www/html/openWB/ramdisk/speicherekwh', 'w') f.write(str(ekwh)) @@ -27,15 +26,13 @@ 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(0x0002,2, unit=sdmid) -#ikwh = resp.registers[1] +# resp = client.read_input_registers(0x0002,2, unit=sdmid) +# ikwh = resp.registers[1] ikwh = float(ikwh) * 10 f = open('/var/www/html/openWB/ramdisk/speicherikwh', 'w') f.write(str(ikwh)) f.close() - - resp = client.read_input_registers(0x0E,2, unit=sdmid) lla1 = resp.registers[1] lla1 = float(lla1) / 100 @@ -57,7 +54,7 @@ f.write(str(lla3)) f.close() -#total watt +# total watt resp = client.read_input_registers(0x26,2, unit=sdmid) value1 = resp.registers[0] value2 = resp.registers[1] @@ -73,6 +70,3 @@ f = open('/var/www/html/openWB/ramdisk/speicherleistung', 'w') f.write(str(final)) f.close() - - - diff --git a/modules/mpm3pmtripple/main.sh b/modules/mpm3pmtripple/main.sh index 5df244ce1..d9c5cee7a 100755 --- a/modules/mpm3pmtripple/main.sh +++ b/modules/mpm3pmtripple/main.sh @@ -1,6 +1,3 @@ #!/bin/bash sudo python /var/www/html/openWB/modules/mpm3pmtripple/readmpm3pm.py /dev/ttyUSB0 105 - - - diff --git a/modules/mpm3pmtripple/readmpm3pm.py b/modules/mpm3pmtripple/readmpm3pm.py index 9ba08b508..4f9487d7b 100755 --- a/modules/mpm3pmtripple/readmpm3pm.py +++ b/modules/mpm3pmtripple/readmpm3pm.py @@ -1,19 +1,19 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -seradd = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) - +seradd = str(sys.argv[1]) idadd = int(sys.argv[2]) + +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) + resp = client.read_input_registers(0x00,2, unit=idadd) voltage = struct.unpack('>f',struct.pack('>HH',*resp.registers))[0] voltage = float("%.1f" % voltage) @@ -95,4 +95,3 @@ f = open('/var/www/html/openWB/ramdisk/llvs21', 'w') f.write(str(voltage)) f.close() - diff --git a/modules/mpm3pmtripplelp2/main.sh b/modules/mpm3pmtripplelp2/main.sh index 12508cf1a..bb9bddff1 100755 --- a/modules/mpm3pmtripplelp2/main.sh +++ b/modules/mpm3pmtripplelp2/main.sh @@ -1,4 +1,3 @@ #!/bin/bash #everything done in tripple lp1 module - diff --git a/modules/nrgkicklp1/main.sh b/modules/nrgkicklp1/main.sh index b440b4c47..98ab947e2 100755 --- a/modules/nrgkicklp1/main.sh +++ b/modules/nrgkicklp1/main.sh @@ -2,12 +2,9 @@ re='^-?[0-9]+$' rekwh='^[-+]?[0-9]+\.?[0-9]*$' - - ##set charging ##curl -s -X PUT -H "Content-Type: application/json" --data '{ "Values": {"ChargingStatus": { "Charging": false }, "ChargingCurrent": { "Value": "6"}, "DeviceMetadata":{"Password": 1234}}}' 10.20.0.78/api/settings/00:1E:C0:76:82:1D - output=$(curl --connect-timeout $nrgkicktimeoutlp1 -s http://$nrgkickiplp1/api/measurements/$nrgkickmaclp1) if [[ $? == "0" ]] ; then watt=$(echo $output | jq -r '.ChargingPower') @@ -42,7 +39,6 @@ if [[ $? == "0" ]] ; then if [[ $lla3 =~ $re ]] ; then echo $llv3 > /var/www/html/openWB/ramdisk/llv3 fi - llkwh=$(echo $output | jq -r '.ChargingEnergyOverAll') llkwh=$(echo "scale=3;$llkwh / 1" |bc) if [[ $llkwh =~ $rekwh ]] ; then diff --git a/modules/nrgkicklp2/main.sh b/modules/nrgkicklp2/main.sh index c64c0b58d..f3a904244 100755 --- a/modules/nrgkicklp2/main.sh +++ b/modules/nrgkicklp2/main.sh @@ -2,12 +2,9 @@ re='^-?[0-9]+$' rekwh='^[-+]?[0-9]+\.?[0-9]*$' - - ##set charging ##curl -s -X PUT -H "Content-Type: application/json" --data '{ "Values": {"ChargingStatus": { "Charging": false }, "ChargingCurrent": { "Value": "6"}, "DeviceMetadata":{"Password": 1234}}}' 10.20.0.78/api/settings/00:1E:C0:76:82:1D - output=$(curl --connect-timeout $nrgkicktimeoutlp2 -s http://$nrgkickiplp2/api/measurements/$nrgkickmaclp2) if [[ $? == "0" ]] ; then watt=$(echo $output | jq -r '.ChargingPower') @@ -15,13 +12,13 @@ if [[ $? == "0" ]] ; then if [[ $watt =~ $re ]] ; then echo $watt > /var/www/html/openWB/ramdisk/llaktuells1 fi - if (( watt > 50 )); then - echo 1 > /var/www/html/openWB/ramdisk/plugstats1 - echo 1 > /var/www/html/openWB/ramdisk/chargestats1 - else - echo 0 > /var/www/html/openWB/ramdisk/plugstats1 - echo 0 > /var/www/html/openWB/ramdisk/chargestats1 - fi + if (( watt > 50 )); then + echo 1 > /var/www/html/openWB/ramdisk/plugstats1 + echo 1 > /var/www/html/openWB/ramdisk/chargestats1 + else + echo 0 > /var/www/html/openWB/ramdisk/plugstats1 + echo 0 > /var/www/html/openWB/ramdisk/chargestats1 + fi lla1=$(echo $output | jq -r '.ChargingCurrentPhase[0]') lla1=$(echo "scale=0;$lla1 / 1" |bc) if [[ $lla1 =~ $re ]] ; then @@ -49,7 +46,6 @@ if [[ $? == "0" ]] ; then if [[ $lla3 =~ $re ]] ; then echo $llv3 > /var/www/html/openWB/ramdisk/llvs13 fi - llkwh=$(echo $output | jq -r '.ChargingEnergyOverAll') llkwh=$(echo "scale=3;$llkwh / 1" |bc) if [[ $llkwh =~ $rekwh ]] ; then diff --git a/modules/sdm120modbusSocket/main.sh b/modules/sdm120modbusSocket/main.sh index 315b47704..23736bb80 100644 --- a/modules/sdm120modbusSocket/main.sh +++ b/modules/sdm120modbusSocket/main.sh @@ -1,5 +1,5 @@ #!/bin/bash if [[ $sdm120modbussocketid != "none" ]]; then - sudo python /var/www/html/openWB/modules/sdm120modbusSocket/readsdm.py $sdm120modbussocketsource $sdm120modbussocketid + sudo python /var/www/html/openWB/modules/sdm120modbusSocket/readsdm.py $sdm120modbussocketsource $sdm120modbussocketid fi diff --git a/modules/sdm120modbusSocket/readsdm.py b/modules/sdm120modbusSocket/readsdm.py index a1a730c44..53d3cf2d7 100644 --- a/modules/sdm120modbusSocket/readsdm.py +++ b/modules/sdm120modbusSocket/readsdm.py @@ -2,18 +2,18 @@ import sys import os import time -import getopt -import socket -import ConfigParser +# import getopt +# import socket +# import ConfigParser import struct -import binascii -seradd = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) +seradd = str(sys.argv[1]) sdmid = int(sys.argv[2]) +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) + resp = client.read_input_registers(0x00,2, unit=sdmid) socketv = struct.unpack('>f',struct.pack('>HH',*resp.registers)) socketv = float("%.1f" % socketv[0]) diff --git a/modules/sdm120modbusll/main.sh b/modules/sdm120modbusll/main.sh index b01bceda6..2d883558e 100755 --- a/modules/sdm120modbusll/main.sh +++ b/modules/sdm120modbusll/main.sh @@ -20,7 +20,7 @@ if [[ $sdm120modbusllid1 != "none" ]] && [[ $sdm120modbusllid2 != "254" ]] && [[ else if [[ $sdm120modbusllid2 != "254" ]] ; then - n=0 + n=0 output=$(sudo python /var/www/html/openWB/modules/sdm120modbusll/readsdm2.py $sdm120modbusllsource $sdm120modbusllid1 $sdm120modbusllid2) while read -r line; do if (( $n == 0 )); then @@ -46,25 +46,16 @@ else llkwh=${llkwh%???} fi n=$((n + 1)) - done <<< "$output" + done <<< "$output" if [[ $llkwh =~ $rekwh ]] ; then lltotal=`echo "($llkwh)" |bc` LANG=C printf "%.3f\n" $lltotal > /var/www/html/openWB/ramdisk/llkwh fi if [[ $wl1 =~ $re ]]; then - llaktuell=`echo "($wl1)" |bc` + llaktuell=`echo "($wl1)" |bc` echo $llaktuell > /var/www/html/openWB/ramdisk/llaktuell fi else sudo python /var/www/html/openWB/modules/sdm120modbusll/readsdm1.py $sdm120modbusllsource $sdm120modbusllid1 - fi fi - - - - - - - - diff --git a/modules/sdm120modbusll/readsdm1.py b/modules/sdm120modbusll/readsdm1.py index 32b5fb04d..a9e6e5db0 100755 --- a/modules/sdm120modbusll/readsdm1.py +++ b/modules/sdm120modbusll/readsdm1.py @@ -1,20 +1,18 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -seradd = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) +seradd = str(sys.argv[1]) sdmid = int(sys.argv[2]) - +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) resp = client.read_input_registers(0x00,2, unit=sdmid) llv1 = struct.unpack('>f',struct.pack('>HH',*resp.registers)) @@ -50,9 +48,3 @@ f = open('/var/www/html/openWB/ramdisk/llkwh', 'w') f.write(str(llwh)) f.close() - - - - - - diff --git a/modules/sdm120modbusll/readsdm2.py b/modules/sdm120modbusll/readsdm2.py index ba16a8061..2ecaa9229 100755 --- a/modules/sdm120modbusll/readsdm2.py +++ b/modules/sdm120modbusll/readsdm2.py @@ -1,21 +1,22 @@ #!/usr/bin/python import sys -import os +# import os import time -import getopt -import socket -import ConfigParser +# import getopt +# import socket +# import ConfigParser import struct -import binascii -seradd = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) -#rq = client.read_holding_registers(0,8,unit=5) -#print(rq.registers) +seradd = str(sys.argv[1]) sdmid = int(sys.argv[2]) sdm2id = int(sys.argv[3]) + +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) + +# rq = client.read_holding_registers(0,8,unit=5) +# print(rq.registers) resp = client.read_input_registers(0x00,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) resp = client.read_input_registers(0x06,2, unit=sdmid) @@ -37,10 +38,3 @@ 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))) - - - - - - - diff --git a/modules/sdm120modbusll/readsdm3.py b/modules/sdm120modbusll/readsdm3.py index 9299bb3bc..8d5d9fe49 100755 --- a/modules/sdm120modbusll/readsdm3.py +++ b/modules/sdm120modbusll/readsdm3.py @@ -1,22 +1,23 @@ #!/usr/bin/python import sys -import os +# import os import time -import getopt -import socket -import ConfigParser +# import getopt +# import socket +# import ConfigParser import struct -import binascii -seradd = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) -#rq = client.read_holding_registers(0,8,unit=5) -#print(rq.registers) -sdmid = int(sys.argv[2]) +seradd = str(sys.argv[1]) +sdmid = int(sys.argv[2]) sdm2id = int(sys.argv[3]) sdm3id = int(sys.argv[4]) + +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) + +# rq = client.read_holding_registers(0,8,unit=5) +# print(rq.registers) resp = client.read_input_registers(0x00,2, unit=sdmid) llv1 = struct.unpack('>f',struct.pack('>HH',*resp.registers)) llv1 = float("%.1f" % llv1[0]) @@ -75,7 +76,6 @@ llwh = struct.unpack('>f',struct.pack('>HH',*resp.registers)) llwh3 = float("%.3f" % llwh[0]) - llwh = llwh1 + llwh2 + llwh3 f = open('/var/www/html/openWB/ramdisk/llkwh', 'w') f.write(str(llwh)) @@ -85,6 +85,3 @@ f = open('/var/www/html/openWB/ramdisk/llaktuell', 'w') f.write(str(ll)) f.close() - - - diff --git a/modules/sdm120modbuslls1/main.sh b/modules/sdm120modbuslls1/main.sh index d9635c50e..5d91f8395 100755 --- a/modules/sdm120modbuslls1/main.sh +++ b/modules/sdm120modbuslls1/main.sh @@ -85,7 +85,7 @@ if [[ $sdm120modbusllid1s1 != "254" ]] && [[ $sdm120modbusllid2s1 != "254" ]] && llkwh3=${llkwh3%???} fi n=$((n + 1)) - done <<< "$output" + done <<< "$output" if [[ $llkwh =~ $rekwh ]] && [[ $llkwh2 =~ $rekwh ]] && [[ $llkwh3 =~ $rekwh ]]; then lltotal=`echo "($llkwh+$llkwh2+$llkwh3)" |bc` LANG=C printf "%.3f\n" $lltotal > /var/www/html/openWB/ramdisk/llkwhs1 @@ -94,7 +94,6 @@ if [[ $sdm120modbusllid1s1 != "254" ]] && [[ $sdm120modbusllid2s1 != "254" ]] && llaktuell=`echo "($wl1+$wl2+$wl3)" |bc` echo $llaktuell > /var/www/html/openWB/ramdisk/llaktuells1 fi - else if [[ $sdm120modbusllid2s1 != "254" ]] ; then n=0 @@ -123,7 +122,7 @@ else llkwh=${llkwh%???} fi n=$((n + 1)) - done <<< "$output" + done <<< "$output" if [[ $llkwh =~ $rekwh ]] ; then lltotal=`echo "($llkwh)" |bc` LANG=C printf "%.3f\n" $lltotal > /var/www/html/openWB/ramdisk/llkwhs1 @@ -134,15 +133,5 @@ else fi else sudo python /var/www/html/openWB/modules/sdm120modbuslls1/readsdm1.py $sdm120lp2source $sdm120modbusllid1s1 - - fi fi - - - - - - - - diff --git a/modules/sdm120modbuslls1/readsdm1.py b/modules/sdm120modbuslls1/readsdm1.py index df607db18..7036503fe 100755 --- a/modules/sdm120modbuslls1/readsdm1.py +++ b/modules/sdm120modbuslls1/readsdm1.py @@ -1,20 +1,18 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -seradd = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) +seradd = str(sys.argv[1]) sdmid = int(sys.argv[2]) - +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) resp = client.read_input_registers(0x00,2, unit=sdmid) llv1 = struct.unpack('>f',struct.pack('>HH',*resp.registers)) @@ -50,9 +48,3 @@ f = open('/var/www/html/openWB/ramdisk/llkwhs1', 'w') f.write(str(llwh)) f.close() - - - - - - diff --git a/modules/sdm120modbuslls1/readsdm2.py b/modules/sdm120modbuslls1/readsdm2.py index ba16a8061..76495d687 100755 --- a/modules/sdm120modbuslls1/readsdm2.py +++ b/modules/sdm120modbuslls1/readsdm2.py @@ -1,21 +1,22 @@ #!/usr/bin/python import sys -import os +# import os import time -import getopt -import socket -import ConfigParser +# import getopt +# import socket +# import ConfigParser import struct -import binascii -seradd = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) -#rq = client.read_holding_registers(0,8,unit=5) -#print(rq.registers) -sdmid = int(sys.argv[2]) +seradd = str(sys.argv[1]) +sdmid = int(sys.argv[2]) sdm2id = int(sys.argv[3]) + +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) + +# rq = client.read_holding_registers(0,8,unit=5) +# print(rq.registers) resp = client.read_input_registers(0x00,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) resp = client.read_input_registers(0x06,2, unit=sdmid) @@ -37,10 +38,3 @@ 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))) - - - - - - - diff --git a/modules/sdm120modbuslls1/readsdm3.py b/modules/sdm120modbuslls1/readsdm3.py index a4ef596b1..4f369814b 100755 --- a/modules/sdm120modbuslls1/readsdm3.py +++ b/modules/sdm120modbuslls1/readsdm3.py @@ -1,22 +1,23 @@ #!/usr/bin/python import sys -import os +# import os import time -import getopt -import socket -import ConfigParser +# import getopt +# import socket +# import ConfigParser import struct -import binascii -seradd = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) -#rq = client.read_holding_registers(0,8,unit=5) -#print(rq.registers) -sdmid = int(sys.argv[2]) +seradd = str(sys.argv[1]) +sdmid = int(sys.argv[2]) sdm2id = int(sys.argv[3]) sdm3id = int(sys.argv[4]) + +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) + +# rq = client.read_holding_registers(0,8,unit=5) +# print(rq.registers) time.sleep(0.3) resp = client.read_input_registers(0x00,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) @@ -54,9 +55,3 @@ print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) resp = client.read_input_registers(0x0156,2, unit=sdm3id) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) - - - - - - diff --git a/modules/sdm120modbuslls2/main.sh b/modules/sdm120modbuslls2/main.sh index 6adefebd8..a9be7b874 100755 --- a/modules/sdm120modbuslls2/main.sh +++ b/modules/sdm120modbuslls2/main.sh @@ -85,7 +85,7 @@ if [[ $sdm120modbusllid1s2 != "254" ]] && [[ $sdm120modbusllid2s2 != "254" ]] && llkwh3=${llkwh3%???} fi n=$((n + 1)) - done <<< "$output" + done <<< "$output" if [[ $llkwh =~ $rekwh ]] && [[ $llkwh2 =~ $rekwh ]] && [[ $llkwh3 =~ $rekwh ]]; then lltotal=`echo "($llkwh+$llkwh2+$llkwh3)" |bc` LANG=C printf "%.3f\n" $lltotal > /var/www/html/openWB/ramdisk/llkwhs2 @@ -94,7 +94,6 @@ if [[ $sdm120modbusllid1s2 != "254" ]] && [[ $sdm120modbusllid2s2 != "254" ]] && llaktuell=`echo "($wl1+$wl2+$wl3)" |bc` echo $llaktuell > /var/www/html/openWB/ramdisk/llaktuells2 fi - else if [[ $sdm120modbusllid2s2 != "254" ]] ; then n=0 @@ -145,7 +144,7 @@ else llkwh2=${llkwh2%???} fi n=$((n + 1)) - done <<< "$output" + done <<< "$output" if [[ $llkwh =~ $rekwh ]] && [[ $llkwh2 =~ $rekwh ]] ; then lltotal=`echo "($llkwh+$llkwh2)" |bc` LANG=C printf "%.3f\n" $lltotal > /var/www/html/openWB/ramdisk/llkwhs2 @@ -158,11 +157,3 @@ else sudo python /var/www/html/openWB/modules/sdm120modbuslls2/readsdm1.py $sdm120lp3source $sdm120modbusllid1s2 fi fi - - - - - - - - diff --git a/modules/sdm120modbuslls2/readsdm1.py b/modules/sdm120modbuslls2/readsdm1.py index 510c5da62..466fd7a57 100755 --- a/modules/sdm120modbuslls2/readsdm1.py +++ b/modules/sdm120modbuslls2/readsdm1.py @@ -1,20 +1,18 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -seradd = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) +seradd = str(sys.argv[1]) sdmid = int(sys.argv[2]) - +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) resp = client.read_input_registers(0x00,2, unit=sdmid) llv1 = struct.unpack('>f',struct.pack('>HH',*resp.registers)) @@ -50,9 +48,3 @@ f = open('/var/www/html/openWB/ramdisk/llkwhs2', 'w') f.write(str(llwh)) f.close() - - - - - - diff --git a/modules/sdm120modbuslls2/readsdm2.py b/modules/sdm120modbuslls2/readsdm2.py index ba16a8061..76495d687 100755 --- a/modules/sdm120modbuslls2/readsdm2.py +++ b/modules/sdm120modbuslls2/readsdm2.py @@ -1,21 +1,22 @@ #!/usr/bin/python import sys -import os +# import os import time -import getopt -import socket -import ConfigParser +# import getopt +# import socket +# import ConfigParser import struct -import binascii -seradd = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) -#rq = client.read_holding_registers(0,8,unit=5) -#print(rq.registers) -sdmid = int(sys.argv[2]) +seradd = str(sys.argv[1]) +sdmid = int(sys.argv[2]) sdm2id = int(sys.argv[3]) + +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) + +# rq = client.read_holding_registers(0,8,unit=5) +# print(rq.registers) resp = client.read_input_registers(0x00,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) resp = client.read_input_registers(0x06,2, unit=sdmid) @@ -37,10 +38,3 @@ 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))) - - - - - - - diff --git a/modules/sdm120modbuslls2/readsdm3.py b/modules/sdm120modbuslls2/readsdm3.py index efe6adc3f..e54291af4 100755 --- a/modules/sdm120modbuslls2/readsdm3.py +++ b/modules/sdm120modbuslls2/readsdm3.py @@ -1,22 +1,23 @@ #!/usr/bin/python import sys -import os +# import os import time -import getopt -import socket -import ConfigParser +# import getopt +# import socket +# import ConfigParser import struct -import binascii -seradd = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) -#rq = client.read_holding_registers(0,8,unit=5) -#print(rq.registers) -sdmid = int(sys.argv[2]) +seradd = str(sys.argv[1]) +sdmid = int(sys.argv[2]) sdm2id = int(sys.argv[3]) sdm3id = int(sys.argv[4]) + +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) + +# rq = client.read_holding_registers(0,8,unit=5) +# print(rq.registers) resp = client.read_input_registers(0x00,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) resp = client.read_input_registers(0x06,2, unit=sdmid) @@ -49,9 +50,3 @@ print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) resp = client.read_input_registers(0x0156,2, unit=sdm3id) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) - - - - - - diff --git a/modules/sdm630modbusbezug/main.sh b/modules/sdm630modbusbezug/main.sh index 1fcd91385..39162be8c 100755 --- a/modules/sdm630modbusbezug/main.sh +++ b/modules/sdm630modbusbezug/main.sh @@ -1,6 +1,4 @@ #!/bin/bash - - if [[ $sdm630modbusbezugsource = *virtual* ]] then if ps ax |grep -v grep |grep "socat pty,link=$sdm630modbusbezugsource,raw tcp:$sdm630modbusbezuglanip:26" > /dev/null @@ -19,23 +17,22 @@ while read -r line; do evua1=$(echo "$line" | cut -c2- ) evua1=${evua1%??} echo "scale=3; $evua1/1" | bc -l > /var/www/html/openWB/ramdisk/bezuga1 -# LANG=C printf "%.3f\n" $evua1 > /var/www/html/openWB/ramdisk/bezuga1 -# echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/bezuga1 + # LANG=C printf "%.3f\n" $evua1 > /var/www/html/openWB/ramdisk/bezuga1 + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/bezuga1 fi if (( $n == 1 )); then evua2=$(echo "$line" | cut -c2- ) evua2=${evua2%??} echo "scale=3; $evua2/1" | bc -l > /var/www/html/openWB/ramdisk/bezuga2 -# LANG=C printf "%.3f\n" $evua2 > /var/www/html/openWB/ramdisk/bezuga2 -# echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/bezuga2 + # LANG=C printf "%.3f\n" $evua2 > /var/www/html/openWB/ramdisk/bezuga2 + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/bezuga2 fi if (( $n == 2 )); then evua3=$(echo "$line" | cut -c2- ) evua3=${evua3%??} echo "scale=3; $evua3/1" | bc -l > /var/www/html/openWB/ramdisk/bezuga3 -# LANG=C printf "%.3f\n" $evua3 > /var/www/html/openWB/ramdisk/bezuga3 -# echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/bezuga3 - + # LANG=C printf "%.3f\n" $evua3 > /var/www/html/openWB/ramdisk/bezuga3 + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/bezuga3 fi if (( $n == 3 )); then wl1=$(echo "$line" | cut -c2- |sed 's/\..*$//') @@ -46,11 +43,10 @@ while read -r line; do if (( $n == 5 )); then wl3=$(echo "$line" | cut -c2- |sed 's/\..*$//') fi - if (( $n == 6 )); then bezugkwhold=$(echo "$line" | cut -c2- ) -# echo ${bezugkwh%??} > /var/www/html/openWB/ramdisk/bezugkwh -# echo ${bezugkwh%??} > /var/www/html/openWB/ramdisk/einspeisungkwh + # echo ${bezugkwh%??} > /var/www/html/openWB/ramdisk/bezugkwh + # echo ${bezugkwh%??} > /var/www/html/openWB/ramdisk/einspeisungkwh fi if (( $n == 7 )); then ikwh1=$(echo "$line" | cut -c2- ) @@ -74,85 +70,69 @@ while read -r line; do evupf1=$(echo "$line" | cut -c2- ) evupf1=${evupf1%??} echo "scale=3; $evupf1/1" | bc -l > /var/www/html/openWB/ramdisk/evupf1 - -# LANG=C printf "%.3f\n" $evupf1 > /var/www/html/openWB/ramdisk/evupf1 -# echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/evupf1 - + # LANG=C printf "%.3f\n" $evupf1 > /var/www/html/openWB/ramdisk/evupf1 + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/evupf1 fi if (( $n == 14 )); then evupf2=$(echo "$line" | cut -c2- ) evupf2=${evupf2%??} echo "scale=3; $evupf2/1" | bc -l > /var/www/html/openWB/ramdisk/evupf2 - -# LANG=C printf "%.3f\n" $evupf2 > /var/www/html/openWB/ramdisk/evupf2 -# echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/evupf2 - + # LANG=C printf "%.3f\n" $evupf2 > /var/www/html/openWB/ramdisk/evupf2 + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/evupf2 fi if (( $n == 15 )); then evupf3=$(echo "$line" | cut -c2- ) evupf3=${evupf3%??} echo "scale=3; $evupf3/1" | bc -l > /var/www/html/openWB/ramdisk/evupf3 - -# LANG=C printf "%.3f\n" $evupf3 > /var/www/html/openWB/ramdisk/evupf3 -# echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/evupf3 - + # LANG=C printf "%.3f\n" $evupf3 > /var/www/html/openWB/ramdisk/evupf3 + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/evupf3 fi if (( $n == 16 )); then evuv1=$(echo "$line" | cut -c2- ) evuv1=${evuv1%??} echo "scale=3; $evuv1/1" | bc -l > /var/www/html/openWB/ramdisk/evuv1 - -# LANG=C printf "%.1f\n" $evuv1 > /var/www/html/openWB/ramdisk/evuv1 -# echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/evuv1 - + # LANG=C printf "%.1f\n" $evuv1 > /var/www/html/openWB/ramdisk/evuv1 + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/evuv1 fi if (( $n == 17 )); then evuv2=$(echo "$line" | cut -c2- ) evuv2=${evuv2%??} echo "scale=3; $evuv2/1" | bc -l > /var/www/html/openWB/ramdisk/evuv2 - -# LANG=C printf "%.1f\n" $evuv2 > /var/www/html/openWB/ramdisk/evuv2 -# echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/evuv2 - + # LANG=C printf "%.1f\n" $evuv2 > /var/www/html/openWB/ramdisk/evuv2 + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/evuv2 fi if (( $n == 18 )); then evuv3=$(echo "$line" | cut -c2- ) evuv3=${evuv3%??} echo "scale=3; $evuv3/1" | bc -l > /var/www/html/openWB/ramdisk/evuv3 -# LANG=C printf "%.1f\n" $evuv3 > /var/www/html/openWB/ramdisk/evuv3 -# echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/evuv3 - + # LANG=C printf "%.1f\n" $evuv3 > /var/www/html/openWB/ramdisk/evuv3 + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/evuv3 fi if (( $n == 19 )); then evuhz=$(echo "$line" | cut -c2- ) evuhz=${evuhz%??} echo "scale=3; $evuhz/1" | bc -l > /var/www/html/openWB/ramdisk/evuhz -# LANG=C printf "%.2f\n" $evuhz > /var/www/html/openWB/ramdisk/evuhz -# echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/evuhz - + # LANG=C printf "%.2f\n" $evuhz > /var/www/html/openWB/ramdisk/evuhz + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/evuhz fi if (( $n == 20 )); then bezugkwh=$(echo "$line" | cut -c2- ) -# echo ${bezugkwh%??} > /var/www/html/openWB/ramdisk/bezugkwh -# echo ${bezugkwh%??} > /var/www/html/openWB/ramdisk/einspeisungkwh + # echo ${bezugkwh%??} > /var/www/html/openWB/ramdisk/bezugkwh + # echo ${bezugkwh%??} > /var/www/html/openWB/ramdisk/einspeisungkwh fi if (( $n == 21 )); then einspeisungkwh=$(echo "$line" | cut -c2- ) -# echo ${bezugkwh%??} > /var/www/html/openWB/ramdisk/bezugkwh -# echo ${bezugkwh%??} > /var/www/html/openWB/ramdisk/einspeisungkwh + # echo ${bezugkwh%??} > /var/www/html/openWB/ramdisk/bezugkwh + # echo ${bezugkwh%??} > /var/www/html/openWB/ramdisk/einspeisungkwh fi n=$((n + 1)) done <<< "$output" - - wattbezug=`echo "($wl1+$wl2+$wl3)" |bc` echo $wl1 > /var/www/html/openWB/ramdisk/bezugw1 echo $wl2 > /var/www/html/openWB/ramdisk/bezugw2 echo $wl3 > /var/www/html/openWB/ramdisk/bezugw3 - - echo $wattbezug echo $wattbezug > /var/www/html/openWB/ramdisk/wattbezug ikwh11=${ikwh1%??} @@ -165,10 +145,9 @@ bezugkwh=${bezugkwh%??} einspeisungkwh=${einspeisungkwh%??} einspeisungkwh=$(echo "(($einspeisungkwh)*1000)" | bc) rekwh='^[-+]?[0-9]+\.?[0-9]*$' -if [[ $bezugkwh =~ $rekwh ]]; then - +if [[ $bezugkwh =~ $rekwh ]]; then bezugkwh=$(echo "(($bezugkwh)*1000)" | bc) -# LANG=C printf "%.3f\n" $bezugkwh > /var/www/html/openWB/ramdisk/bezugkwh + # LANG=C printf "%.3f\n" $bezugkwh > /var/www/html/openWB/ramdisk/bezugkwh echo "scale=3; $bezugkwh/1" | bc -l > /var/www/html/openWB/ramdisk/bezugkwh fi ekwh11=${ekwh1%??} @@ -178,12 +157,11 @@ echo $ekwh11 > /var/www/html/openWB/ramdisk/einspeisungkwh1 echo $ekwh22 > /var/www/html/openWB/ramdisk/einspeisungkwh2 echo $ekwh33 > /var/www/html/openWB/ramdisk/einspeisungkwh3 -#ekwh=$(echo "(($ekwh11+$ekwh22+$ekwh33)*1000)" |bc) +# ekwh=$(echo "(($ekwh11+$ekwh22+$ekwh33)*1000)" |bc) if [[ $einspeisungkwh =~ $rekwh ]]; then echo $einspeisungkwh > /var/www/html/openWB/ramdisk/einspeisungkwh fi -#echo ${ikwh2%??} -#echo ${ikwh3%??} - +# echo ${ikwh2%??} +# echo ${ikwh3%??} diff --git a/modules/sdm630modbusbezug/readsdm.py b/modules/sdm630modbusbezug/readsdm.py index a238e7409..d3e47cdfa 100755 --- a/modules/sdm630modbusbezug/readsdm.py +++ b/modules/sdm630modbusbezug/readsdm.py @@ -1,23 +1,22 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -seradd = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) -#rq = client.read_holding_registers(0,8,unit=5) -#print(rq.registers) +seradd = str(sys.argv[1]) sdmid = int(sys.argv[2]) -resp = client.read_input_registers(0x06,2, unit=sdmid) +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) +# rq = client.read_holding_registers(0,8,unit=5) +# print(rq.registers) +resp = client.read_input_registers(0x06,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) resp = client.read_input_registers(0x08,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) diff --git a/modules/sdm630modbusll/main.sh b/modules/sdm630modbusll/main.sh index 0b673d18b..78ee47dd4 100755 --- a/modules/sdm630modbusll/main.sh +++ b/modules/sdm630modbusll/main.sh @@ -1,5 +1,4 @@ #!/bin/bash - if [[ $sdm630modbusllsource = *virtual* ]] then if ps ax |grep -v grep |grep "socat pty,link=$sdm630modbusllsource,raw tcp:$sdm630modbuslllanip:26" > /dev/null @@ -17,114 +16,99 @@ while read -r line; do if (( $n == 0 )); then lla1=$(echo "$line" | cut -c2- ) lla1=${lla1%???} -# LANG=C printf "%.3f\n" $lla1 > /var/www/html/openWB/ramdisk/lla1 -# echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/lla1 + # LANG=C printf "%.3f\n" $lla1 > /var/www/html/openWB/ramdisk/lla1 + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/lla1 echo "scale=3; $lla1/1" | bc -l > /var/www/html/openWB/ramdisk/lla1 - fi if (( $n == 1 )); then lla2=$(echo "$line" | cut -c2- ) lla2=${lla2%???} -# LANG=C printf "%.3f\n" $lla2 > /var/www/html/openWB/ramdisk/lla2 -# echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/lla2 + # LANG=C printf "%.3f\n" $lla2 > /var/www/html/openWB/ramdisk/lla2 + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/lla2 echo "scale=3; $lla2/1" | bc -l > /var/www/html/openWB/ramdisk/lla2 - fi if (( $n == 2 )); then lla3=$(echo "$line" | cut -c2- ) lla3=${lla3%???} echo "scale=3; $lla3/1" | bc -l > /var/www/html/openWB/ramdisk/lla3 - -# LANG=C printf "%.3f\n" $lla3 > /var/www/html/openWB/ramdisk/lla3 -# echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/lla3 - + # LANG=C printf "%.3f\n" $lla3 > /var/www/html/openWB/ramdisk/lla3 + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/lla3 fi -if (( $n == 3 )); then - wl1=$(echo "$line" | cut -c2- |sed 's/\..*$//') -fi -if (( $n == 4 )); then - llkwh=$(echo "$line" | cut -c2- ) - llkwh=${llkwh%???} - rekwh='^[-+]?[0-9]+\.?[0-9]*$' - if [[ $llkwh =~ $rekwh ]]; then - #LANG=C printf "%.3f\n" $llkwh > /var/www/html/openWB/ramdisk/llkwh - echo "scale=3; $llkwh/1" | bc -l > /var/www/html/openWB/ramdisk/llkwh - - fi -fi -if (( $n == 5 )); then - wl2=$(echo "$line" | cut -c2- |sed 's/\..*$//') -fi -if (( $n == 6 )); then - wl3=$(echo "$line" | cut -c2- |sed 's/\..*$//') -fi -if (( $n == 7 )); then -llv1=$(echo "$line" | cut -c2- ) -llv1=${llv1%???} -echo "scale=1; $llv1/1" | bc -l > /var/www/html/openWB/ramdisk/llv1 -#LANG=C printf "%.1f\n" $llv1 > /var/www/html/openWB/ramdisk/llv1 -# echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llv1 - -fi -if (( $n == 8 )); then -llv2=$(echo "$line" | cut -c2- ) -llv2=${llv2%???} -echo "scale=1; $llv2/1" | bc -l > /var/www/html/openWB/ramdisk/llv2 -#LANG=C printf "%.1f\n" $llv2 > /var/www/html/openWB/ramdisk/llv2 -#echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llv2 -fi -if (( $n == 9 )); then -llv3=$(echo "$line" | cut -c2- ) -llv3=${llv3%???} -echo "scale=1; $llv3/1" | bc -l > /var/www/html/openWB/ramdisk/llv3 -#LANG=C printf "%.1f\n" $llv3 > /var/www/html/openWB/ramdisk/llv3 -# echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llv3 -fi -if (( $n == 10 )); then -#echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llaltnv -#llaltnv=$(echo "$line" | cut -c2- ) -#llaltnv=${llaltnv%??} -#printf "%.1f\n" $llaltnv > /var/www/html/openWB/ramdisk/llaltnv + if (( $n == 3 )); then + wl1=$(echo "$line" | cut -c2- |sed 's/\..*$//') + fi + if (( $n == 4 )); then + llkwh=$(echo "$line" | cut -c2- ) + llkwh=${llkwh%???} + rekwh='^[-+]?[0-9]+\.?[0-9]*$' + if [[ $llkwh =~ $rekwh ]]; then + #LANG=C printf "%.3f\n" $llkwh > /var/www/html/openWB/ramdisk/llkwh + echo "scale=3; $llkwh/1" | bc -l > /var/www/html/openWB/ramdisk/llkwh + fi + fi + if (( $n == 5 )); then + wl2=$(echo "$line" | cut -c2- |sed 's/\..*$//') + fi + if (( $n == 6 )); then + wl3=$(echo "$line" | cut -c2- |sed 's/\..*$//') + fi + if (( $n == 7 )); then + llv1=$(echo "$line" | cut -c2- ) + llv1=${llv1%???} + echo "scale=1; $llv1/1" | bc -l > /var/www/html/openWB/ramdisk/llv1 + # LANG=C printf "%.1f\n" $llv1 > /var/www/html/openWB/ramdisk/llv1 + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llv1 + fi + if (( $n == 8 )); then + llv2=$(echo "$line" | cut -c2- ) + llv2=${llv2%???} + echo "scale=1; $llv2/1" | bc -l > /var/www/html/openWB/ramdisk/llv2 + # LANG=C printf "%.1f\n" $llv2 > /var/www/html/openWB/ramdisk/llv2 + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llv2 + fi + if (( $n == 9 )); then + llv3=$(echo "$line" | cut -c2- ) + llv3=${llv3%???} + echo "scale=1; $llv3/1" | bc -l > /var/www/html/openWB/ramdisk/llv3 + # LANG=C printf "%.1f\n" $llv3 > /var/www/html/openWB/ramdisk/llv3 + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llv3 + fi + if (( $n == 10 )); then + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llaltnv + # llaltnv=$(echo "$line" | cut -c2- ) + # llaltnv=${llaltnv%??} + # printf "%.1f\n" $llaltnv > /var/www/html/openWB/ramdisk/llaltnv echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llaltnv -fi -if (( $n == 11 )); then -# llhz=$(echo "$line" | cut -c2- ) -# llhz=${llhz%??} - # printf "%.1f\n" $llhz > /var/www/html/openWB/ramdisk/llhz + fi + if (( $n == 11 )); then + # llhz=$(echo "$line" | cut -c2- ) + # llhz=${llhz%??} + # printf "%.1f\n" $llhz > /var/www/html/openWB/ramdisk/llhz echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llhz - -fi -if (( $n == 12 )); then -llpf1=$(echo "$line" | cut -c2- ) -llpf1=${llpf1%??} -echo "scale=3; $llpf1/1" | bc -l > /var/www/html/openWB/ramdisk/llpf1 -#LANG=C printf "%.3f\n" $llpf1 > /var/www/html/openWB/ramdisk/llpf1 - -fi -if (( $n == 13 )); then -llpf2=$(echo "$line" | cut -c2- ) -llpf2=${llpf2%??} -echo "scale=3; $llpf2/1" | bc -l > /var/www/html/openWB/ramdisk/llpf2 -#LANG=C printf "%.3f\n" $llpf2 > /var/www/html/openWB/ramdisk/llpf2 -fi -if (( $n == 14 )); then -llpf3=$(echo "$line" | cut -c2- ) -llpf3=${llpf3%??} -echo "scale=3; $llpf3/1" | bc -l > /var/www/html/openWB/ramdisk/llpf3 -#LANG=C printf "%.3f\n" $llpf3 > /var/www/html/openWB/ramdisk/llpf3 -fi - - + fi + if (( $n == 12 )); then + llpf1=$(echo "$line" | cut -c2- ) + llpf1=${llpf1%??} + echo "scale=3; $llpf1/1" | bc -l > /var/www/html/openWB/ramdisk/llpf1 + # LANG=C printf "%.3f\n" $llpf1 > /var/www/html/openWB/ramdisk/llpf1 + fi + if (( $n == 13 )); then + llpf2=$(echo "$line" | cut -c2- ) + llpf2=${llpf2%??} + echo "scale=3; $llpf2/1" | bc -l > /var/www/html/openWB/ramdisk/llpf2 + # LANG=C printf "%.3f\n" $llpf2 > /var/www/html/openWB/ramdisk/llpf2 + fi + if (( $n == 14 )); then + llpf3=$(echo "$line" | cut -c2- ) + llpf3=${llpf3%??} + echo "scale=3; $llpf3/1" | bc -l > /var/www/html/openWB/ramdisk/llpf3 + # LANG=C printf "%.3f\n" $llpf3 > /var/www/html/openWB/ramdisk/llpf3 + fi n=$((n + 1)) - done <<< "$output" - - +done <<< "$output" re='^-?[0-9]+$' if [[ $wl1 =~ $re ]] && [[ $wl2 =~ $re ]] && [[ $wl3 =~ $re ]]; then llaktuell=`echo "($wl1+$wl2+$wl3)" |bc` echo $llaktuell > /var/www/html/openWB/ramdisk/llaktuell fi - - - diff --git a/modules/sdm630modbusll/readsdm.py b/modules/sdm630modbusll/readsdm.py index 90290bd4b..354464691 100755 --- a/modules/sdm630modbusll/readsdm.py +++ b/modules/sdm630modbusll/readsdm.py @@ -1,29 +1,27 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -seradd = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) -#rq = client.read_holding_registers(0,8,unit=5) -#print(rq.registers) +seradd = str(sys.argv[1]) sdmid = int(sys.argv[2]) -resp = client.read_input_registers(0x06,2, unit=sdmid) +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) +# rq = client.read_holding_registers(0,8,unit=5) +# print(rq.registers) +resp = client.read_input_registers(0x06,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) resp = client.read_input_registers(0x08,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) resp = client.read_input_registers(0x0A,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) - resp = client.read_input_registers(0x0C,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) resp = client.read_input_registers(0x0156,2, unit=sdmid) @@ -48,6 +46,3 @@ print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) resp = client.read_input_registers(0x22,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) - - - diff --git a/modules/sdm630modbuslls1/main.sh b/modules/sdm630modbuslls1/main.sh index 3aaa3d1b3..ef5512369 100755 --- a/modules/sdm630modbuslls1/main.sh +++ b/modules/sdm630modbuslls1/main.sh @@ -1,5 +1,4 @@ #!/bin/bash - if [[ $sdm630lp2source = *virtual* ]] then if ps ax |grep -v grep |grep "socat pty,link=$sdm630lp2source,raw tcp:$lllaniplp2:26" > /dev/null @@ -18,43 +17,40 @@ while read -r line; do llas11=$(echo "$line" | cut -c2- ) llas11=${llas11%??} echo "scale=3; $llas11/1" | bc -l > /var/www/html/openWB/ramdisk/llas11 - -# echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llas11 - + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llas11 fi if (( $n == 1 )); then llas12=$(echo "$line" | cut -c2- ) llas12=${llas12%??} echo "scale=3; $llas12/1" | bc -l > /var/www/html/openWB/ramdisk/llas12 -# echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llas12 - + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llas12 fi if (( $n == 2 )); then llas13=$(echo "$line" | cut -c2- ) llas13=${llas13%??} echo "scale=3; $llas13/1" | bc -l > /var/www/html/openWB/ramdisk/llas13 -# echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llas13 + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llas13 fi -if (( $n == 3 )); then - wl1=$(echo "$line" | cut -c2- |sed 's/\..*$//') -fi -if (( $n == 4 )); then - llkwhs1=$(echo "$line" | cut -c2- ) - llkwhs1=${llkwhs1%??} - rekwh='^[-+]?[0-9]+\.?[0-9]*$' - if [[ $llkwhs1 =~ $rekwh ]]; then - echo "scale=3; $llkwhs1/1" | bc -l > /var/www/html/openWB/ramdisk/llkwhs1 + if (( $n == 3 )); then + wl1=$(echo "$line" | cut -c2- |sed 's/\..*$//') + fi + if (( $n == 4 )); then + llkwhs1=$(echo "$line" | cut -c2- ) + llkwhs1=${llkwhs1%??} + rekwh='^[-+]?[0-9]+\.?[0-9]*$' + if [[ $llkwhs1 =~ $rekwh ]]; then + echo "scale=3; $llkwhs1/1" | bc -l > /var/www/html/openWB/ramdisk/llkwhs1 + fi + fi + if (( $n == 5 )); then + wl2=$(echo "$line" | cut -c2- |sed 's/\..*$//') + fi + if (( $n == 6 )); then + wl3=$(echo "$line" | cut -c2- |sed 's/\..*$//') fi -fi -if (( $n == 5 )); then - wl2=$(echo "$line" | cut -c2- |sed 's/\..*$//') -fi -if (( $n == 6 )); then - wl3=$(echo "$line" | cut -c2- |sed 's/\..*$//') -fi -n=$((n + 1)) - done <<< "$output" + n=$((n + 1)) +done <<< "$output" llaktuells1=`echo "($wl1+$wl2+$wl3)" |bc` echo $llaktuells1 > /var/www/html/openWB/ramdisk/llaktuells1 @@ -63,6 +59,3 @@ if [[ $wl1 =~ $re ]] && [[ $wl2 =~ $re ]] && [[ $wl3 =~ $re ]]; then llaktuell=`echo "($wl1+$wl2+$wl3)" |bc` echo $llaktuell > /var/www/html/openWB/ramdisk/llaktuells1 fi - - - diff --git a/modules/sdm630modbuslls1/readsdm.py b/modules/sdm630modbuslls1/readsdm.py index de8e4e957..3eab3818f 100755 --- a/modules/sdm630modbuslls1/readsdm.py +++ b/modules/sdm630modbuslls1/readsdm.py @@ -1,29 +1,28 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -seradd = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) -#rq = client.read_holding_registers(0,8,unit=5) -#print(rq.registers) +seradd = str(sys.argv[1]) sdmid = int(sys.argv[2]) -resp = client.read_input_registers(0x06,2, unit=sdmid) +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) + +# rq = client.read_holding_registers(0,8,unit=5) +# print(rq.registers) +resp = client.read_input_registers(0x06,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) resp = client.read_input_registers(0x08,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) resp = client.read_input_registers(0x0A,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) - resp = client.read_input_registers(0x0C,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) resp = client.read_input_registers(0x0156,2, unit=sdmid) @@ -32,5 +31,3 @@ print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) resp = client.read_input_registers(0x10,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) - - diff --git a/modules/sdm630modbuslls2/main.sh b/modules/sdm630modbuslls2/main.sh index 1b6288e73..68dea8b1e 100755 --- a/modules/sdm630modbuslls2/main.sh +++ b/modules/sdm630modbuslls2/main.sh @@ -1,5 +1,4 @@ #!/bin/bash - if [[ $sdm630lp3source = *virtual* ]] then if ps ax |grep -v grep |grep "socat pty,link=$sdm630lp3source,raw tcp:$lllaniplp3:26" > /dev/null @@ -18,21 +17,19 @@ while read -r line; do llas21=$(echo "$line" | cut -c2- ) llas21=${llas21%??} echo "scale=3; $llas21/1" | bc -l > /var/www/html/openWB/ramdisk/llas21 -# echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llas21 - + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llas21 fi if (( $n == 1 )); then llas22=$(echo "$line" | cut -c2- ) llas22=${llas22%??} echo "scale=3; $llas22/1" | bc -l > /var/www/html/openWB/ramdisk/llas22 -# echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llas22 - + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llas22 fi if (( $n == 2 )); then llas23=$(echo "$line" | cut -c2- ) llas23=${llas23%??} echo "scale=3; $llas23/1" | bc -l > /var/www/html/openWB/ramdisk/llas23 -# echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llas23 + # echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llas23 fi if (( $n == 3 )); then wl1=$(echo "$line" | cut -c2- |sed 's/\..*$//') @@ -51,17 +48,11 @@ while read -r line; do if (( $n == 6 )); then wl3=$(echo "$line" | cut -c2- |sed 's/\..*$//') fi - n=$((n + 1)) - done <<< "$output" +done <<< "$output" - re='^-?[0-9]+$' if [[ $wl1 =~ $re ]] && [[ $wl2 =~ $re ]] && [[ $wl3 =~ $re ]]; then llaktuells2=`echo "($wl1+$wl2+$wl3)" |bc` echo $llaktuells2 > /var/www/html/openWB/ramdisk/llaktuells2 fi - - - - diff --git a/modules/sdm630modbuslls2/readsdm.py b/modules/sdm630modbuslls2/readsdm.py index de8e4e957..262dfd283 100755 --- a/modules/sdm630modbuslls2/readsdm.py +++ b/modules/sdm630modbuslls2/readsdm.py @@ -1,29 +1,27 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -seradd = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) -#rq = client.read_holding_registers(0,8,unit=5) -#print(rq.registers) +seradd = str(sys.argv[1]) sdmid = int(sys.argv[2]) -resp = client.read_input_registers(0x06,2, unit=sdmid) +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) +# rq = client.read_holding_registers(0,8,unit=5) +# print(rq.registers) +resp = client.read_input_registers(0x06,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) resp = client.read_input_registers(0x08,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) resp = client.read_input_registers(0x0A,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) - resp = client.read_input_registers(0x0C,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) resp = client.read_input_registers(0x0156,2, unit=sdmid) @@ -32,5 +30,3 @@ print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) resp = client.read_input_registers(0x10,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) - - diff --git a/modules/sdm630modbuswr/main.sh b/modules/sdm630modbuswr/main.sh index 8bdffe367..8fe943ec1 100755 --- a/modules/sdm630modbuswr/main.sh +++ b/modules/sdm630modbuswr/main.sh @@ -1,6 +1,4 @@ #!/bin/bash - - if [[ $sdm630modbuswrsource = *virtual* ]] then if ps ax |grep -v grep |grep "socat pty,link=$sdm630modbuswrsource,raw tcp:$sdm630modbuswrlanip:26" > /dev/null @@ -40,7 +38,6 @@ while read -r line; do echo $wrwh > /var/www/html/openWB/ramdisk/pvkwh LANG=C printf "%.4f\n" $wrkwh > /var/www/html/openWB/ramdisk/pvkwhk fi - n=$((n + 1)) done <<< "$output" @@ -50,5 +47,3 @@ if (( wattwr > 0 )); then fi echo $wattwr echo $wattwr > /var/www/html/openWB/ramdisk/pvwatt - - diff --git a/modules/sdm630modbuswr/readsdm.py b/modules/sdm630modbuswr/readsdm.py index 944b32533..744e73962 100755 --- a/modules/sdm630modbuswr/readsdm.py +++ b/modules/sdm630modbuswr/readsdm.py @@ -1,29 +1,27 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -seradd = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) -#rq = client.read_holding_registers(0,8,unit=5) -#print(rq.registers) +seradd = str(sys.argv[1]) sdmid = int(sys.argv[2]) -resp = client.read_input_registers(0x06,2, unit=sdmid) +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) +# rq = client.read_holding_registers(0,8,unit=5) +# print(rq.registers) +resp = client.read_input_registers(0x06,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) resp = client.read_input_registers(0x08,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) resp = client.read_input_registers(0x0A,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) - resp = client.read_input_registers(0x0C,2, unit=sdmid) print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) resp = client.read_input_registers(0x0E,2, unit=sdmid) @@ -32,6 +30,3 @@ 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))) - - - diff --git a/modules/simpleevsewifi/main.sh b/modules/simpleevsewifi/main.sh index b01f416ff..03ad50db2 100755 --- a/modules/simpleevsewifi/main.sh +++ b/modules/simpleevsewifi/main.sh @@ -3,36 +3,38 @@ re='^-?[0-9]+$' rekwh='^[-+]?[0-9]+\.?[0-9]*$' output=$(curl --connect-timeout $evsewifitimeoutlp1 -s http://$evsewifiiplp1/getParameters) -watt=$(echo $output | jq '.list[] | .actualPower') -lla1=$(echo $output | jq '.list[] | .currentP1') -lla2=$(echo $output | jq '.list[] | .currentP2') -lla3=$(echo $output | jq '.list[] | .currentP3') -evsewifiplugstatelp1=$(echo $output | jq '.list[] | .vehicleState') -llkwh=$(echo $output | jq '.list[] | .meterReading') -watt=$(echo "scale=0;$watt * 1000 /1" |bc) -if [[ $watt =~ $re ]] ; then - echo $watt > /var/www/html/openWB/ramdisk/llaktuell -fi -if [[ $lla1 =~ $rekwh ]] ; then - echo $lla1 > /var/www/html/openWB/ramdisk/lla1 -fi -if [[ $lla2 =~ $rekwh ]] ; then - echo $lla2 > /var/www/html/openWB/ramdisk/lla2 -fi -if [[ $lla3 =~ $rekwh ]] ; then - echo $lla3 > /var/www/html/openWB/ramdisk/lla3 -fi -if [[ $llkwh =~ $rekwh ]] ; then - echo $llkwh > /var/www/html/openWB/ramdisk/llkwh -fi -if [[ $evsewifiplugstatelp1 > "1" ]]; then - echo 1 > /var/www/html/openWB/ramdisk/plugstat -else - echo 0 > /var/www/html/openWB/ramdisk/plugstat -fi -if [[ $evsewifiplugstatelp1 > "2" ]] ; then - echo 1 > /var/www/html/openWB/ramdisk/chargestat -else - echo 0 > /var/www/html/openWB/ramdisk/chargestat -fi +if ! [ -z "$output" ]; then + watt=$(echo $output | jq '.list[] | .actualPower') + lla1=$(echo $output | jq '.list[] | .currentP1') + lla2=$(echo $output | jq '.list[] | .currentP2') + lla3=$(echo $output | jq '.list[] | .currentP3') + llkwh=$(echo $output | jq '.list[] | .meterReading') + evsewifiplugstatelp1=$(echo $output | jq '.list[] | .vehicleState') + watt=$(echo "scale=0;$watt * 1000 /1" |bc) + if [[ $watt =~ $re ]] ; then + echo $watt > /var/www/html/openWB/ramdisk/llaktuell + fi + if [[ $lla1 =~ $re ]] ; then + echo $lla1 > /var/www/html/openWB/ramdisk/lla1 + fi + if [[ $lla2 =~ $re ]] ; then + echo $lla2 > /var/www/html/openWB/ramdisk/lla2 + fi + if [[ $lla3 =~ $re ]] ; then + echo $lla3 > /var/www/html/openWB/ramdisk/lla3 + fi + if [[ $llkwh =~ $rekwh ]] ; then + echo $llkwh > /var/www/html/openWB/ramdisk/llkwh + fi + if [[ $evsewifiplugstatelp1 > "1" ]] ; then + echo 1 > /var/www/html/openWB/ramdisk/plugstat + else + echo 0 > /var/www/html/openWB/ramdisk/plugstat + fi + if [[ $evsewifiplugstatelp1 > "2" ]] ; then + echo 1 > /var/www/html/openWB/ramdisk/chargestat + else + echo 0 > /var/www/html/openWB/ramdisk/chargestat + fi +fi diff --git a/modules/simpleevsewifis1/main.sh b/modules/simpleevsewifis1/main.sh index c5e13f35a..f1152331e 100755 --- a/modules/simpleevsewifis1/main.sh +++ b/modules/simpleevsewifis1/main.sh @@ -3,36 +3,38 @@ re='^-?[0-9]+$' rekwh='^[-+]?[0-9]+\.?[0-9]*$' output=$(curl --connect-timeout $evsewifitimeoutlp2 -s http://$evsewifiiplp2/getParameters) -watt=$(echo $output | jq '.list[] | .actualPower') -lla1=$(echo $output | jq '.list[] | .currentP1') -lla2=$(echo $output | jq '.list[] | .currentP2') -lla3=$(echo $output | jq '.list[] | .currentP3') -llkwh=$(echo $output | jq '.list[] | .meterReading') -evsewifiplugstatelp2=$(echo $output | jq '.list[] | .vehicleState') -watt=$(echo "scale=0;$watt * 1000 /1" |bc) -if [[ $watt =~ $re ]] ; then - echo $watt > /var/www/html/openWB/ramdisk/llaktuells1 -fi -if [[ $lla1 =~ $rekwh ]] ; then - echo $lla1 > /var/www/html/openWB/ramdisk/llas11 -fi -if [[ $lla2 =~ $rekwh ]] ; then - echo $lla2 > /var/www/html/openWB/ramdisk/llas12 -fi -if [[ $lla3 =~ $rekwh ]] ; then - echo $lla3 > /var/www/html/openWB/ramdisk/llas13 -fi -if [[ $llkwh =~ $rekwh ]] ; then - echo $llkwh > /var/www/html/openWB/ramdisk/llkwhs1 -fi -if [[ $evsewifiplugstatelp2 > "1" ]]; then - echo 1 > /var/www/html/openWB/ramdisk/plugstats1 -else - echo 0 > /var/www/html/openWB/ramdisk/plugstats1 -fi -if [[ $evsewifiplugstatelp2 > "2" ]]; then - echo 1 > /var/www/html/openWB/ramdisk/chargestats1 -else - echo 0 > /var/www/html/openWB/ramdisk/chargestats1 -fi +if ! [ -z "$output" ]; then + watt=$(echo $output | jq '.list[] | .actualPower') + lla1=$(echo $output | jq '.list[] | .currentP1') + lla2=$(echo $output | jq '.list[] | .currentP2') + lla3=$(echo $output | jq '.list[] | .currentP3') + llkwh=$(echo $output | jq '.list[] | .meterReading') + evsewifiplugstatelp2=$(echo $output | jq '.list[] | .vehicleState') + watt=$(echo "scale=0;$watt * 1000 /1" |bc) + if [[ $watt =~ $re ]] ; then + echo $watt > /var/www/html/openWB/ramdisk/llaktuells1 + fi + if [[ $lla1 =~ $re ]] ; then + echo $lla1 > /var/www/html/openWB/ramdisk/llas11 + fi + if [[ $lla2 =~ $re ]] ; then + echo $lla2 > /var/www/html/openWB/ramdisk/llas12 + fi + if [[ $lla3 =~ $re ]] ; then + echo $lla3 > /var/www/html/openWB/ramdisk/llas13 + fi + if [[ $llkwh =~ $rekwh ]] ; then + echo $llkwh > /var/www/html/openWB/ramdisk/llkwhs1 + fi + if [[ $evsewifiplugstatelp2 > "1" ]] ; then + echo 1 > /var/www/html/openWB/ramdisk/plugstats1 + else + echo 0 > /var/www/html/openWB/ramdisk/plugstats1 + fi + if [[ $evsewifiplugstatelp2 > "2" ]] ; then + echo 1 > /var/www/html/openWB/ramdisk/chargestats1 + else + echo 0 > /var/www/html/openWB/ramdisk/chargestats1 + fi +fi diff --git a/modules/simpleevsewifis2/main.sh b/modules/simpleevsewifis2/main.sh index 1605fe7e5..294b2d507 100755 --- a/modules/simpleevsewifis2/main.sh +++ b/modules/simpleevsewifis2/main.sh @@ -1,6 +1,7 @@ #!/bin/bash re='^-?[0-9]+$' rekwh='^[-+]?[0-9]+\.?[0-9]*$' + output=$(curl --connect-timeout $evsewifitimeoutlp3 -s http://$evsewifiiplp3/getParameters) if ! [ -z "$output" ]; then watt=$(echo $output | jq '.list[] | .actualPower') @@ -26,7 +27,7 @@ if ! [ -z "$output" ]; then if [[ $llkwh =~ $rekwh ]] ; then echo $llkwh > /var/www/html/openWB/ramdisk/llkwhs2 fi - if [[ $evsewifiplugstatelp3 > "1" ]]; then + if [[ $evsewifiplugstatelp3 > "1" ]] ; then echo 1 > /var/www/html/openWB/ramdisk/plugstatlp3 else echo 0 > /var/www/html/openWB/ramdisk/plugstatlp3 diff --git a/modules/smaemd_bezug/main.sh b/modules/smaemd_bezug/main.sh index 31d543ac0..5258091da 100755 --- a/modules/smaemd_bezug/main.sh +++ b/modules/smaemd_bezug/main.sh @@ -1,7 +1,5 @@ #!/bin/bash - - ikwh=$(cat /run/shm/em-$smaemdbezugid-pregardcounter) ekwh=$(cat /run/shm/em-$smaemdbezugid-psurpluscounter) bezuga1=$(cat /run/shm/em-$smaemdbezugid-p1regard |sed 's/\..*$//') @@ -21,9 +19,8 @@ echo $bezuga1 > /var/www/html/openWB/ramdisk/bezuga1 echo $bezuga2 > /var/www/html/openWB/ramdisk/bezuga2 echo $bezuga3 > /var/www/html/openWB/ramdisk/bezuga3 - if (( $watteinspeisung > 5 ));then - wattbezug=$(echo -$watteinspeisung) - fi - echo $wattbezug - echo $wattbezug > /var/www/html/openWB/ramdisk/wattbezug + wattbezug=$(echo -$watteinspeisung) +fi +echo $wattbezug +echo $wattbezug > /var/www/html/openWB/ramdisk/wattbezug diff --git a/modules/smaemd_ll/main.sh b/modules/smaemd_ll/main.sh index d927f68f0..53ebb94a4 100755 --- a/modules/smaemd_ll/main.sh +++ b/modules/smaemd_ll/main.sh @@ -1,7 +1,5 @@ #!/bin/bash - - illwh=$(cat /run/shm/em-$smaemdllid-pregardcounter) llwatt=$(cat /run/shm/em-$smaemdllid-pregard |sed 's/\..*$//') bezuga1=$(cat /run/shm/em-$smaemdllid-p1regard |sed 's/\..*$//') @@ -13,5 +11,3 @@ echo $llwatt > /var/www/html/openWB/ramdisk/llaktuell echo $bezuga1 > /var/www/html/openWB/ramdisk/lla1 echo $bezuga2 > /var/www/html/openWB/ramdisk/lla2 echo $bezuga3 > /var/www/html/openWB/ramdisk/lla3 - - diff --git a/modules/smaemd_pv/main.sh b/modules/smaemd_pv/main.sh index 3afd8a8d5..2d15eb642 100755 --- a/modules/smaemd_pv/main.sh +++ b/modules/smaemd_pv/main.sh @@ -3,4 +3,3 @@ timeout 3 python3 /var/www/html/openWB/modules/smaemd_pv/sma-em-measurement.py $smaemdpvid pvwatt=$(i', all.decode('hex'))[0]) -#print final -#pv punkt +# print "hausverbrauch" +# resp= client.read_holding_registers(40071,2,unit=1) +# value1 = resp.registers[0] +# value2 = resp.registers[1] +# all = format(value2, '04x') + format(value1, '04x') +# final = int(struct.unpack('>i', all.decode('hex'))[0]) +# print final +# pv punkt ext = 0 if addext == 1: - resp= client.read_holding_registers(40075,2,unit=1) - value1 = resp.registers[0] - value2 = resp.registers[1] - all = format(value2, '04x') + format(value1, '04x') - ext = int(struct.unpack('>i', all.decode('hex'))[0]) + resp= client.read_holding_registers(40075,2,unit=1) + value1 = resp.registers[0] + value2 = resp.registers[1] + all = format(value2, '04x') + format(value1, '04x') + ext = int(struct.unpack('>i', all.decode('hex'))[0]) resp= client.read_holding_registers(40067,2,unit=1) value1 = resp.registers[0] value2 = resp.registers[1] diff --git a/modules/speicher_e3dc/e3dcfarm.py b/modules/speicher_e3dc/e3dcfarm.py index 3b20f9066..041fe7f0d 100755 --- a/modules/speicher_e3dc/e3dcfarm.py +++ b/modules/speicher_e3dc/e3dcfarm.py @@ -1,19 +1,21 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusTcpClient + ipaddress = str(sys.argv[1]) ip2address = str(sys.argv[2]) -from pymodbus.client.sync import ModbusTcpClient + client = ModbusTcpClient(ipaddress, port=502) client2 = ModbusTcpClient(ip2address, port=502) #Zweites E3DC -#battsoc +# battsoc resp= client.read_holding_registers(40082,1,unit=1) resp2= client2.read_holding_registers(40082,1,unit=1) #Zweites E3DC value1 = resp.registers[0] @@ -26,14 +28,14 @@ f = open('/var/www/html/openWB/ramdisk/speichersoc', 'w') f.write(str(final)) f.close() -#print "hausverbrauch" -#resp= client.read_holding_registers(40071,2,unit=1) -#value1 = resp.registers[0] -#value2 = resp.registers[1] -#all = format(value2, '04x') + format(value1, '04x') -#final = int(struct.unpack('>i', all.decode('hex'))[0]) -#print final -#pv punkt +# print "hausverbrauch" +# resp= client.read_holding_registers(40071,2,unit=1) +# value1 = resp.registers[0] +# value2 = resp.registers[1] +# all = format(value2, '04x') + format(value1, '04x') +# final = int(struct.unpack('>i', all.decode('hex'))[0]) +# print final +# pv punkt resp= client.read_holding_registers(40067,2,unit=1) resp2= client2.read_holding_registers(40067,2,unit=1) #Zweites E3DC value1 = resp.registers[0] @@ -53,7 +55,7 @@ f = open('/var/www/html/openWB/ramdisk/pvwatt', 'w') f.write(str(final)) f.close() -#battleistung +# battleistung resp= client.read_holding_registers(40069,2,unit=1) resp2= client2.read_holding_registers(40069,2,unit=1) #Zweites E3DC value1 = resp.registers[0] @@ -68,5 +70,3 @@ f = open('/var/www/html/openWB/ramdisk/speicherleistung', 'w') f.write(str(final)) f.close() - - diff --git a/modules/speicher_e3dc/main.sh b/modules/speicher_e3dc/main.sh index 45ce87c57..d31cebd9e 100755 --- a/modules/speicher_e3dc/main.sh +++ b/modules/speicher_e3dc/main.sh @@ -3,7 +3,7 @@ if [[ $pvwattmodul != "none" ]]; then pvwattold=$( /var/www/html/openWB/ramdisk/speichersoc echo $leistung > /var/www/html/openWB/ramdisk/speicherleistung - echo $speicheriwh > /var/www/html/openWB/ramdisk/speicherikwh echo $speicherewh > /var/www/html/openWB/ramdisk/speicherekwh - diff --git a/modules/speicher_fronius/main.sh b/modules/speicher_fronius/main.sh index dd1b579e4..7490bb035 100755 --- a/modules/speicher_fronius/main.sh +++ b/modules/speicher_fronius/main.sh @@ -3,22 +3,19 @@ #Auslesen eines Fronius Symo WR Hybrid mit Fronius Smartmeter und Batterie über die integrierte JSON-API des WR. speicherwatttmp=$(curl --connect-timeout 5 -s "$wrfroniusip/solar_api/v1/GetPowerFlowRealtimeData.fcgi?Scope=System") - - speicherwatt=$(echo $speicherwatttmp | jq '.Body.Data.Site.P_Akku' | sed 's/\..*$//') speicherwatt=$(echo "$speicherwatt * -1" | bc) #wenn WR aus bzw. im standby (keine Antwort) ersetze leeren Wert durch eine 0 ra='^-?[0-9]+$' if ! [[ $speicherwatt =~ $ra ]] ; then - speicherwatt="0" + speicherwatt="0" fi echo $speicherwatt > /var/www/html/openWB/ramdisk/speicherleistung speichersoc=$(echo $speicherwatttmp | jq '.Body.Data.Inverters."1".SOC' | sed 's/\..*$//') if ! [[ $speichersoc =~ $ra ]] ; then - speichersoc="0" + speichersoc="0" fi echo $speichersoc > /var/www/html/openWB/ramdisk/speichersoc - diff --git a/modules/speicher_http/main.sh b/modules/speicher_http/main.sh index 07cda9a4b..64220258a 100755 --- a/modules/speicher_http/main.sh +++ b/modules/speicher_http/main.sh @@ -6,7 +6,6 @@ re='^-?[0-9]+$' echo $soc > /var/www/html/openWB/ramdisk/speichersoc leistung=$(curl --connect-timeout 10 -s $speicherleistung_http ) -re='^-?[0-9]+$' echo $leistung > /var/www/html/openWB/ramdisk/speicherleistung @@ -19,4 +18,3 @@ if [[ speicherekwh != "none" ]]; then ekwh=$(curl --connect-timeout 10 -s $speicherekwh_http) echo $ekwh > /var/www/html/openWB/ramdisk/speicherekwh fi - diff --git a/modules/speicher_json/main.sh b/modules/speicher_json/main.sh index 2c611479b..4837c17ce 100644 --- a/modules/speicher_json/main.sh +++ b/modules/speicher_json/main.sh @@ -19,9 +19,9 @@ echo ${speicherleistung} echo $speicherleistung > /var/www/html/openWB/ramdisk/speicherleistung if [ ! -z "$battjsonsoc" ]; then - battsoc=$(echo $answer | jq -r "$battjsonsoc") + battsoc=$(echo $answer | jq -r "$battjsonsoc") else - battsoc=0 + battsoc=0 fi openwbDebugLog ${DMOD} 1 "BattSoC: ${battsoc}" diff --git a/modules/speicher_lgessv1/main.sh b/modules/speicher_lgessv1/main.sh index bdcf95440..14d523e9d 100755 --- a/modules/speicher_lgessv1/main.sh +++ b/modules/speicher_lgessv1/main.sh @@ -25,7 +25,7 @@ fi # z.b. wenn das System neu gestartet wurde, dann wird ein Dummykey an- # gelegt if test -f "/var/www/html/openWB/ramdisk/ess_session_key"; then - session_key=$(sed -n '1p' /var/www/html/openWB/ramdisk/ess_session_key) + session_key=$(sed -n '1p' /var/www/html/openWB/ramdisk/ess_session_key) else session_key=" " fi diff --git a/modules/speicher_mpm3pm/main.sh b/modules/speicher_mpm3pm/main.sh index 54647acdc..87002b538 100755 --- a/modules/speicher_mpm3pm/main.sh +++ b/modules/speicher_mpm3pm/main.sh @@ -7,7 +7,3 @@ elif (( speicherkitversion == 2 )); then else sudo python /var/www/html/openWB/modules/speicher_mpm3pm/readmpm3pm.py fi - - - - diff --git a/modules/speicher_mpm3pm/readmpm3pm.py b/modules/speicher_mpm3pm/readmpm3pm.py index 6a790ae23..6b9297fd2 100755 --- a/modules/speicher_mpm3pm/readmpm3pm.py +++ b/modules/speicher_mpm3pm/readmpm3pm.py @@ -1,16 +1,12 @@ #!/usr/bin/python -import sys -import os -import time -import getopt +# import sys +# import os +# import time +# import getopt import struct from pymodbus.client.sync import ModbusTcpClient -client = ModbusTcpClient('192.168.193.19', port=8899) -#from pymodbus.transaction import ModbusRtuFramer -#client = ModbusTcpClient('192.168.0.7', port=8899, framer=ModbusRtuFramer) - - +client = ModbusTcpClient('192.168.193.19', port=8899) resp = client.read_input_registers(0x0002,4, unit=1) value1 = resp.registers[0] @@ -22,7 +18,7 @@ f.write(str(ikwh)) f.close() -#total watt +# total watt resp = client.read_input_registers(0x26,2, unit=1) value1 = resp.registers[0] value2 = resp.registers[1] @@ -32,7 +28,7 @@ f.write(str(final)) f.close() -#export kwh +# export kwh resp = client.read_input_registers(0x0004,4, unit=1) value1 = resp.registers[0] value2 = resp.registers[1] @@ -42,4 +38,3 @@ f = open('/var/www/html/openWB/ramdisk/speicherekwh', 'w') f.write(str(ekwh)) f.close() - diff --git a/modules/speicher_mpm3pm/readsdm120.py b/modules/speicher_mpm3pm/readsdm120.py index b35b179e6..7ebd69f91 100755 --- a/modules/speicher_mpm3pm/readsdm120.py +++ b/modules/speicher_mpm3pm/readsdm120.py @@ -1,16 +1,12 @@ #!/usr/bin/python -import sys -import os -import time -import getopt +# import sys +# import os +# import time +# import getopt import struct from pymodbus.client.sync import ModbusTcpClient -client = ModbusTcpClient('192.168.193.19', port=8899) -#from pymodbus.transaction import ModbusRtuFramer -#client = ModbusTcpClient('192.168.0.7', port=8899, framer=ModbusRtuFramer) - - +client = ModbusTcpClient('192.168.193.19', port=8899) resp = client.read_input_registers(0x0048,2, unit=9) vwh = struct.unpack('>f',struct.pack('>HH',*resp.registers)) @@ -19,7 +15,7 @@ f.write(str(ikwh)) f.close() -#total watt +# total watt resp = client.read_input_registers(0x000C,2, unit=9) watt = struct.unpack('>f',struct.pack('>HH',*resp.registers)) watt = int(watt[0]) @@ -27,14 +23,10 @@ f.write(str(watt)) f.close() - - -#export kwh +# export kwh resp = client.read_input_registers(0x004a,2, unit=9) vwhe = struct.unpack('>f',struct.pack('>HH',*resp.registers)) ekwh = float("%.3f" % vwhe[0]) * int(1000) f = open('/var/www/html/openWB/ramdisk/speicherekwh', 'w') f.write(str(ekwh)) f.close() - - diff --git a/modules/speicher_mpm3pm/readsdm630.py b/modules/speicher_mpm3pm/readsdm630.py index e0075e311..431dca291 100755 --- a/modules/speicher_mpm3pm/readsdm630.py +++ b/modules/speicher_mpm3pm/readsdm630.py @@ -1,16 +1,12 @@ #!/usr/bin/python -import sys -import os -import time -import getopt +# 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) - - +client = ModbusTcpClient('192.168.193.15', port=8899) resp = client.read_input_registers(0x0048,2, unit=117) vwh = struct.unpack('>f',struct.pack('>HH',*resp.registers)) @@ -19,7 +15,7 @@ f.write(str(ikwh)) f.close() -#total watt +# total watt resp = client.read_input_registers(0x000C,2, unit=117) watt = struct.unpack('>f',struct.pack('>HH',*resp.registers)) watt1 = int(watt[0]) @@ -34,14 +30,10 @@ f.write(str(final)) f.close() - - -#export kwh +# export kwh resp = client.read_input_registers(0x004a,2, unit=117) vwhe = struct.unpack('>f',struct.pack('>HH',*resp.registers)) ekwh = float("%.3f" % vwhe[0]) * int(1000) f = open('/var/www/html/openWB/ramdisk/speicherekwh', 'w') f.write(str(ekwh)) f.close() - - diff --git a/modules/speicher_saxpower/main.sh b/modules/speicher_saxpower/main.sh index 4a325fad3..9f92631c3 100644 --- a/modules/speicher_saxpower/main.sh +++ b/modules/speicher_saxpower/main.sh @@ -1,5 +1,2 @@ #!/bin/bash - python /var/www/html/openWB/modules/speicher_saxpower/saxpower.py $speicher1_ip - - diff --git a/modules/speicher_saxpower/saxpower.py b/modules/speicher_saxpower/saxpower.py index 8222a01f8..667291275 100644 --- a/modules/speicher_saxpower/saxpower.py +++ b/modules/speicher_saxpower/saxpower.py @@ -1,35 +1,27 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket - +# import os +# import time +# import getopt +# import socket +from pymodbus.client.sync import ModbusTcpClient ipaddress = str(sys.argv[1]) -from pymodbus.client.sync import ModbusTcpClient - client = ModbusTcpClient(ipaddress, port=3600) -#Register auslesen -client = ModbusTcpClient(ipaddress, port=3600) +# Register auslesen resp= client.read_holding_registers(46, 2,unit=64) - -#SOC +# SOC soc = resp.registers[0] f = open('/var/www/html/openWB/ramdisk/speichersoc', 'w') f.write(str(soc)) f.close() - - - -##akt. Speicherleistung +# akt. Speicherleistung sax_pow=resp.registers[1] - -#unsigned to signed int +# unsigned to signed int if sax_pow > 32767: sax_pow -= 65535 @@ -40,4 +32,3 @@ f = open('/var/www/html/openWB/ramdisk/speicherleistung', 'w') f.write(str(sax_pow)) f.close() - diff --git a/modules/speicher_sbs25/main.sh b/modules/speicher_sbs25/main.sh index 841b188f6..95680d280 100755 --- a/modules/speicher_sbs25/main.sh +++ b/modules/speicher_sbs25/main.sh @@ -1,5 +1,3 @@ #!/bin/bash - - sudo python /var/www/html/openWB/modules/speicher_sbs25/sbs25.py $sbs25ip diff --git a/modules/speicher_sbs25/sbs25.py b/modules/speicher_sbs25/sbs25.py index 49baffe14..d2089d745 100755 --- a/modules/speicher_sbs25/sbs25.py +++ b/modules/speicher_sbs25/sbs25.py @@ -1,17 +1,19 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -ipaddress = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusTcpClient + +ipaddress = str(sys.argv[1]) + client = ModbusTcpClient(ipaddress, port=502) -#print "SoC batt" +# print "SoC batt" resp= client.read_holding_registers(30845,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] @@ -21,7 +23,7 @@ f.write(str(final)) f.close() -#print "be-entladen watt" +# print "be-entladen watt" resp= client.read_holding_registers(31393,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] @@ -39,6 +41,3 @@ f = open('/var/www/html/openWB/ramdisk/speicherleistung', 'w') f.write(str(final)) f.close() - - - diff --git a/modules/speicher_siemens/main.sh b/modules/speicher_siemens/main.sh index 30218488d..ceeb4bfb2 100755 --- a/modules/speicher_siemens/main.sh +++ b/modules/speicher_siemens/main.sh @@ -1,5 +1,3 @@ #!/bin/bash - - python /var/www/html/openWB/modules/speicher_siemens/siemens.py $speicher1_ip diff --git a/modules/speicher_siemens/siemens.py b/modules/speicher_siemens/siemens.py index fa0f83281..709ddbb83 100755 --- a/modules/speicher_siemens/siemens.py +++ b/modules/speicher_siemens/siemens.py @@ -1,17 +1,19 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -ipaddress = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusTcpClient + +ipaddress = str(sys.argv[1]) + client = ModbusTcpClient(ipaddress, port=502) -#speicherleistung +# speicherleistung resp= client.read_holding_registers(6,2,unit=1) value1 = resp.registers[0] value2 = resp.registers[1] @@ -21,7 +23,7 @@ f.write(str(final)) f.close() -#soc +# soc resp= client.read_holding_registers(8,2,unit=1) value1 = resp.registers[0] value2 = resp.registers[1] @@ -30,7 +32,3 @@ f = open('/var/www/html/openWB/ramdisk/speichersoc', 'w') f.write(str(final)) f.close() - - - - diff --git a/modules/speicher_solaredge/main.sh b/modules/speicher_solaredge/main.sh index 8c85bc17a..c7a771cf0 100755 --- a/modules/speicher_solaredge/main.sh +++ b/modules/speicher_solaredge/main.sh @@ -1,7 +1,6 @@ #!/bin/bash if [[ $solaredgespeicherip == $solaredgepvip ]] ; then - echo "value read at pv modul" > /dev/null + echo "value read at pv modul" > /dev/null else - python /var/www/html/openWB/modules/speicher_solaredge/solaredge.py $solaredgespeicherip $solaredgezweiterspeicher + python /var/www/html/openWB/modules/speicher_solaredge/solaredge.py $solaredgespeicherip $solaredgezweiterspeicher fi - diff --git a/modules/speicher_solaredge/solaredge.py b/modules/speicher_solaredge/solaredge.py index ea58e29ea..d6363bb36 100755 --- a/modules/speicher_solaredge/solaredge.py +++ b/modules/speicher_solaredge/solaredge.py @@ -1,16 +1,18 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusTcpClient + ipaddress = str(sys.argv[1]) zweiterspeicher = int(sys.argv[2]) storage2power = 0 -from pymodbus.client.sync import ModbusTcpClient + client = ModbusTcpClient(ipaddress, port=502) rr = client.read_holding_registers(62836, 2, unit=1) @@ -25,7 +27,6 @@ f.write(str(final)) f.close() - rr = client.read_holding_registers(62852, 2, unit=1) raw = struct.pack('>HH', rr.getRegister(1), rr.getRegister(0)) soc = int(struct.unpack('>f', raw)[0]) @@ -39,7 +40,3 @@ f = open('/var/www/html/openWB/ramdisk/speichersoc', 'w') f.write(str(fsoc)) f.close() - - - - diff --git a/modules/speicher_solax/solax.py b/modules/speicher_solax/solax.py index 6aa4f590d..0a3ff4b81 100644 --- a/modules/speicher_solax/solax.py +++ b/modules/speicher_solax/solax.py @@ -1,12 +1,11 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import struct -import binascii - +# import os +# import time +# import getopt +# import socket +# import struct +# import binascii from pymodbus.client.sync import ModbusTcpClient def unsigned16(result, addr): @@ -19,19 +18,19 @@ def signed16(result, addr): return val ipaddress = str(sys.argv[1]) + client = ModbusTcpClient(ipaddress, port=502) resp=client.read_input_registers(0, 114) -value1 = signed16(resp, 22) #Batterie Power - -value2 = unsigned16(resp, 28 ) - +# Batterie Power +value1 = signed16(resp, 22) f = open('/var/www/html/openWB/ramdisk/speicherleistung', 'w') f.write(str(value1)) f.close() - -f = open('/var/www/html/openWB/ramdisk/speichersoc', 'w') #Batterieladezustand +# Batterieladezustand +value2 = unsigned16(resp, 28 ) +f = open('/var/www/html/openWB/ramdisk/speichersoc', 'w') f.write(str(value2)) f.close() diff --git a/modules/speicher_sonneneco/main.sh b/modules/speicher_sonneneco/main.sh index d983f96cf..63a38654a 100755 --- a/modules/speicher_sonneneco/main.sh +++ b/modules/speicher_sonneneco/main.sh @@ -1,6 +1,6 @@ #!/bin/bash -#Auslesen einer Sonnbenbatterie Eco 4.5 über die integrierte JSON-API des Batteriesystems +# Auslesen einer Sonnbenbatterie Eco 4.5 über die integrierte JSON-API des Batteriesystems ra='^-?[0-9]+$' if (( sonnenecoalternativ == 2 )); then speichersoc=$(curl --connect-timeout 5 -s "$sonnenecoip:7979/rest/devices/battery/M05") @@ -10,7 +10,7 @@ if (( sonnenecoalternativ == 2 )); then speicherladung=$(echo $speicherladung | sed 's/\..*$//') speicherentladung=$(echo $speicherentladung | sed 's/\..*$//') speicherwatt=$(echo "$speicherladung - $speicherentladung" | bc) - #wenn Batterie aus bzw. keine Antwort ersetze leeren Wert durch eine 0 + # wenn Batterie aus bzw. keine Antwort ersetze leeren Wert durch eine 0 if ! [[ $speicherwatt =~ $ra ]] ; then speicherwatt="0" fi @@ -26,27 +26,18 @@ if (( sonnenecoalternativ == 2 )); then else if (( sonnenecoalternativ == 0 )); then speicherantwort=$(curl --connect-timeout 5 -s "$sonnenecoip:7979/rest/devices/battery") - speichersoc=$(echo $speicherantwort | jq '.M05' | sed 's/\..*$//') - speicherentladung=$(echo $speicherantwort | jq '.M34' | sed 's/\..*$//') - speicherladung=$(echo $speicherantwort | jq '.M35' |sed 's/\..*$//') - speicherwatt=$(echo "$speicherladung - $speicherentladung" | bc) - - #wenn Batterie aus bzw. keine Antwort ersetze leeren Wert durch eine 0 - + # wenn Batterie aus bzw. keine Antwort ersetze leeren Wert durch eine 0 if ! [[ $speicherwatt =~ $ra ]] ; then - speicherwatt="0" + speicherwatt="0" fi - echo $speicherwatt > /var/www/html/openWB/ramdisk/speicherleistung - if ! [[ $speichersoc =~ $ra ]] ; then - speichersoc="0" + speichersoc="0" fi - echo $speichersoc > /var/www/html/openWB/ramdisk/speichersoc else speicherantwort=$(curl --connect-timeout 5 -s "$sonnenecoip/api/v1/status") @@ -56,13 +47,13 @@ else speicherpvwatt=$((speicherpvwatt * -1)) echo $speicherpvwatt > /var/www/html/openWB/ramdisk/pvwatt if ! [[ $speicherwatt =~ $ra ]] ; then - speicherwatt="0" - else - speicherwatt=$((speicherwatt * -1)) + speicherwatt="0" + else + speicherwatt=$((speicherwatt * -1)) fi echo $speicherwatt > /var/www/html/openWB/ramdisk/speicherleistung if ! [[ $speichersoc =~ $ra ]] ; then - speichersoc="0" + speichersoc="0" fi echo $speichersoc > /var/www/html/openWB/ramdisk/speichersoc fi diff --git a/modules/speicher_studer/studer_speicher.py b/modules/speicher_studer/studer_speicher.py index fc958ee7f..5d1cd3e67 100644 --- a/modules/speicher_studer/studer_speicher.py +++ b/modules/speicher_studer/studer_speicher.py @@ -1,16 +1,18 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser -import struct -import binascii +# import os +# import time +# import getopt +# import socket +# import ConfigParser +# import struct +# import binascii from pymodbus.constants import Endian from pymodbus.payload import BinaryPayloadDecoder -ipaddress = str(sys.argv[1]) from pymodbus.client.sync import ModbusTcpClient + +ipaddress = str(sys.argv[1]) + client = ModbusTcpClient(ipaddress, port=502) connection = client.connect() @@ -67,4 +69,3 @@ f.close() client.close() - diff --git a/modules/speicher_sungrow/sungrow.py b/modules/speicher_sungrow/sungrow.py index a7ef8a0fc..2e755801b 100644 --- a/modules/speicher_sungrow/sungrow.py +++ b/modules/speicher_sungrow/sungrow.py @@ -1,14 +1,16 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -ipaddress = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusTcpClient + +ipaddress = str(sys.argv[1]) + client = ModbusTcpClient(ipaddress, port=502) resp= client.read_input_registers(13022,1,unit=1) @@ -19,13 +21,11 @@ f.write(str(final)) f.close() - resp= client.read_input_registers(13000,1,unit=1) value1 = resp.registers[0] binary=bin(value1)[2:].zfill(8) - -#battwatt +# battwatt resp= client.read_input_registers(13021,1,unit=1) value1 = resp.registers[0] all = format(value1, '04x') @@ -35,7 +35,3 @@ f = open('/var/www/html/openWB/ramdisk/speicherleistung', 'w') f.write(str(final)) f.close() - - - - diff --git a/modules/speicher_sunnyisland/main.sh b/modules/speicher_sunnyisland/main.sh index e9d3643f9..0f9193488 100755 --- a/modules/speicher_sunnyisland/main.sh +++ b/modules/speicher_sunnyisland/main.sh @@ -1,5 +1,3 @@ #!/bin/bash - - sudo python /var/www/html/openWB/modules/speicher_sunnyisland/sunnyisland.py $sunnyislandip diff --git a/modules/speicher_sunnyisland/sbs25.py b/modules/speicher_sunnyisland/sbs25.py index 49baffe14..d2089d745 100755 --- a/modules/speicher_sunnyisland/sbs25.py +++ b/modules/speicher_sunnyisland/sbs25.py @@ -1,17 +1,19 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -ipaddress = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusTcpClient + +ipaddress = str(sys.argv[1]) + client = ModbusTcpClient(ipaddress, port=502) -#print "SoC batt" +# print "SoC batt" resp= client.read_holding_registers(30845,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] @@ -21,7 +23,7 @@ f.write(str(final)) f.close() -#print "be-entladen watt" +# print "be-entladen watt" resp= client.read_holding_registers(31393,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] @@ -39,6 +41,3 @@ f = open('/var/www/html/openWB/ramdisk/speicherleistung', 'w') f.write(str(final)) f.close() - - - diff --git a/modules/speicher_sunnyisland/sunnyisland.py b/modules/speicher_sunnyisland/sunnyisland.py index 56cb70cdd..4796a7a2e 100755 --- a/modules/speicher_sunnyisland/sunnyisland.py +++ b/modules/speicher_sunnyisland/sunnyisland.py @@ -1,17 +1,19 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -ipaddress = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusTcpClient + +ipaddress = str(sys.argv[1]) + client = ModbusTcpClient(ipaddress, port=502) -#print "SoC batt" +# print "SoC batt" resp= client.read_holding_registers(30845,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] @@ -21,7 +23,7 @@ f.write(str(final)) f.close() -#print "be-entladen watt" +# print "be-entladen watt" resp= client.read_holding_registers(30775,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] @@ -30,7 +32,8 @@ f = open('/var/www/html/openWB/ramdisk/speicherleistung', 'w') f.write(str(ladung)) f.close() -#print "import wh" + +# print "import wh" resp= client.read_holding_registers(30595,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] @@ -39,7 +42,8 @@ f = open('/var/www/html/openWB/ramdisk/speicherikwh', 'w') f.write(str(ladung)) f.close() -#print "exportwh" + +# print "exportwh" resp= client.read_holding_registers(30597,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] @@ -48,5 +52,3 @@ f = open('/var/www/html/openWB/ramdisk/speicherekwh', 'w') f.write(str(ladung)) f.close() - - diff --git a/modules/speicher_tesvoltsma/main.sh b/modules/speicher_tesvoltsma/main.sh index bc8348d56..4940faf2f 100644 --- a/modules/speicher_tesvoltsma/main.sh +++ b/modules/speicher_tesvoltsma/main.sh @@ -1,5 +1,3 @@ #!/bin/bash - sudo python /var/www/html/openWB/modules/speicher_tesvoltsma/tripower.py $speicher1_ip - diff --git a/modules/speicher_tesvoltsma/tripower.py b/modules/speicher_tesvoltsma/tripower.py index 2d798fdff..3b6fb7a50 100644 --- a/modules/speicher_tesvoltsma/tripower.py +++ b/modules/speicher_tesvoltsma/tripower.py @@ -1,17 +1,19 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -ipaddress = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusTcpClient + +ipaddress = str(sys.argv[1]) + client = ModbusTcpClient(ipaddress, port=502) -#print "SoC batt" +# print "SoC batt" resp= client.read_input_registers(1056,2,unit=25) value1 = resp.registers[0] value2 = resp.registers[1] @@ -20,7 +22,8 @@ f = open('/var/www/html/openWB/ramdisk/speichersoc', 'w') f.write(str(final)) f.close() -#print "be-entladen watt" + +# print "be-entladen watt" resp= client.read_input_registers(1012,2,unit=25) value1 = resp.registers[0] value2 = resp.registers[1] diff --git a/modules/speicher_varta/main.sh b/modules/speicher_varta/main.sh index f86dd9a73..a80c3a812 100755 --- a/modules/speicher_varta/main.sh +++ b/modules/speicher_varta/main.sh @@ -1,25 +1,21 @@ #!/bin/bash -#Auslesen eines Varta Speicher über die integrierte XML-API der Batteroe. +# Auslesen eines Varta Speicher über die integrierte XML-API der Batteroe. if [[ "$usevartamodbus" != "1" ]]; then - speicherwatt=$(curl --connect-timeout 5 -s "$vartaspeicherip/cgi/ems_data.xml" | grep 'P' | sed 's/.*value=//' |tr -d "'/>") - #wenn WR aus bzw. im standby (keine Antwort) ersetze leeren Wert durch eine 0 + # wenn WR aus bzw. im standby (keine Antwort) ersetze leeren Wert durch eine 0 ra='^-?[0-9]+$' if [[ $speicherwatt =~ $ra ]] ; then echo $speicherwatt > /var/www/html/openWB/ramdisk/speicherleistung fi speichersoc=$(curl --connect-timeout 5 -s "$vartaspeicherip/cgi/ems_data.xml" | grep 'SOC' | sed 's/.*value=//' |tr -d "'/>") - #if [[ $speichersoc -ge "101" ]]; then + # if [[ $speichersoc -ge "101" ]]; then speichersoc=$(echo "$speichersoc / 10" |bc) - #fi + # fi if [[ $speichersoc =~ $ra ]] ; then echo $speichersoc > /var/www/html/openWB/ramdisk/speichersoc fi else python /var/www/html/openWB/modules/speicher_varta/varta.py $vartaspeicherip fi - - - diff --git a/modules/speicher_varta/varta.py b/modules/speicher_varta/varta.py index 3c9dea0b5..7d11f794d 100644 --- a/modules/speicher_varta/varta.py +++ b/modules/speicher_varta/varta.py @@ -1,17 +1,19 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -ipaddress = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusTcpClient + +ipaddress = str(sys.argv[1]) + client = ModbusTcpClient(ipaddress, port=502) -#battsoc +# battsoc resp= client.read_holding_registers(1068,1,unit=1) value1 = resp.registers[0] all = format(value1, '04x') @@ -20,7 +22,8 @@ f = open('/var/www/html/openWB/ramdisk/speichersoc', 'w') f.write(str(final)) f.close() -#battleistung + +# battleistung resp= client.read_holding_registers(1066,1,unit=1) value1 = resp.registers[0] all = format(value1, '04x') @@ -28,4 +31,3 @@ f = open('/var/www/html/openWB/ramdisk/speicherleistung', 'w') f.write(str(final)) f.close() - diff --git a/modules/speicher_victron/main.sh b/modules/speicher_victron/main.sh index 8fe893372..7c645e974 100755 --- a/modules/speicher_victron/main.sh +++ b/modules/speicher_victron/main.sh @@ -1,10 +1,3 @@ #!/bin/bash - - sudo python /var/www/html/openWB/modules/speicher_victron/victron_speicher.py $bezug_victronip - - - - - diff --git a/modules/speicher_victron/victron_speicher.py b/modules/speicher_victron/victron_speicher.py index ae10ee0da..9d031b860 100644 --- a/modules/speicher_victron/victron_speicher.py +++ b/modules/speicher_victron/victron_speicher.py @@ -1,61 +1,61 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser -import struct -import binascii +# import os +# import time +# import getopt +# import socket +# import ConfigParser +# import struct +# import binascii from pymodbus.constants import Endian from pymodbus.payload import BinaryPayloadDecoder -ipaddress = str(sys.argv[1]) from pymodbus.client.sync import ModbusTcpClient + +ipaddress = str(sys.argv[1]) + client = ModbusTcpClient(ipaddress, port=502) connection = client.connect() +# Battery Voltage +# resp= client.read_holding_registers(840,1,unit=100) +# decoder = BinaryPayloadDecoder.fromRegisters(resp.registers,byteorder=Endian.Big,wordorder=Endian.Big) +# bv = str(decoder.decode_16bit_uint()) +# bv = float(bv) / 10 +# f = open('/var/www/html/openWB/ramdisk/???', 'w') +# f.write(str(watt)) +# f.close() +# print "Batteriespannung aktuell:" +# print bv -#Battery Voltage -#resp= client.read_holding_registers(840,1,unit=100) -#decoder = BinaryPayloadDecoder.fromRegisters(resp.registers,byteorder=Endian.Big,wordorder=Endian.Big) -#bv = str(decoder.decode_16bit_uint()) -#bv = float(bv) / 10 -#f = open('/var/www/html/openWB/ramdisk/???', 'w') -#f.write(str(watt)) -#f.close() -#print "Batteriespannung aktuell:" -#print bv - -#Battery ampere -#resp= client.read_holding_registers(841,1,unit=100) -#decoder = BinaryPayloadDecoder.fromRegisters(resp.registers,byteorder=Endian.Big,wordorder=Endian.Big) -#ba = str(decoder.decode_16bit_int()) -#ba = float(ba) / 10 -#f = open('/var/www/html/openWB/ramdisk/???', 'w') -#f.write(str(a3)) -#f.close() -#print "Batterie Ampere +/- aktuell:" -#print ba +# Battery ampere +# resp= client.read_holding_registers(841,1,unit=100) +# decoder = BinaryPayloadDecoder.fromRegisters(resp.registers,byteorder=Endian.Big,wordorder=Endian.Big) +# ba = str(decoder.decode_16bit_int()) +# ba = float(ba) / 10 +# f = open('/var/www/html/openWB/ramdisk/???', 'w') +# f.write(str(a3)) +# f.close() +# print "Batterie Ampere +/- aktuell:" +# print ba -#Battery watt +# Battery watt resp= client.read_holding_registers(842,1,unit=100) decoder = BinaryPayloadDecoder.fromRegisters(resp.registers,byteorder=Endian.Big,wordorder=Endian.Big) bw = str(decoder.decode_16bit_int()) f = open('/var/www/html/openWB/ramdisk/speicherleistung', 'w') f.write(str(bw)) f.close() -#print "Batterie Wirkleistung +/- aktuell:" -#print bw +# print "Batterie Wirkleistung +/- aktuell:" +# print bw -#Battery SOC +# Battery SOC resp= client.read_holding_registers(843,1,unit=100) decoder = BinaryPayloadDecoder.fromRegisters(resp.registers,byteorder=Endian.Big,wordorder=Endian.Big) bs = str(decoder.decode_16bit_uint()) f = open('/var/www/html/openWB/ramdisk/speichersoc', 'w') f.write(str(bs)) f.close() -#print "Batterie SOC aktuell:" -#print bs +# print "Batterie SOC aktuell:" +# print bs client.close() - diff --git a/modules/twcmanagerlp1/main.sh b/modules/twcmanagerlp1/main.sh index dc5b283b3..b16f6b284 100755 --- a/modules/twcmanagerlp1/main.sh +++ b/modules/twcmanagerlp1/main.sh @@ -19,9 +19,5 @@ if (( twcmanagerlp1phasen == 3 )); then echo $amps > /var/www/html/openWB/ramdisk/lla1 echo $amps > /var/www/html/openWB/ramdisk/lla2 echo $amps > /var/www/html/openWB/ramdisk/lla3 - fi echo $watt > /var/www/html/openWB/ramdisk/llaktuell - - - diff --git a/modules/verbraucher/abb-b23remote.py b/modules/verbraucher/abb-b23remote.py index 32c99ab45..90bf2f8bb 100755 --- a/modules/verbraucher/abb-b23remote.py +++ b/modules/verbraucher/abb-b23remote.py @@ -1,21 +1,21 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser -import struct -import binascii +# import os +# import time +# import getopt +# import socket +# import ConfigParser +# import struct +# import binascii import ctypes +from pymodbus.client.sync import ModbusTcpClient as ModbusClient +from pymodbus.transaction import ModbusRtuFramer #Args in var schreiben verbrauchernr = str(sys.argv[1]) seradd = str(sys.argv[2]) ABBid = int(sys.argv[3]) -from pymodbus.client.sync import ModbusTcpClient as ModbusClient -from pymodbus.transaction import ModbusRtuFramer client = ModbusClient(seradd, port=502, framer=ModbusRtuFramer) response = client.read_holding_registers(address=0x5B00, count=28, unit=ABBid) diff --git a/modules/verbraucher/mpm3pmlocal.py b/modules/verbraucher/mpm3pmlocal.py index d81a4da40..113fcfea9 100755 --- a/modules/verbraucher/mpm3pmlocal.py +++ b/modules/verbraucher/mpm3pmlocal.py @@ -1,18 +1,17 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -verbrauchernr = str(sys.argv[1]) -seradd = str(sys.argv[2]) +# import binascii from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) +verbrauchernr = str(sys.argv[1]) +seradd = str(sys.argv[2]) +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) sdmid = int(sys.argv[3]) @@ -37,7 +36,6 @@ f.write(str(ekwh)) f.close() - resp = client.read_input_registers(0x26,2, unit=sdmid) value1 = resp.registers[0] value2 = resp.registers[1] @@ -47,4 +45,3 @@ f = open(wstring, 'w') f.write(str(final)) f.close() - diff --git a/modules/verbraucher/mpm3pmremote.py b/modules/verbraucher/mpm3pmremote.py index c1101c382..373dc644c 100755 --- a/modules/verbraucher/mpm3pmremote.py +++ b/modules/verbraucher/mpm3pmremote.py @@ -1,17 +1,18 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusTcpClient + verbrauchernr = str(sys.argv[1]) seradd = str(sys.argv[2]) -from pymodbus.client.sync import ModbusTcpClient -client = ModbusTcpClient(seradd, port=8899) +client = ModbusTcpClient(seradd, port=8899) sdmid = int(sys.argv[3]) if ( sdmid < 100 ): @@ -47,7 +48,6 @@ f.write(str(final)) f.close() - resp = client.read_input_registers(0x0E,2, unit=sdmid) lla1 = resp.registers[1] lla1 = float(lla1) / 100 @@ -72,7 +72,7 @@ else: resp = client.read_input_registers(0x0156,2, unit=sdmid) ikwh = struct.unpack('>f',struct.pack('>HH',*resp.registers))[0] - ikwh = float("%.3f" % llkwh) + ikwh = float("%.3f" % ikwh) ikwh = float(ikwh) * 1000 whstring = "/var/www/html/openWB/ramdisk/verbraucher%s_wh" % (verbrauchernr) f = open(whstring, 'w') @@ -92,5 +92,3 @@ f = open(wstring, 'w') f.write(str(llg)) f.close() - - diff --git a/modules/verbraucher/sdm120local.py b/modules/verbraucher/sdm120local.py index 3906be53f..3525c50e5 100755 --- a/modules/verbraucher/sdm120local.py +++ b/modules/verbraucher/sdm120local.py @@ -1,22 +1,20 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusSerialClient + #Args in var schreiben verbrauchernr = str(sys.argv[1]) seradd = str(sys.argv[2]) sdmid = int(sys.argv[3]) -from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) - - +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) resp = client.read_input_registers(0x0006,2, unit=sdmid) al1 = struct.unpack('>f',struct.pack('>HH',*resp.registers)) @@ -35,7 +33,6 @@ f.write(str(watt)) f.close() - resp = client.read_input_registers(0x0048,2, unit=sdmid) vwh = struct.unpack('>f',struct.pack('>HH',*resp.registers)) vwh2 = float("%.3f" % vwh[0]) * int(1000) @@ -45,7 +42,6 @@ f.write(str(vwh3)) f.close() - resp = client.read_input_registers(0x004a,2, unit=sdmid) vwhe = struct.unpack('>f',struct.pack('>HH',*resp.registers)) vwhe2 = float("%.3f" % vwhe[0]) * int(1000) diff --git a/modules/verbraucher/sdm120remote.py b/modules/verbraucher/sdm120remote.py index 3fa7fa053..b585bfb92 100755 --- a/modules/verbraucher/sdm120remote.py +++ b/modules/verbraucher/sdm120remote.py @@ -1,20 +1,20 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -verbrauchernr = str(sys.argv[1]) -seradd = str(sys.argv[2]) +# import binascii from pymodbus.client.sync import ModbusTcpClient -client = ModbusTcpClient(seradd, port=8899) - +verbrauchernr = str(sys.argv[1]) +seradd = str(sys.argv[2]) sdmid = int(sys.argv[3]) +client = ModbusTcpClient(seradd, port=8899) + resp = client.read_input_registers(0x0006,2, unit=sdmid) al1 = struct.unpack('>f',struct.pack('>HH',*resp.registers)) al1 = float("%.3f" % al1[0]) @@ -32,7 +32,6 @@ f.write(str(watt)) f.close() - resp = client.read_input_registers(0x0048,2, unit=sdmid) vwh = struct.unpack('>f',struct.pack('>HH',*resp.registers)) vwh2 = float("%.3f" % vwh[0]) * int(1000) @@ -42,7 +41,6 @@ f.write(str(vwh3)) f.close() - resp = client.read_input_registers(0x004a,2, unit=sdmid) vwhe = struct.unpack('>f',struct.pack('>HH',*resp.registers)) vwhe2 = float("%.3f" % vwhe[0]) * int(1000) @@ -52,7 +50,3 @@ f = open(vwhestring, 'w') f.write(str(vwhe3)) f.close() - - - - diff --git a/modules/verbraucher/sdm630local.py b/modules/verbraucher/sdm630local.py index a645569dc..650b0c6a6 100644 --- a/modules/verbraucher/sdm630local.py +++ b/modules/verbraucher/sdm630local.py @@ -1,20 +1,20 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusSerialClient + #Args in var schreiben verbrauchernr = str(sys.argv[1]) seradd = str(sys.argv[2]) sdmid = int(sys.argv[3]) -from pymodbus.client.sync import ModbusSerialClient -client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, - stopbits=1, bytesize=8, timeout=1) +client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, stopbits=1, bytesize=8, timeout=1) #Phase 1 A resp = client.read_input_registers(0x06,2, unit=sdmid) @@ -124,4 +124,4 @@ wattstring = "/var/www/html/openWB/ramdisk/verbraucher%s_watt" % (verbrauchernr) f = open(wattstring, 'w') f.write(str(watt)) -f.close() \ No newline at end of file +f.close() diff --git a/modules/verbraucher/sdm630remote.py b/modules/verbraucher/sdm630remote.py index f1268a981..0e4a61894 100755 --- a/modules/verbraucher/sdm630remote.py +++ b/modules/verbraucher/sdm630remote.py @@ -1,18 +1,19 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusTcpClient + #Args in var schreiben verbrauchernr = str(sys.argv[1]) seradd = str(sys.argv[2]) sdmid = int(sys.argv[3]) -from pymodbus.client.sync import ModbusTcpClient client = ModbusTcpClient(seradd, port=8899) #Phase 1 A @@ -68,6 +69,7 @@ f = open(vl3string, 'w') f.write(str(vl3)) f.close() + #KWH Total Import resp = client.read_input_registers(0x0156,2, unit=sdmid) vwh = struct.unpack('>f',struct.pack('>HH',*resp.registers)) diff --git a/modules/vzlogger/main.sh b/modules/vzlogger/main.sh index f07a25454..e83f60616 100755 --- a/modules/vzlogger/main.sh +++ b/modules/vzlogger/main.sh @@ -5,7 +5,6 @@ #Mithilfe von sed wird die die gewünschte Zeile ausgewählt #tr entfernt unnötige leerzeilen - watttmp=$(curl --connect-timeout 15 -s $vzloggerip) watt=$(echo $watttmp | jq . | sed ''$vzloggerline'!d' | tr -d ' ' ) watt=$(echo "${watt}" | cut -f1 -d".") diff --git a/modules/vzloggerpv/main.sh b/modules/vzloggerpv/main.sh index 9ede602e7..fb36f47af 100755 --- a/modules/vzloggerpv/main.sh +++ b/modules/vzloggerpv/main.sh @@ -5,7 +5,6 @@ #Mithilfe von sed wird die die gewünschte Zeile ausgewählt #tr entfernt unnötige leerzeilen - watttmp=$(curl --connect-timeout 15 -s $vzloggerpvip) watt=$(echo $watttmp | jq . | sed ''$vzloggerpvline'!d' | tr -d ' ' ) watt=$(echo "${watt}" | cut -f1 -d".") @@ -15,4 +14,3 @@ fi echo $watt #zur weiteren verwendung im webinterface echo $watt > /var/www/html/openWB/ramdisk/pvwatt - diff --git a/modules/wr2_ethlovato/main.sh b/modules/wr2_ethlovato/main.sh index af97749aa..242c159d2 100755 --- a/modules/wr2_ethlovato/main.sh +++ b/modules/wr2_ethlovato/main.sh @@ -8,5 +8,3 @@ fi pv2watt=$(i', all.decode('hex'))[0]) @@ -22,16 +19,14 @@ finalbezug=finalbezug1 else: finalbezug=finalbezug2 - f = open('/var/www/html/openWB/ramdisk/pv2kwh', 'w') f.write(str(finalbezug)) f.close() -#phasen watt +# phasen watt resp = client.read_input_registers(0x0013,2, unit=0x08) all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') finalw1 = int(struct.unpack('>i', all.decode('hex'))[0] / 100) - resp = client.read_input_registers(0x0015,2, unit=0x08) all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') finalw2 = int(struct.unpack('>i', all.decode('hex'))[0] / 100) @@ -42,15 +37,15 @@ finalw= finalw1 + finalw2 + finalw3 if ( finalw > 10): finalw=finalw*-1 -#total watt -#resp = client.read_input_registers(0x0039,2, unit=0x08) -#all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') -#finalw = int(struct.unpack('>i', all.decode('hex'))[0] / 100) +# total watt +# resp = client.read_input_registers(0x0039,2, unit=0x08) +# all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') +# finalw = int(struct.unpack('>i', all.decode('hex'))[0] / 100) f = open('/var/www/html/openWB/ramdisk/pv2watt', 'w') f.write(str(finalw)) f.close() -#ampere l1 +# ampere l1 resp = client.read_input_registers(0x0007, 2, unit=0x08) all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') lla1 = float(struct.unpack('>i', all.decode('hex'))[0]) / 10000 @@ -58,7 +53,7 @@ f.write(str(lla1)) f.close() -#ampere l2 +# ampere l2 resp = client.read_input_registers(0x0009, 2, unit=0x08) all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') lla2 = float(struct.unpack('>i', all.decode('hex'))[0]) / 10000 @@ -66,13 +61,10 @@ f.write(str(lla2)) f.close() -#ampere l3 +# ampere l3 resp = client.read_input_registers(0x000b, 2, unit=0x08) all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') lla3 = float(struct.unpack('>i', all.decode('hex'))[0]) / 10000 f = open('/var/www/html/openWB/ramdisk/pv2a3', 'w') f.write(str(lla3)) f.close() - - - diff --git a/modules/wr2_ethlovato/readmpm3pm.py b/modules/wr2_ethlovato/readmpm3pm.py index 731daa6bb..37efed290 100755 --- a/modules/wr2_ethlovato/readmpm3pm.py +++ b/modules/wr2_ethlovato/readmpm3pm.py @@ -1,27 +1,21 @@ #!/usr/bin/python -import sys -import os -import time -import getopt +# 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) - - - +client = ModbusTcpClient('192.168.193.15', port=8899) -###### 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] +# 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)) @@ -57,7 +51,7 @@ f.write(str(lla3)) f.close() -#total watt +# total watt resp = client.read_input_registers(0x26,2, unit=8) value1 = resp.registers[0] value2 = resp.registers[1] @@ -66,5 +60,3 @@ f = open('/var/www/html/openWB/ramdisk/pvwatt', 'w') f.write(str(final)) f.close() - - diff --git a/modules/wr2_ethlovato/readsdm.py b/modules/wr2_ethlovato/readsdm.py index 01611a4ee..35ceb8c43 100755 --- a/modules/wr2_ethlovato/readsdm.py +++ b/modules/wr2_ethlovato/readsdm.py @@ -1,17 +1,15 @@ #!/usr/bin/python -import sys -import os -import time -import getopt +# import sys +# import os +# import time +# import getopt import struct from pymodbus.client.sync import ModbusTcpClient + client = ModbusTcpClient('192.168.193.13', port=8899) sdmid = 116 - - - -#phasen watt +# phasen watt resp = client.read_input_registers(0x0C,2, unit=sdmid) llw1 = struct.unpack('>f',struct.pack('>HH',*resp.registers))[0] finalw1 = int(llw1) @@ -25,14 +23,11 @@ finalw= finalw1 + finalw2 + finalw3 if ( finalw > 10): finalw=finalw*-1 - - f = open('/var/www/html/openWB/ramdisk/pv2watt', 'w') f.write(str(finalw)) f.close() - -#ampere l1 +# ampere l1 resp = client.read_input_registers(0x06,2, unit=sdmid) lla1 = float(struct.unpack('>f',struct.pack('>HH',*resp.registers))[0]) lla1 = float("%.1f" % lla1) @@ -40,7 +35,7 @@ f.write(str(lla1)) f.close() -#ampere l2 +# ampere l2 resp = client.read_input_registers(0x08,2, unit=sdmid) lla1 = float(struct.unpack('>f',struct.pack('>HH',*resp.registers))[0]) lla2 = float("%.1f" % lla1) @@ -48,7 +43,7 @@ f.write(str(lla2)) f.close() -#ampere l3 +# ampere l3 resp = client.read_input_registers(0x0A,2, unit=sdmid) lla1 = float(struct.unpack('>f',struct.pack('>HH',*resp.registers))[0]) lla3 = float("%.1f" % lla1) @@ -56,12 +51,9 @@ f.write(str(lla3)) f.close() - resp = client.read_input_registers(0x0156,2, unit=sdmid) pvkwh = struct.unpack('>f',struct.pack('>HH',*resp.registers))[0] pvkwh = int(pvkwh * 1000) f = open('/var/www/html/openWB/ramdisk/pv2kwh', 'w') f.write(str(pvkwh)) f.close() - - diff --git a/modules/wr2_ethlovatoaevu/main.sh b/modules/wr2_ethlovatoaevu/main.sh index 232a7e54a..788ad1d7c 100755 --- a/modules/wr2_ethlovatoaevu/main.sh +++ b/modules/wr2_ethlovatoaevu/main.sh @@ -6,8 +6,5 @@ else python /var/www/html/openWB/modules/wr2_ethlovatoaevu/readlovato.py fi - pvwatt2=$(i', all.decode('hex'))[0]) @@ -19,11 +16,10 @@ f.write(str(finalbezug)) f.close() -#phasen watt +# phasen watt resp = client.read_input_registers(0x0013,2, unit=0x08) all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') finalw1 = int(struct.unpack('>i', all.decode('hex'))[0] / 100) - resp = client.read_input_registers(0x0015,2, unit=0x08) all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') finalw2 = int(struct.unpack('>i', all.decode('hex'))[0] / 100) @@ -34,15 +30,15 @@ finalw= finalw1 + finalw2 + finalw3 if ( finalw > 10): finalw=finalw*-1 -#total watt -#resp = client.read_input_registers(0x0039,2, unit=0x08) -#all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') -#finalw = int(struct.unpack('>i', all.decode('hex'))[0] / 100) +# total watt +# resp = client.read_input_registers(0x0039,2, unit=0x08) +# all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') +# finalw = int(struct.unpack('>i', all.decode('hex'))[0] / 100) f = open('/var/www/html/openWB/ramdisk/pv2watt', 'w') f.write(str(finalw)) f.close() -#ampere l1 +# ampere l1 resp = client.read_input_registers(0x0007, 2, unit=0x08) all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') lla1 = float(struct.unpack('>i', all.decode('hex'))[0]) / 10000 @@ -50,7 +46,7 @@ f.write(str(lla1)) f.close() -#ampere l2 +# ampere l2 resp = client.read_input_registers(0x0009, 2, unit=0x08) all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') lla2 = float(struct.unpack('>i', all.decode('hex'))[0]) / 10000 @@ -58,13 +54,10 @@ f.write(str(lla2)) f.close() -#ampere l3 +# ampere l3 resp = client.read_input_registers(0x000b, 2, unit=0x08) all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') lla3 = float(struct.unpack('>i', all.decode('hex'))[0]) / 10000 f = open('/var/www/html/openWB/ramdisk/pv2a3', 'w') f.write(str(lla3)) f.close() - - - diff --git a/modules/wr2_ethlovatoaevu/readmpm3pm.py b/modules/wr2_ethlovatoaevu/readmpm3pm.py index 731daa6bb..37efed290 100755 --- a/modules/wr2_ethlovatoaevu/readmpm3pm.py +++ b/modules/wr2_ethlovatoaevu/readmpm3pm.py @@ -1,27 +1,21 @@ #!/usr/bin/python -import sys -import os -import time -import getopt +# 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) - - - +client = ModbusTcpClient('192.168.193.15', port=8899) -###### 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] +# 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)) @@ -57,7 +51,7 @@ f.write(str(lla3)) f.close() -#total watt +# total watt resp = client.read_input_registers(0x26,2, unit=8) value1 = resp.registers[0] value2 = resp.registers[1] @@ -66,5 +60,3 @@ f = open('/var/www/html/openWB/ramdisk/pvwatt', 'w') f.write(str(final)) f.close() - - diff --git a/modules/wr2_ethlovatoaevu/readsdm.py b/modules/wr2_ethlovatoaevu/readsdm.py index 53d3d8c5c..332ee380a 100755 --- a/modules/wr2_ethlovatoaevu/readsdm.py +++ b/modules/wr2_ethlovatoaevu/readsdm.py @@ -1,17 +1,15 @@ #!/usr/bin/python -import sys -import os -import time -import getopt +# import sys +# import os +# import time +# import getopt import struct from pymodbus.client.sync import ModbusTcpClient + client = ModbusTcpClient('192.168.193.15', port=8899) sdmid = 116 - - - -#phasen watt +# phasen watt resp = client.read_input_registers(0x0C,2, unit=sdmid) llw1 = struct.unpack('>f',struct.pack('>HH',*resp.registers))[0] finalw1 = int(llw1) @@ -25,14 +23,11 @@ finalw= finalw1 + finalw2 + finalw3 if ( finalw > 10): finalw=finalw*-1 - - f = open('/var/www/html/openWB/ramdisk/pv2watt', 'w') f.write(str(finalw)) f.close() - -#ampere l1 +# ampere l1 resp = client.read_input_registers(0x06,2, unit=sdmid) lla1 = float(struct.unpack('>f',struct.pack('>HH',*resp.registers))[0]) lla1 = float("%.1f" % lla1) @@ -40,7 +35,7 @@ f.write(str(lla1)) f.close() -#ampere l2 +# ampere l2 resp = client.read_input_registers(0x08,2, unit=sdmid) lla1 = float(struct.unpack('>f',struct.pack('>HH',*resp.registers))[0]) lla2 = float("%.1f" % lla1) @@ -48,7 +43,7 @@ f.write(str(lla2)) f.close() -#ampere l3 +# ampere l3 resp = client.read_input_registers(0x0A,2, unit=sdmid) lla1 = float(struct.unpack('>f',struct.pack('>HH',*resp.registers))[0]) lla3 = float("%.1f" % lla1) @@ -56,12 +51,9 @@ f.write(str(lla3)) f.close() - resp = client.read_input_registers(0x0156,2, unit=sdmid) pvkwh = struct.unpack('>f',struct.pack('>HH',*resp.registers))[0] pvkwh = int(pvkwh * 1000) f = open('/var/www/html/openWB/ramdisk/pv2kwh', 'w') f.write(str(pvkwh)) f.close() - - diff --git a/modules/wr2_ethsdm120/main.sh b/modules/wr2_ethsdm120/main.sh index 879d2fd7e..efd53d5d1 100755 --- a/modules/wr2_ethsdm120/main.sh +++ b/modules/wr2_ethsdm120/main.sh @@ -3,5 +3,3 @@ sudo python /var/www/html/openWB/modules/wr2_ethsdm120/readsdm120.py $pv2ip $pv2id $pv2ip2 $pv2id2 pvwatt=$(f',struct.pack('>HH',*resp.registers)) watt1 = int(watt[0]) - - resp = client.read_input_registers(0x004a,2, unit=sdmid) vwh = struct.unpack('>f',struct.pack('>HH',*resp.registers)) vwh1 = float("%.3f" % vwh[0]) @@ -35,7 +33,6 @@ v1wh = struct.unpack('>f',struct.pack('>HH',*resp.registers)) v1wh1 = float("%.3f" % v1wh[0]) - try: if sdm2id > 0: resp = client2.read_input_registers(0x000C,2, unit=sdm2id) @@ -53,14 +50,12 @@ vwh2=0 v1wh2=0 - except: watt2=0 vwh2=0 v1wh2=0 pass - watt=watt1+watt2 if watt > 0: watt=watt*-1 @@ -68,7 +63,6 @@ f.write(str(watt)) f.close() - if vwh1 > v1wh1: final1wh=vwh1 else: diff --git a/modules/wr2_kostalpiko/main.sh b/modules/wr2_kostalpiko/main.sh index dc07f2f34..dd168ad93 100644 --- a/modules/wr2_kostalpiko/main.sh +++ b/modules/wr2_kostalpiko/main.sh @@ -1,13 +1,13 @@ #!/bin/bash -#Auslesen eines Kostal Piko WR über die integrierte API des WR. Rückgabewert ist die aktuelle Wattleistung. +# Auslesen eines Kostal Piko WR über die integrierte API des WR. Rückgabewert ist die aktuelle Wattleistung. if [[ "$speichermodul" != "none" ]]; then pvwatttmp=$(curl --connect-timeout 5 -s $pv2ip/api/dxs.json?dxsEntries=33556736'&'dxsEntries=251658753) else pvwatttmp=$(curl --connect-timeout 5 -s $pv2ip/api/dxs.json?dxsEntries=67109120'&'dxsEntries=251658753) fi -#aktuelle Ausgangsleistung am WR [W] +# aktuelle Ausgangsleistung am WR [W] pvwatt=$(echo $pvwatttmp | jq '.dxsEntries[0].value' | sed 's/\..*$//') if [ $pvwatt > 5 ] @@ -16,11 +16,11 @@ if [ $pvwatt > 5 ] fi echo $pvwatt -#zur weiteren verwendung im webinterface +# zur weiteren verwendung im webinterface echo $pvwatt > /var/www/html/openWB/ramdisk/pv2watt -#Gesamtzählerstand am WR [kWh] -#pvkwh=$(echo $pvwatttmp | jq '.dxsEntries[1].value' | sed 's/\..*$//') -#echo $pvkwh > /var/www/html/openWB/ramdisk/pvkwhk -#pvkwh=$(echo "$pvkwh*1000" |bc) -#zur weiteren verwendung im webinterface -#echo $pvkwh > /var/www/html/openWB/ramdisk/pvkwh +# Gesamtzählerstand am WR [kWh] +# pvkwh=$(echo $pvwatttmp | jq '.dxsEntries[1].value' | sed 's/\..*$//') +# echo $pvkwh > /var/www/html/openWB/ramdisk/pvkwhk +# pvkwh=$(echo "$pvkwh*1000" |bc) +# zur weiteren verwendung im webinterface +# echo $pvkwh > /var/www/html/openWB/ramdisk/pvkwh diff --git a/modules/wr2_kostalpikovar2/main.sh b/modules/wr2_kostalpikovar2/main.sh index da07acede..efbb5f0d7 100755 --- a/modules/wr2_kostalpikovar2/main.sh +++ b/modules/wr2_kostalpikovar2/main.sh @@ -4,39 +4,38 @@ # based on Homematic Script v0.2 (c) 2018 by Alchy -#Daten einlesen +# Daten einlesen HTML=$(/usr/bin/curl -u $wr2_piko2_user:$wr2_piko2_pass --connect-timeout 10 -s -k $wr2_piko2_url | /usr/bin/tr -d '\r' | /usr/bin/tr -d '\n' | /usr/bin/tr -d ' ' | /usr/bin/tr '#' ' ') # request html, concat to one line, remove spaces, add spaces before color changes (#) if [[ -n $HTML ]] # check if valid content of request then - counter=0 - for LINE in $HTML # parse all html lines - do - if [[ $LINE =~ FFFFFF ]]; # search for white background color - then - ((counter++)) - PART2=${LINE##*F\">} # strip before number - VALUE=${PART2%%<*} # strip after number + counter=0 + for LINE in $HTML # parse all html lines + do + if [[ $LINE =~ FFFFFF ]]; # search for white background color + then + ((counter++)) + PART2=${LINE##*F\">} # strip before number + VALUE=${PART2%%<*} # strip after number - if [[ $counter -eq 1 ]] # pvwatt - then - if [[ $VALUE = "xxx" ]] # off-value equals zero - then - $VALUE = "0" - fi - re='^[-+]?[0-9]+\.?[0-9]*$' - if ! [[ $VALUE =~ $re ]] # check for valid number - then - VALUE=$( /var/www/html/openWB/ramdisk/pv2watt - echo $((VALUE*-1)) - elif [[ $counter -eq 2 ]] # pvkwhk - then - echo ${VALUE} > /var/www/html/openWB/ramdisk/pv2kwhk - fi - fi - done + if [[ $counter -eq 1 ]] # pvwatt + then + if [[ $VALUE = "xxx" ]] # off-value equals zero + then + $VALUE = "0" + fi + re='^[-+]?[0-9]+\.?[0-9]*$' + if ! [[ $VALUE =~ $re ]] # check for valid number + then + VALUE=$( /var/www/html/openWB/ramdisk/pv2watt + echo $((VALUE*-1)) + elif [[ $counter -eq 2 ]] # pvkwhk + then + echo ${VALUE} > /var/www/html/openWB/ramdisk/pv2kwhk + fi + fi + done fi - diff --git a/modules/wr2_kostalsteca/main.sh b/modules/wr2_kostalsteca/main.sh index 6a2b9d0a0..d9645b1b6 100644 --- a/modules/wr2_kostalsteca/main.sh +++ b/modules/wr2_kostalsteca/main.sh @@ -9,7 +9,6 @@ DMOD="PV" Debug=$debug - if (( $Debug > 1 )); then measure=$(curl --connect-timeout 5 -s $pv2ip/measurements.xml) openwbDebugLog ${DMOD} 2 "MEASURE: $measure" diff --git a/modules/wr2_smamodbus/main.sh b/modules/wr2_smamodbus/main.sh index 4db5ceb2f..85acb257d 100755 --- a/modules/wr2_smamodbus/main.sh +++ b/modules/wr2_smamodbus/main.sh @@ -2,11 +2,5 @@ sudo python /var/www/html/openWB/modules/wr2_smamodbus/sma.py $pv2ip - pv2watt=$(h', watt.decode('hex'))[0]) * -1 -#read multiplier +# read multiplier multiplier=format(resp.registers[1], '04x') fmultiplier=int(struct.unpack('>h', multiplier.decode('hex'))[0]) if fmultiplier == 2: @@ -40,9 +42,6 @@ f.write(str(fwr1watt)) f.close() - - - resp= client.read_holding_registers(40093,2,unit=slave1id) value1 = resp.registers[0] value2 = resp.registers[1] @@ -55,7 +54,3 @@ f = open('/var/www/html/openWB/ramdisk/pv2kwhk', 'w') f.write(str(pvkwhk)) f.close() - - - - diff --git a/modules/wr2_solax/solax.py b/modules/wr2_solax/solax.py index 7aa9e437a..d4c7b645d 100644 --- a/modules/wr2_solax/solax.py +++ b/modules/wr2_solax/solax.py @@ -1,16 +1,16 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import struct -import binascii - - +# import os +# import time +# import getopt +# import socket +# import struct +# import binascii from pymodbus.client.sync import ModbusTcpClient from pymodbus.factory import ClientDecoder +ipaddress = str(sys.argv[1]) + def unsigned32(result, addr): low = result.registers[addr] high = result.registers[addr + 1] @@ -26,10 +26,8 @@ def signed16(result, addr): val -= 65535 return val -ipaddress = str(sys.argv[1]) client = ModbusTcpClient(ipaddress, port=502) - resp=client.read_input_registers(10, 2) pv1 = unsigned16(resp, 0) pv2 = unsigned16(resp, 1) diff --git a/modules/wr2_victron/main.sh b/modules/wr2_victron/main.sh index 4076320e7..0c76ee06e 100755 --- a/modules/wr2_victron/main.sh +++ b/modules/wr2_victron/main.sh @@ -1,8 +1,4 @@ #!/bin/bash -# - - - python /var/www/html/openWB/modules/wr2_victron/victron.py $pv2ip $pv2id pv2watt=$( /var/www/html/openWB/ramdisk/pvwatt - echo $watt - diff --git a/modules/wr_ethmpm3pmaevu/main.sh b/modules/wr_ethmpm3pmaevu/main.sh index 808ef209c..83526ca75 100755 --- a/modules/wr_ethmpm3pmaevu/main.sh +++ b/modules/wr_ethmpm3pmaevu/main.sh @@ -8,5 +8,3 @@ else fi pvwatt=$(i', all.decode('hex'))[0]) @@ -26,7 +23,7 @@ f.write(str(finalbezug)) f.close() -#phasen watt +# phasen watt resp = client.read_input_registers(0x0013,2, unit=0x08) all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') finalw1 = int(struct.unpack('>i', all.decode('hex'))[0] / 100) @@ -42,15 +39,15 @@ if ( finalw > 10): finalw=finalw*-1 -#total watt -#resp = client.read_input_registers(0x0039,2, unit=0x08) -#all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') -#finalw = int(struct.unpack('>i', all.decode('hex'))[0] / 100) +# total watt +# resp = client.read_input_registers(0x0039,2, unit=0x08) +# all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') +# finalw = int(struct.unpack('>i', all.decode('hex'))[0] / 100) f = open('/var/www/html/openWB/ramdisk/pvwatt', 'w') f.write(str(finalw)) f.close() -#ampere l1 +# ampere l1 resp = client.read_input_registers(0x0007, 2, unit=0x08) all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') lla1 = float(struct.unpack('>i', all.decode('hex'))[0]) / 10000 @@ -58,7 +55,7 @@ f.write(str(lla1)) f.close() -#ampere l2 +# ampere l2 resp = client.read_input_registers(0x0009, 2, unit=0x08) all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') lla2 = float(struct.unpack('>i', all.decode('hex'))[0]) / 10000 @@ -66,13 +63,10 @@ f.write(str(lla2)) f.close() -#ampere l3 +# ampere l3 resp = client.read_input_registers(0x000b, 2, unit=0x08) all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') lla3 = float(struct.unpack('>i', all.decode('hex'))[0]) / 10000 f = open('/var/www/html/openWB/ramdisk/pva3', 'w') f.write(str(lla3)) f.close() - - - diff --git a/modules/wr_ethmpm3pmaevu/readmpm3pm.py b/modules/wr_ethmpm3pmaevu/readmpm3pm.py index 731daa6bb..37efed290 100755 --- a/modules/wr_ethmpm3pmaevu/readmpm3pm.py +++ b/modules/wr_ethmpm3pmaevu/readmpm3pm.py @@ -1,27 +1,21 @@ #!/usr/bin/python -import sys -import os -import time -import getopt +# 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) - - - +client = ModbusTcpClient('192.168.193.15', port=8899) -###### 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] +# 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)) @@ -57,7 +51,7 @@ f.write(str(lla3)) f.close() -#total watt +# total watt resp = client.read_input_registers(0x26,2, unit=8) value1 = resp.registers[0] value2 = resp.registers[1] @@ -66,5 +60,3 @@ f = open('/var/www/html/openWB/ramdisk/pvwatt', 'w') f.write(str(final)) f.close() - - diff --git a/modules/wr_ethmpm3pmaevu/readsdm.py b/modules/wr_ethmpm3pmaevu/readsdm.py index 61bb6afee..58a02ecbd 100755 --- a/modules/wr_ethmpm3pmaevu/readsdm.py +++ b/modules/wr_ethmpm3pmaevu/readsdm.py @@ -1,17 +1,15 @@ #!/usr/bin/python -import sys -import os -import time -import getopt +# import sys +# import os +# import time +# import getopt import struct from pymodbus.client.sync import ModbusTcpClient + client = ModbusTcpClient('192.168.193.15', port=8899) sdmid = 116 - - - -#phasen watt +# phasen watt resp = client.read_input_registers(0x0C,2, unit=sdmid) llw1 = struct.unpack('>f',struct.pack('>HH',*resp.registers))[0] finalw1 = int(llw1) @@ -26,13 +24,11 @@ if ( finalw > 10): finalw=finalw*-1 - f = open('/var/www/html/openWB/ramdisk/pvwatt', 'w') f.write(str(finalw)) f.close() - -#ampere l1 +# ampere l1 resp = client.read_input_registers(0x06,2, unit=sdmid) lla1 = float(struct.unpack('>f',struct.pack('>HH',*resp.registers))[0]) lla1 = float("%.1f" % lla1) @@ -40,7 +36,7 @@ f.write(str(lla1)) f.close() -#ampere l2 +# ampere l2 resp = client.read_input_registers(0x08,2, unit=sdmid) lla1 = float(struct.unpack('>f',struct.pack('>HH',*resp.registers))[0]) lla2 = float("%.1f" % lla1) @@ -48,7 +44,7 @@ f.write(str(lla2)) f.close() -#ampere l3 +# ampere l3 resp = client.read_input_registers(0x0A,2, unit=sdmid) lla1 = float(struct.unpack('>f',struct.pack('>HH',*resp.registers))[0]) lla3 = float("%.1f" % lla1) @@ -56,12 +52,9 @@ f.write(str(lla3)) f.close() - resp = client.read_input_registers(0x0156,2, unit=sdmid) pvkwh = struct.unpack('>f',struct.pack('>HH',*resp.registers))[0] pvkwh = float("%.3f" % pvkwh) / 1000 f = open('/var/www/html/openWB/ramdisk/pvkwh', 'w') f.write(str(pvkwh)) f.close() - - diff --git a/modules/wr_ethsdm120/main.sh b/modules/wr_ethsdm120/main.sh index a5109dcfa..7a12cb834 100755 --- a/modules/wr_ethsdm120/main.sh +++ b/modules/wr_ethsdm120/main.sh @@ -3,5 +3,3 @@ sudo python /var/www/html/openWB/modules/wr_ethsdm120/readsdm120.py $wr_sdm120ip $wr_sdm120id pvwatt=$(f',struct.pack('>HH',*resp.registers)) al1 = float("%.3f" % al1[0]) @@ -28,7 +28,6 @@ f.write(str(watt)) f.close() - resp = client.read_input_registers(0x004a,2, unit=sdmid) vwh = struct.unpack('>f',struct.pack('>HH',*resp.registers)) vwh1 = float("%.3f" % vwh[0]) @@ -42,6 +41,3 @@ f = open("/var/www/html/openWB/ramdisk/pvkwh", 'w') f.write(str(vwh3)) f.close() - - - diff --git a/modules/wr_fronius/main.sh b/modules/wr_fronius/main.sh index 1f80276c4..96b79b765 100755 --- a/modules/wr_fronius/main.sh +++ b/modules/wr_fronius/main.sh @@ -1,14 +1,13 @@ #!/bin/bash # Auslesen eine Fronius Symo WR über die integrierte API des WR. Rückgabewert ist die aktuelle Wirkleistung in [W]. - pvwatttmp=$(curl --connect-timeout 3 -s "$wrfroniusip/solar_api/v1/GetPowerFlowRealtimeData.fcgi?Scope=System") pvwatt=$(echo $pvwatttmp | jq '.Body.Data.Site.P_PV' | sed 's/\..*$//') # Wenn WR aus bzw. im Standby (keine Antwort), ersetze leeren Wert durch eine 0 re='^-?[0-9]+$' if ! [[ $pvwatt =~ $re ]] ; then - pvwatt="0" + pvwatt="0" fi if [[ $wrfroniusisgen24 == 0 ]]; then pvkwh=$(echo $pvwatttmp | jq '.Body.Data.Site.E_Total' | sed 's/\..*$//') @@ -19,7 +18,7 @@ if [[ $wrfronius2ip != "none" ]]; then # Wenn WR aus bzw. im Standby (keine Antwort), ersetze leeren Wert durch eine 0 re='^-?[0-9]+$' if ! [[ $pv2watt =~ $re ]] ; then - pv2watt="0" + pv2watt="0" fi pvwatt=$(echo "($pvwatt + $pv2watt) * -1" | bc) echo $pvwatt @@ -42,7 +41,6 @@ else # Zur weiteren Verwendung im Webinterface echo $pvwatt > /var/www/html/openWB/ramdisk/pvwatt if [[ $wrfroniusisgen24 == 0 ]]; then - if [[ $pvkwh =~ $re ]] ; then if (( pvkwh > 0 )); then echo $pvkwh > /var/www/html/openWB/ramdisk/pvkwh diff --git a/modules/wr_http/main.sh b/modules/wr_http/main.sh index 487278981..748b1d310 100755 --- a/modules/wr_http/main.sh +++ b/modules/wr_http/main.sh @@ -1,12 +1,10 @@ #!/bin/bash - - wattwr=$(curl --connect-timeout 10 -s $wr_http_w_url) re='^-?[0-9]+$' if ! [[ $wattwr =~ $re ]] ; then - wattwr="0" + wattwr="0" fi if (( wattwr > 3 )); then wattwr=$(( wattwr * -1 )) @@ -20,5 +18,3 @@ if [[ $wr_http_kwh_url != "none" ]]; then pvkwhk=$(echo "scale=3;$ekwh / 1000" |bc) echo $pvkwhk > /var/www/html/openWB/ramdisk/pvkwhk fi - - diff --git a/modules/wr_huawei/huawei.py b/modules/wr_huawei/huawei.py index a419afa66..7725fb7c7 100644 --- a/modules/wr_huawei/huawei.py +++ b/modules/wr_huawei/huawei.py @@ -1,40 +1,37 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -ipaddress = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusTcpClient -#client = ModbusTcpClient(ipaddress, port=502) - -#resp= client.read_holding_registers(32066,1,unit=1) -#value1 = resp.registers[0] -#print(str(value1)) -#all = format(value1, '04x') + format(value2, '04x') -#final = int(struct.unpack('>i', all.decode('hex'))[0])*-1 -#f = open('/var/www/html/openWB/ramdisk/pvwatt', 'w') -#f.write(str(final)) -#f.close() -#print(str(final)) +ipaddress = str(sys.argv[1]) +client = ModbusTcpClient(ipaddress, port=502) +# resp= client.read_holding_registers(32066,1,unit=1) +# value1 = resp.registers[0] +# print(str(value1)) +# all = format(value1, '04x') + format(value2, '04x') +# final = int(struct.unpack('>i', all.decode('hex'))[0])*-1 +# f = open('/var/www/html/openWB/ramdisk/pvwatt', 'w') +# f.write(str(final)) +# f.close() +# print(str(final)) client = ModbusTcpClient(ipaddress, port=502) resp= client.read_holding_registers(32080,2,unit=1) value1 = resp.registers[0] value2 = resp.registers[1] -#print(str(value1)) -#print(str(value2)) +# print(str(value1)) +# print(str(value2)) all = format(value1, '04x') + format(value2, '04x') final = int(struct.unpack('>i', all.decode('hex'))[0])*-1 f = open('/var/www/html/openWB/ramdisk/pvwatt', 'w') f.write(str(final)) f.close() -#print(str(final)) - - +# print(str(final)) diff --git a/modules/wr_huawei/main.sh b/modules/wr_huawei/main.sh index dc322b2fa..0e9d80d17 100755 --- a/modules/wr_huawei/main.sh +++ b/modules/wr_huawei/main.sh @@ -1,8 +1,5 @@ #!/bin/bash - - python /var/www/html/openWB/modules/wr_huawei/huawei.py $pv1_ipa pvwatt=$( 5 ] then pvwatt=$(echo "$pvwatt*-1" |bc) fi echo $pvwatt -#zur weiteren verwendung im webinterface +# zur weiteren verwendung im webinterface echo $pvwatt > /var/www/html/openWB/ramdisk/pvwatt -#Gesamtzählerstand am WR [kWh] -#pvkwh=$(echo $pvwatttmp | jq '.dxsEntries[1].value' | sed 's/\..*$//') -#echo $pvkwh > /var/www/html/openWB/ramdisk/pvkwhk -#pvkwh=$(echo "$pvkwh*1000" |bc) -#zur weiteren verwendung im webinterface -#echo $pvkwh > /var/www/html/openWB/ramdisk/pvkwh +# Gesamtzählerstand am WR [kWh] +# pvkwh=$(echo $pvwatttmp | jq '.dxsEntries[1].value' | sed 's/\..*$//') +# echo $pvkwh > /var/www/html/openWB/ramdisk/pvkwhk +# pvkwh=$(echo "$pvkwh*1000" |bc) +# zur weiteren verwendung im webinterface +# echo $pvkwh > /var/www/html/openWB/ramdisk/pvkwh diff --git a/modules/wr_kostalpikovar2/main.sh b/modules/wr_kostalpikovar2/main.sh index fda8ad8c3..80654ef49 100755 --- a/modules/wr_kostalpikovar2/main.sh +++ b/modules/wr_kostalpikovar2/main.sh @@ -3,41 +3,39 @@ # modified by Kevin Wieland # based on Homematic Script v0.2 (c) 2018 by Alchy - -#Daten einlesen +# Daten einlesen HTML=$(/usr/bin/curl -u $wr_piko2_user:$wr_piko2_pass --connect-timeout 10 -s -k $wr_piko2_url | /usr/bin/tr -d '\r' | /usr/bin/tr -d '\n' | /usr/bin/tr -d ' ' | /usr/bin/tr '#' ' ') # request html, concat to one line, remove spaces, add spaces before color changes (#) - + if [[ -n $HTML ]] # check if valid content of request then - counter=0 - for LINE in $HTML # parse all html lines - do - if [[ $LINE =~ FFFFFF ]]; # search for white background color - then - ((counter++)) - PART2=${LINE##*F\">} # strip before number - VALUE=${PART2%%<*} # strip after number + counter=0 + for LINE in $HTML # parse all html lines + do + if [[ $LINE =~ FFFFFF ]]; # search for white background color + then + ((counter++)) + PART2=${LINE##*F\">} # strip before number + VALUE=${PART2%%<*} # strip after number - if [[ $counter -eq 1 ]] # pvwatt - then - if [[ $VALUE = "xxx" ]] # off-value equals zero - then - $VALUE = "0" - fi - re='^[-+]?[0-9]+\.?[0-9]*$' - if ! [[ $VALUE =~ $re ]] # check for valid number - then - VALUE=$( /var/www/html/openWB/ramdisk/pvwatt - echo $((VALUE*-1)) - elif [[ $counter -eq 2 ]] # pvkwhk - then - echo ${VALUE} > /var/www/html/openWB/ramdisk/pvkwhk - echo $((VALUE*1000)) > /var/www/html/openWB/ramdisk/pvkwh - fi - fi - done + if [[ $counter -eq 1 ]] # pvwatt + then + if [[ $VALUE = "xxx" ]] # off-value equals zero + then + $VALUE = "0" + fi + re='^[-+]?[0-9]+\.?[0-9]*$' + if ! [[ $VALUE =~ $re ]] # check for valid number + then + VALUE=$( /var/www/html/openWB/ramdisk/pvwatt + echo $((VALUE*-1)) + elif [[ $counter -eq 2 ]] # pvkwhk + then + echo ${VALUE} > /var/www/html/openWB/ramdisk/pvkwhk + echo $((VALUE*1000)) > /var/www/html/openWB/ramdisk/pvkwh + fi + fi + done fi - diff --git a/modules/wr_lgessv1/main.sh b/modules/wr_lgessv1/main.sh index fc9afd8fb..a32f6ce65 100755 --- a/modules/wr_lgessv1/main.sh +++ b/modules/wr_lgessv1/main.sh @@ -25,7 +25,7 @@ fi # z.b. wenn das System neu gestartet wurde, dann wird ein Dummykey an- # gelegt if test -f "/var/www/html/openWB/ramdisk/ess_session_key"; then - session_key=$(sed -n '1p' /var/www/html/openWB/ramdisk/ess_session_key) + session_key=$(sed -n '1p' /var/www/html/openWB/ramdisk/ess_session_key) else session_key=" " fi diff --git a/modules/wr_plenticore/read_kostalplenticore.py b/modules/wr_plenticore/read_kostalplenticore.py index 9a500bbdd..736a5c2e1 100644 --- a/modules/wr_plenticore/read_kostalplenticore.py +++ b/modules/wr_plenticore/read_kostalplenticore.py @@ -21,12 +21,12 @@ ######################################################### import sys -import os -import getopt -import socket -import ConfigParser -import struct -import binascii +# import os +# import getopt +# import socket +# import ConfigParser +# import struct +# import binascii from datetime import datetime from pymodbus.payload import BinaryPayloadDecoder from pymodbus.constants import Endian @@ -85,7 +85,7 @@ def write_to_ramdisk(): # Gesamtleistung AC PV-Module with open('/var/www/html/openWB/ramdisk/pvwatt', 'w') as f: f.write(str(PV_power_total)) - #schreibe den Wert nur wenn kein Speicher vorhanden ist. Wenn er da ist nutze die openWB PV Watt beschränkung + # schreibe den Wert nur wenn kein Speicher vorhanden ist. Wenn er da ist nutze die openWB PV Watt beschränkung if boolspeicher != 1: # Gesamtertrag in Wattstunden with open('/var/www/html/openWB/ramdisk/pvkwh', 'w') as f: diff --git a/modules/wr_powerdog/main.sh b/modules/wr_powerdog/main.sh index 8623972ed..845256e1c 100755 --- a/modules/wr_powerdog/main.sh +++ b/modules/wr_powerdog/main.sh @@ -2,4 +2,4 @@ sudo python /var/www/html/openWB/modules/wr_powerdog/powerdog.py $bezug1_ip wattbezug=$(i', all.decode('hex'))[0]) @@ -19,4 +21,3 @@ f = open('/var/www/html/openWB/ramdisk/pvwatt', 'w') f.write(str(gridw)) f.close() - diff --git a/modules/wr_pvkit/readlovato.py b/modules/wr_pvkit/readlovato.py index 02f592328..7789791e7 100644 --- a/modules/wr_pvkit/readlovato.py +++ b/modules/wr_pvkit/readlovato.py @@ -1,15 +1,14 @@ #!/usr/bin/python -import sys -import os -import time -import getopt +# import sys +# import os +# import time +# import getopt import struct from pymodbus.client.sync import ModbusTcpClient + client = ModbusTcpClient('192.168.193.13', port=8899) -#from pymodbus.transaction import ModbusRtuFramer -#client = ModbusTcpClient('192.168.0.7', port=8899, framer=ModbusRtuFramer) -#Counters +# Counters resp = client.read_input_registers(0x1a1f,2, unit=0x08) all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') finalbezug1 = int(struct.unpack('>i', all.decode('hex'))[0]) @@ -24,7 +23,7 @@ f.write(str(finalbezug)) f.close() -#phasen watt +# phasen watt resp = client.read_input_registers(0x0013,2, unit=0x08) all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') finalw1 = int(struct.unpack('>i', all.decode('hex'))[0] / 100) @@ -40,15 +39,15 @@ if ( finalw > 10): finalw=finalw*-1 -#total watt -#resp = client.read_input_registers(0x0039,2, unit=0x08) -#all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') -#finalw = int(struct.unpack('>i', all.decode('hex'))[0] / 100) +# total watt +# resp = client.read_input_registers(0x0039,2, unit=0x08) +# all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') +# finalw = int(struct.unpack('>i', all.decode('hex'))[0] / 100) f = open('/var/www/html/openWB/ramdisk/pvwatt', 'w') f.write(str(finalw)) f.close() -#ampere l1 +# ampere l1 resp = client.read_input_registers(0x0007, 2, unit=0x08) all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') lla1 = float(struct.unpack('>i', all.decode('hex'))[0]) / 10000 @@ -56,7 +55,7 @@ f.write(str(lla1)) f.close() -#ampere l2 +# ampere l2 resp = client.read_input_registers(0x0009, 2, unit=0x08) all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') lla2 = float(struct.unpack('>i', all.decode('hex'))[0]) / 10000 @@ -64,7 +63,7 @@ f.write(str(lla2)) f.close() -#ampere l3 +# ampere l3 resp = client.read_input_registers(0x000b, 2, unit=0x08) all = format(resp.registers[0], '04x') + format(resp.registers[1], '04x') lla3 = float(struct.unpack('>i', all.decode('hex'))[0]) / 10000 diff --git a/modules/wr_pvkit/readmpm3pm.py b/modules/wr_pvkit/readmpm3pm.py index 8a495b67b..179baff95 100644 --- a/modules/wr_pvkit/readmpm3pm.py +++ b/modules/wr_pvkit/readmpm3pm.py @@ -1,23 +1,21 @@ #!/usr/bin/python -import sys -import os -import time -import getopt +# import sys +# import os +# import time +# import getopt import struct from pymodbus.client.sync import ModbusTcpClient + client = ModbusTcpClient('192.168.193.13', 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] +# 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)) @@ -53,7 +51,7 @@ f.write(str(lla3)) f.close() -#total watt +# total watt resp = client.read_input_registers(0x26,2, unit=8) value1 = resp.registers[0] value2 = resp.registers[1] diff --git a/modules/wr_pvkit/readsdm.py b/modules/wr_pvkit/readsdm.py index 3611009e8..053552b6d 100644 --- a/modules/wr_pvkit/readsdm.py +++ b/modules/wr_pvkit/readsdm.py @@ -1,14 +1,15 @@ #!/usr/bin/python -import sys -import os -import time -import getopt +# import sys +# import os +# import time +# import getopt import struct from pymodbus.client.sync import ModbusTcpClient + client = ModbusTcpClient('192.168.193.13', port=8899) sdmid = 116 -#phasen watt +# phasen watt resp = client.read_input_registers(0x0C,2, unit=sdmid) llw1 = struct.unpack('>f',struct.pack('>HH',*resp.registers))[0] finalw1 = int(llw1) @@ -27,7 +28,7 @@ f.write(str(finalw)) f.close() -#ampere l1 +# ampere l1 resp = client.read_input_registers(0x06,2, unit=sdmid) lla1 = float(struct.unpack('>f',struct.pack('>HH',*resp.registers))[0]) lla1 = float("%.1f" % lla1) @@ -35,7 +36,7 @@ f.write(str(lla1)) f.close() -#ampere l2 +# ampere l2 resp = client.read_input_registers(0x08,2, unit=sdmid) lla1 = float(struct.unpack('>f',struct.pack('>HH',*resp.registers))[0]) lla2 = float("%.1f" % lla1) @@ -43,7 +44,7 @@ f.write(str(lla2)) f.close() -#ampere l3 +# ampere l3 resp = client.read_input_registers(0x0A,2, unit=sdmid) lla1 = float(struct.unpack('>f',struct.pack('>HH',*resp.registers))[0]) lla3 = float("%.1f" % lla1) diff --git a/modules/wr_shelly/main.sh b/modules/wr_shelly/main.sh index eedf36980..7b28d3590 100644 --- a/modules/wr_shelly/main.sh +++ b/modules/wr_shelly/main.sh @@ -2,13 +2,13 @@ pv_out=$(curl --connect-timeout 3 -s $pv1_ipa/status ) pv_watt=$(echo $pv_out |jq '.meters[0].power' | sed 's/\..*$//') -#if (( $pv_watt > 0 )); then -# pv_watt=$(echo "$pv_watt*-1" |bc) -#fi +# if (( $pv_watt > 0 )); then +# pv_watt=$(echo "$pv_watt*-1" |bc) +# fi pv_watt=$(echo "$pv_watt * -1" | bc) re='^-?[0-9]+$' if ! [[ $pv_watt =~ $re ]] ; then - pv_watt="0" + pv_watt="0" fi echo $pv_watt > /var/www/html/openWB/ramdisk/pvwatt echo $pv_watt diff --git a/modules/wr_siemens/main.sh b/modules/wr_siemens/main.sh index d61e5af25..ca68834a3 100755 --- a/modules/wr_siemens/main.sh +++ b/modules/wr_siemens/main.sh @@ -1,8 +1,5 @@ #!/bin/bash - - python /var/www/html/openWB/modules/wr_siemens/siemens.py $pv1_ipa wattbezug=$( W) +# Aktuelle Leistung (kW --> W) wattwr=$(echo $json | jq .ActivePower) wattwr=$(echo "scale=3 ; $wattwr * 1000" | bc) wattwr=$(echo "$wattwr / 1" | bc) -#Zählerstand Export (kWh --> Wh) +# Zählerstand Export (kWh --> Wh) pvkwh=$(echo $json | jq .CounterReadingExport) pvkwh=$(echo "scale=3 ; $pvkwh * 1000" | bc) -#Zur Reduzierung der Datenmenge kann die folgende Zeile eingefügt werden. -#pvkwh=$(echo "$pvkwh / 1" | bc) +# Zur Reduzierung der Datenmenge kann die folgende Zeile eingefügt werden. +# pvkwh=$(echo "$pvkwh / 1" | bc) -#Prüfen ob Werte gültig +# Prüfen ob Werte gültig re='^[-+]?[0-9]+\.?[0-9]*$' if ! [[ $wattwr =~ $re ]] ; then - wattwr=$( /var/www/html/openWB/ramdisk/pvwatt - echo $pvkwh > /var/www/html/openWB/ramdisk/pvkwh - pvkwhk=$(echo "scale=3 ; $pvkwh / 1000" | bc) echo $pvkwhk > /var/www/html/openWB/ramdisk/pvkwhk diff --git a/modules/wr_solaredge/main.sh b/modules/wr_solaredge/main.sh index f2e05d405..fd3b795ea 100755 --- a/modules/wr_solaredge/main.sh +++ b/modules/wr_solaredge/main.sh @@ -12,4 +12,3 @@ fi pvwatt=$(h', all.decode('hex'))[0]) * -1 + if extprodakt == 1: + resp= client.read_holding_registers(40380,1,unit=slave1id) + value1 = resp.registers[0] + all = format(value1, '04x') + extprod = int(struct.unpack('>h', all.decode('hex'))[0]) * -1 else: - extprod = 0 + extprod = 0 rawprodw = rawprodw + extprod - storagepower f = open('/var/www/html/openWB/ramdisk/pvwatt', 'w') f.write(str(rawprodw)) f.close() - resp= client.read_holding_registers(40093,2,unit=slave1id) value1 = resp.registers[0] value2 = resp.registers[1] @@ -72,7 +74,3 @@ f = open('/var/www/html/openWB/ramdisk/pvkwhk', 'w') f.write(str(pvkwhk)) f.close() - - - - diff --git a/modules/wr_solaredge/solaredge2.py b/modules/wr_solaredge/solaredge2.py index a901560f6..553879e92 100755 --- a/modules/wr_solaredge/solaredge2.py +++ b/modules/wr_solaredge/solaredge2.py @@ -1,27 +1,30 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusTcpClient + ipaddress = str(sys.argv[1]) slave1id = int(sys.argv[2]) slave2id = int(sys.argv[3]) batwrsame = int(sys.argv[4]) extprodakt = int(sys.argv[5]) -from pymodbus.client.sync import ModbusTcpClient client = ModbusTcpClient(ipaddress, port=502) -#batterie auslesen und pv leistung korrigieren + +# batterie auslesen und pv leistung korrigieren storagepower = 0 if batwrsame == 1: rr = client.read_holding_registers(62836, 2, unit=1) raw = struct.pack('>HH', rr.getRegister(1), rr.getRegister(0)) storagepower = int(struct.unpack('>f', raw)[0]) -#wr1 + +# wr1 resp= client.read_holding_registers(40084,2,unit=slave1id) multipli = resp.registers[0] multiplint = format(multipli, '04x') @@ -48,7 +51,7 @@ all = format(value1, '04x') + format(value2, '04x') final = int(struct.unpack('>i', all.decode('hex'))[0]) -#wr2 +# wr2 resp= client.read_holding_registers(40084,2,unit=slave2id) multipli = resp.registers[0] multiplint = format(multipli, '04x') @@ -70,12 +73,12 @@ rawprod2w = rawprod2w / 10000 if extprodakt == 1: - resp= client.read_holding_registers(40380,1,unit=slave1id) - value1 = resp.registers[0] - all = format(value1, '04x') - extprod = int(struct.unpack('>h', all.decode('hex'))[0]) * -1 + resp= client.read_holding_registers(40380,1,unit=slave1id) + value1 = resp.registers[0] + all = format(value1, '04x') + extprod = int(struct.unpack('>h', all.decode('hex'))[0]) * -1 else: - extprod = 0 + extprod = 0 realrawprodw = rawprodw + rawprod2w + extprod - storagepower f = open('/var/www/html/openWB/ramdisk/pvwatt', 'w') f.write(str(realrawprodw)) @@ -94,7 +97,3 @@ f = open('/var/www/html/openWB/ramdisk/pvkwhk', 'w') f.write(str(pvkwhk)) f.close() - - - - diff --git a/modules/wr_solaredge/solaredge2wr.py b/modules/wr_solaredge/solaredge2wr.py index e85eb6fc4..a4e43174a 100755 --- a/modules/wr_solaredge/solaredge2wr.py +++ b/modules/wr_solaredge/solaredge2wr.py @@ -1,20 +1,23 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusTcpClient + ipaddress = str(sys.argv[1]) slave1id = int(sys.argv[2]) batwrsame = int(sys.argv[3]) ip2address = str(sys.argv[4]) extprodakt = str(sys.argv[5]) -from pymodbus.client.sync import ModbusTcpClient + client = ModbusTcpClient(ipaddress, port=502) -#batterie auslesen und pv leistung korrigieren + +# batterie auslesen und pv leistung korrigieren storagepower = 0 if batwrsame == 1: rr = client.read_holding_registers(62836, 2, unit=1) @@ -50,17 +53,15 @@ rawprodw = rawprodw / 100000 rawprodwwr1 = rawprodw - storagepower - resp= client.read_holding_registers(40093,2,unit=slave1id) value1 = resp.registers[0] value2 = resp.registers[1] all = format(value1, '04x') + format(value2, '04x') finalwr1 = int(struct.unpack('>i', all.decode('hex'))[0]) - -from pymodbus.client.sync import ModbusTcpClient client = ModbusTcpClient(ip2address, port=502) -#batterie auslesen und pv leistung korrigieren + +# batterie auslesen und pv leistung korrigieren resp= client.read_holding_registers(40084,2,unit=slave1id) multipli = resp.registers[0] multiplint = format(multipli, '04x') @@ -90,20 +91,19 @@ rawprodw = rawprodw / 100000 rawprodwwr2 = rawprodw -if extprodakt == 1: - resp= client.read_holding_registers(40380,1,unit=slave1id) - value1 = resp.registers[0] - all = format(value1, '04x') - extprod = int(struct.unpack('>h', all.decode('hex'))[0]) * -1 +if extprodakt == 1: + resp= client.read_holding_registers(40380,1,unit=slave1id) + value1 = resp.registers[0] + all = format(value1, '04x') + extprod = int(struct.unpack('>h', all.decode('hex'))[0]) * -1 else: - extprod = 0 + extprod = 0 rawprodw = extprod + rawprodwwr1 + rawprodwwr2 f = open('/var/www/html/openWB/ramdisk/pvwatt', 'w') f.write(str(rawprodw)) f.close() - resp= client.read_holding_registers(40093,2,unit=slave1id) value1 = resp.registers[0] value2 = resp.registers[1] @@ -117,7 +117,3 @@ f = open('/var/www/html/openWB/ramdisk/pvkwhk', 'w') f.write(str(pvkwhk)) f.close() - - - - diff --git a/modules/wr_solaredge/solaredge3.py b/modules/wr_solaredge/solaredge3.py index 982dcb124..a33348fc6 100755 --- a/modules/wr_solaredge/solaredge3.py +++ b/modules/wr_solaredge/solaredge3.py @@ -1,12 +1,14 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusTcpClient + ipaddress = str(sys.argv[1]) slave1id = int(sys.argv[2]) slave2id = int(sys.argv[3]) @@ -14,14 +16,15 @@ batwrsame = int(sys.argv[5]) extprodakt = int(sys.argv[6]) -from pymodbus.client.sync import ModbusTcpClient client = ModbusTcpClient(ipaddress, port=502) + storagepower = 0 if batwrsame == 1: rr = client.read_holding_registers(62836, 2, unit=1) raw = struct.pack('>HH', rr.getRegister(1), rr.getRegister(0)) storagepower = int(struct.unpack('>f', raw)[0]) -#wr1 + +# wr1 resp= client.read_holding_registers(40084,2,unit=slave1id) multipli = resp.registers[0] multiplint = format(multipli, '04x') @@ -47,7 +50,8 @@ value2 = resp.registers[1] all = format(value1, '04x') + format(value2, '04x') final = int(struct.unpack('>i', all.decode('hex'))[0]) -#wr3 + +# wr3 resp= client.read_holding_registers(40084,2,unit=slave3id) multipli = resp.registers[0] multiplint = format(multipli, '04x') @@ -74,7 +78,7 @@ all = format(value1, '04x') + format(value2, '04x') final3 = int(struct.unpack('>i', all.decode('hex'))[0]) -#wr2 +# wr2 resp= client.read_holding_registers(40084,2,unit=slave2id) multipli = resp.registers[0] multiplint = format(multipli, '04x') @@ -120,7 +124,3 @@ f = open('/var/www/html/openWB/ramdisk/pvkwhk', 'w') f.write(str(pvkwhk)) f.close() - - - - diff --git a/modules/wr_solaredge/solaredge4.py b/modules/wr_solaredge/solaredge4.py index 5db25826a..fd7bdea05 100755 --- a/modules/wr_solaredge/solaredge4.py +++ b/modules/wr_solaredge/solaredge4.py @@ -1,12 +1,14 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusTcpClient + ipaddress = str(sys.argv[1]) slave1id = int(sys.argv[2]) slave2id = int(sys.argv[3]) @@ -15,14 +17,15 @@ slave4id = int(sys.argv[6]) extprodakt = int(sys.argv[7]) -from pymodbus.client.sync import ModbusTcpClient client = ModbusTcpClient(ipaddress, port=502) + storagepower = 0 if batwrsame == 1: rr = client.read_holding_registers(62836, 2, unit=1) raw = struct.pack('>HH', rr.getRegister(1), rr.getRegister(0)) storagepower = int(struct.unpack('>f', raw)[0]) -#wr1 + +# wr1 resp= client.read_holding_registers(40084,2,unit=slave1id) multipli = resp.registers[0] multiplint = format(multipli, '04x') @@ -48,7 +51,8 @@ value2 = resp.registers[1] all = format(value1, '04x') + format(value2, '04x') final = int(struct.unpack('>i', all.decode('hex'))[0]) -#wr3 + +# wr3 resp= client.read_holding_registers(40084,2,unit=slave3id) multipli = resp.registers[0] multiplint = format(multipli, '04x') @@ -75,7 +79,7 @@ all = format(value1, '04x') + format(value2, '04x') final3 = int(struct.unpack('>i', all.decode('hex'))[0]) -#wr4 +# wr4 resp= client.read_holding_registers(40084,2,unit=slave4id) multipli = resp.registers[0] multiplint = format(multipli, '04x') @@ -102,7 +106,7 @@ all = format(value1, '04x') + format(value2, '04x') final4 = int(struct.unpack('>i', all.decode('hex'))[0]) -#wr2 +# wr2 resp= client.read_holding_registers(40084,2,unit=slave2id) multipli = resp.registers[0] multiplint = format(multipli, '04x') @@ -122,15 +126,14 @@ rawprod2w = rawprod2w / 1000 if fmultiplint == -4: rawprod2w = rawprod2w / 10000 - -if extprodakt == 1: - resp= client.read_holding_registers(40380,1,unit=slave1id) - value1 = resp.registers[0] - all = format(value1, '04x') - extprod = int(struct.unpack('>h', all.decode('hex'))[0]) * -1 +if extprodakt == 1: + resp= client.read_holding_registers(40380,1,unit=slave1id) + value1 = resp.registers[0] + all = format(value1, '04x') + extprod = int(struct.unpack('>h', all.decode('hex'))[0]) * -1 else: - extprod = 0 + extprod = 0 realrawprodw = rawprodw + rawprod2w + rawprod3w +rawprod4w + extprod - storagepower f = open('/var/www/html/openWB/ramdisk/pvwatt', 'w') @@ -150,7 +153,3 @@ f = open('/var/www/html/openWB/ramdisk/pvkwhk', 'w') f.write(str(pvkwhk)) f.close() - - - - diff --git a/modules/wr_solaredge/solaredgeall.py b/modules/wr_solaredge/solaredgeall.py index cd5b5b55d..566c019f4 100644 --- a/modules/wr_solaredge/solaredgeall.py +++ b/modules/wr_solaredge/solaredgeall.py @@ -1,12 +1,14 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusTcpClient + ipaddress = str(sys.argv[1]) try: slave1id = int(sys.argv[2]) @@ -28,10 +30,12 @@ extprodakt = int(sys.argv[7]) zweiterspeicher = int(sys.argv[8]) subbat = int(sys.argv[9]) + storage2power = 0 -from pymodbus.client.sync import ModbusTcpClient + client = ModbusTcpClient(ipaddress, port=502) -#batterie auslesen und pv leistung korrigieren + +# batterie auslesen und pv leistung korrigieren storagepower = 0 storage2power = 0 if batwrsame == 1: @@ -66,13 +70,12 @@ f.write(str(final)) f.close() - try: resp= client.read_holding_registers(40083,2,unit=slave1id) - #read watt + # read watt watt=format(resp.registers[0], '04x') wr1watt=int(struct.unpack('>h', watt.decode('hex'))[0]) * -1 - #read multiplier + # read multiplier multiplier=format(resp.registers[1], '04x') fmultiplier=int(struct.unpack('>h', multiplier.decode('hex'))[0]) if fmultiplier == 2: @@ -101,10 +104,10 @@ if slave2id != 0: try: resp= client.read_holding_registers(40083,2,unit=slave2id) - #read watt + # read watt watt=format(resp.registers[0], '04x') wr2watt=int(struct.unpack('>h', watt.decode('hex'))[0]) * -1 - #read multiplier + # read multiplier multiplier=format(resp.registers[1], '04x') fmultiplier=int(struct.unpack('>h', multiplier.decode('hex'))[0]) if fmultiplier == 2: @@ -135,17 +138,16 @@ if slave3id != 0: try: resp= client.read_holding_registers(40083,2,unit=slave3id) - #read watt + # read watt watt=format(resp.registers[0], '04x') wr3watt=int(struct.unpack('>h', watt.decode('hex'))[0]) * -1 - #read multiplier + # read multiplier multiplier=format(resp.registers[1], '04x') fmultiplier=int(struct.unpack('>h', multiplier.decode('hex'))[0]) if fmultiplier == 2: fwr3watt = wr3watt * 100 if fmultiplier == 1: fwr3watt = wr3watt * 10 - if fmultiplier == 0: fwr3watt = wr3watt if fmultiplier == -1: @@ -170,17 +172,16 @@ if slave4id != 0: try: resp= client.read_holding_registers(40083,2,unit=slave4id) - #read watt + # read watt watt=format(resp.registers[0], '04x') wr4watt=int(struct.unpack('>h', watt.decode('hex'))[0]) * -1 - #read multiplier + # read multiplier multiplier=format(resp.registers[1], '04x') fmultiplier=int(struct.unpack('>h', multiplier.decode('hex'))[0]) if fmultiplier == 2: fwr4watt = wr4watt * 100 if fmultiplier == 1: fwr4watt = wr4watt * 10 - if fmultiplier == 0: fwr4watt = wr4watt if fmultiplier == -1: @@ -203,8 +204,7 @@ else: fwr4watt=0 - -if extprodakt == 1: +if extprodakt == 1: try: resp= client.read_holding_registers(40380,1,unit=slave1id) value1 = resp.registers[0] @@ -227,9 +227,6 @@ f = open('/var/www/html/openWB/ramdisk/pvwatt', 'w') f.write(str(allwatt)) f.close() - - - f = open('/var/www/html/openWB/ramdisk/pvkwh', 'w') f.write(str(final)) f.close() @@ -237,5 +234,3 @@ f = open('/var/www/html/openWB/ramdisk/pvkwhk', 'w') f.write(str(pvkwhk)) f.close() - - diff --git a/modules/wr_solarlog/main.sh b/modules/wr_solarlog/main.sh index cd91f1ffd..fdba29cd3 100755 --- a/modules/wr_solarlog/main.sh +++ b/modules/wr_solarlog/main.sh @@ -1,18 +1,12 @@ #!/bin/bash - - - answer=$(curl -d {\"801\":{\"170\":null}} --connect-timeout 5 -s $bezug_solarlog_ip/getjp) - pvwatt=$(echo $answer | jq '."801"."170"."101"' ) pvkwh=$(echo $answer | jq '."801"."170"."109"' ) - if (( $pvwatt > 5 )); then pvwatt=$(echo "$pvwatt*-1" |bc) fi echo $pvwatt echo $pvwatt > /var/www/html/openWB/ramdisk/pvwatt echo $pvkwh > /var/www/html/openWB/ramdisk/pvkwh - diff --git a/modules/wr_solarview/main.sh b/modules/wr_solarview/main.sh index ba33bad06..b1e137103 100755 --- a/modules/wr_solarview/main.sh +++ b/modules/wr_solarview/main.sh @@ -11,128 +11,127 @@ target="$openwb_home/ramdisk" # Checks if [ -z "$solarview_hostname" ]; then - log "Missing required variable 'solarview_hostname'" - return 1 + log "Missing required variable 'solarview_hostname'" + return 1 fi if [ "${solarview_port}" ]; then - if [ "$solarview_port" -lt 1 ] || [ "$solarview_port" -gt 65535 ]; then - log "Invalid value '$solarview_port' for variable 'solarview_port'" - return 1 - fi + if [ "$solarview_port" -lt 1 ] || [ "$solarview_port" -gt 65535 ]; then + log "Invalid value '$solarview_port' for variable 'solarview_port'" + return 1 + fi fi log() { - echo "[wr_solarview] $*" >>"$target/openWB.log" + echo "[wr_solarview] $*" >>"$target/openWB.log" } request() { - command="$1" - port="${solarview_port:-15000}" - timeout="${solarview_timeout:-1}" - - response=$(echo "$command" | nc -w "$timeout" "$solarview_hostname" "$port") - return_code="$?" - if [ "$return_code" -ne 0 ]; then - log "Error: request to SolarView failed. Details: return-code: '$return_code', host: '$solarview_hostname', port: '$port', timeout: '$timeout'" - return "$return_code" - fi - - [ "$debug" -ne 0 ] && log "Raw response: $response" - # - # Format: {WR,Tag,Monat,Jahr,Stunde,Minute,KDY,KMT,KYR,KT0,PAC,UDC,IDC,UDCB,IDCB,UDCC,IDCC,UDCD,IDCD,UL1,IL1,UL2,IL2,UL3,IL3,TKK},Checksum - # Beispiel: {01,09,09,2019,08,18,0000.0,00082,002617,00018691,00104,451,000.2,000,000.0,000,000.0,000,000.0,226,000.4,000,000.0,000,000.0,00},▒ - # - # Bedeutung (siehe SolarView-Dokumentation): - # KDY= Tagesertrag (kWh) - # KMT= Monatsertrag (kWh) - # KYR= Jahresertrag (kWh) - # KT0= Gesamtertrag (kWh) - # PAC= Generatorleistung in W - # UDC, UDCB, UDCC, UDCD= Generator-Spannungen in Volt pro MPP-Tracker - # IDC, IDCB, IDCC, IDCD= Generator-Ströme in Ampere pro MPP-Tracker - # UL1, IL1= Netzspannung, Netzstrom Phase 1 - # UL2, IL2= Netzspannung, Netzstrom Phase 2 - # UL3, IL3= Netzspannung, Netzstrom Phase 3 - # TKK= Temperatur Wechselrichter - - # Geschweifte Klammern und Checksumme entfernen - values="${response#*\{}" - values="${values%\}*}" - - # Werte auslesen und verarbeiten - local LANG=C - echo "$values" | while IFS=',' read -r WR Tag Monat Jahr Stunde Minute KDY KMT KYR KT0 PAC UDC IDC UDCB IDCB UDCC IDCC UDCD IDCD UL1 IL1 UL2 IL2 UL3 IL3 TKK - do - - # Werte formatiert in Variablen speichern - id="$WR" - timestamp="$Jahr-$Monat-$Tag $Stunde:$Minute" - power=$( awk "BEGIN{print -1 * $PAC}") - energy_day=$( awk "BEGIN{print 1000 * $KDY}") - energy_month=$(awk "BEGIN{print 1000 * $KMT}") - energy_year=$( awk "BEGIN{print 1000 * $KYR}") - energy_total=$(awk "BEGIN{print 1000 * $KT0}") - mpptracker1_voltage=$(printf "%.0f" "$UDC") - mpptracker1_current=$(printf "%.1f" "$IDC") - mpptracker2_voltage=$(printf "%.0f" "$UDCB") - mpptracker2_current=$(printf "%.1f" "$IDCB") - mpptracker3_voltage=$(printf "%.0f" "$UDCC") - mpptracker3_current=$(printf "%.1f" "$IDCC") - mpptracker4_voltage=$(printf "%.0f" "$UDCD") - mpptracker4_current=$(printf "%.1f" "$IDCD") - grid1_voltage=$( printf "%.0f" "$UL1") - grid1_current=$( printf "%.1f" "$IL1") - grid2_voltage=$( printf "%.0f" "$UL2") - grid2_current=$( printf "%.1f" "$IL2") - grid3_voltage=$( printf "%.0f" "$UL3") - grid3_current=$( printf "%.1f" "$IL3") - temperature=$( printf "%.0f" "$TKK") - - if [ "$debug" -ne 0 ]; then - # Werte ausgeben - log "ID: $id" - log "Zeitpunkt: $timestamp" - log "Temperatur: $temperature °C" - log "Leistung: $power W" - log "Energie:" - log " Tag: $energy_day Wh" - log " Monat: $energy_month Wh" - log " Jahr: $energy_year Wh" - log " Gesamt: $energy_total Wh" - log "Generator-MPP-Tracker-1" - log " Spannung: $mpptracker1_voltage V" - log " Strom: $mpptracker1_current A" - log "Generator-MPP-Tracker-2" - log " Spannung: $mpptracker2_voltage V" - log " Strom: $mpptracker2_current A" - log "Generator-MPP-Tracker-3" - log " Spannung: $mpptracker3_voltage V" - log " Strom: $mpptracker3_current A" - log "Generator-MPP-Tracker-4" - log " Spannung: $mpptracker4_voltage V" - log " Strom: $mpptracker4_current A" - log "Netz:" - log " Phase 1:" - log " Spannung: $grid1_voltage V" - log " Strom: $grid1_current A" - log " Phase 2:" - log " Spannung: $grid2_voltage V" - log " Strom: $grid2_current A" - log " Phase 3:" - log " Spannung: $grid3_voltage V" - log " Strom: $grid3_current A" - fi - - # Werte speichern - echo "$power" >"$target/pvwatt" - echo "$energy_total" >"$target/pvkwh" - echo "$energy_day" >"$target/daily_pvkwh" - echo "$energy_month" >"$target/monthly_pvkwh" - echo "$energy_year" >"$target/yearly_pvkwh" - - # Aktuelle Leistung an der Aufrufer zurückliefern - echo "$power" - done + command="$1" + port="${solarview_port:-15000}" + timeout="${solarview_timeout:-1}" + + response=$(echo "$command" | nc -w "$timeout" "$solarview_hostname" "$port") + return_code="$?" + if [ "$return_code" -ne 0 ]; then + log "Error: request to SolarView failed. Details: return-code: '$return_code', host: '$solarview_hostname', port: '$port', timeout: '$timeout'" + return "$return_code" + fi + + [ "$debug" -ne 0 ] && log "Raw response: $response" + # + # Format: {WR,Tag,Monat,Jahr,Stunde,Minute,KDY,KMT,KYR,KT0,PAC,UDC,IDC,UDCB,IDCB,UDCC,IDCC,UDCD,IDCD,UL1,IL1,UL2,IL2,UL3,IL3,TKK},Checksum + # Beispiel: {01,09,09,2019,08,18,0000.0,00082,002617,00018691,00104,451,000.2,000,000.0,000,000.0,000,000.0,226,000.4,000,000.0,000,000.0,00},▒ + # + # Bedeutung (siehe SolarView-Dokumentation): + # KDY= Tagesertrag (kWh) + # KMT= Monatsertrag (kWh) + # KYR= Jahresertrag (kWh) + # KT0= Gesamtertrag (kWh) + # PAC= Generatorleistung in W + # UDC, UDCB, UDCC, UDCD= Generator-Spannungen in Volt pro MPP-Tracker + # IDC, IDCB, IDCC, IDCD= Generator-Ströme in Ampere pro MPP-Tracker + # UL1, IL1= Netzspannung, Netzstrom Phase 1 + # UL2, IL2= Netzspannung, Netzstrom Phase 2 + # UL3, IL3= Netzspannung, Netzstrom Phase 3 + # TKK= Temperatur Wechselrichter + + # Geschweifte Klammern und Checksumme entfernen + values="${response#*\{}" + values="${values%\}*}" + + # Werte auslesen und verarbeiten + local LANG=C + echo "$values" | while IFS=',' read -r WR Tag Monat Jahr Stunde Minute KDY KMT KYR KT0 PAC UDC IDC UDCB IDCB UDCC IDCC UDCD IDCD UL1 IL1 UL2 IL2 UL3 IL3 TKK + do + # Werte formatiert in Variablen speichern + id="$WR" + timestamp="$Jahr-$Monat-$Tag $Stunde:$Minute" + power=$( awk "BEGIN{print -1 * $PAC}") + energy_day=$( awk "BEGIN{print 1000 * $KDY}") + energy_month=$(awk "BEGIN{print 1000 * $KMT}") + energy_year=$( awk "BEGIN{print 1000 * $KYR}") + energy_total=$(awk "BEGIN{print 1000 * $KT0}") + mpptracker1_voltage=$(printf "%.0f" "$UDC") + mpptracker1_current=$(printf "%.1f" "$IDC") + mpptracker2_voltage=$(printf "%.0f" "$UDCB") + mpptracker2_current=$(printf "%.1f" "$IDCB") + mpptracker3_voltage=$(printf "%.0f" "$UDCC") + mpptracker3_current=$(printf "%.1f" "$IDCC") + mpptracker4_voltage=$(printf "%.0f" "$UDCD") + mpptracker4_current=$(printf "%.1f" "$IDCD") + grid1_voltage=$( printf "%.0f" "$UL1") + grid1_current=$( printf "%.1f" "$IL1") + grid2_voltage=$( printf "%.0f" "$UL2") + grid2_current=$( printf "%.1f" "$IL2") + grid3_voltage=$( printf "%.0f" "$UL3") + grid3_current=$( printf "%.1f" "$IL3") + temperature=$( printf "%.0f" "$TKK") + + if [ "$debug" -ne 0 ]; then + # Werte ausgeben + log "ID: $id" + log "Zeitpunkt: $timestamp" + log "Temperatur: $temperature °C" + log "Leistung: $power W" + log "Energie:" + log " Tag: $energy_day Wh" + log " Monat: $energy_month Wh" + log " Jahr: $energy_year Wh" + log " Gesamt: $energy_total Wh" + log "Generator-MPP-Tracker-1" + log " Spannung: $mpptracker1_voltage V" + log " Strom: $mpptracker1_current A" + log "Generator-MPP-Tracker-2" + log " Spannung: $mpptracker2_voltage V" + log " Strom: $mpptracker2_current A" + log "Generator-MPP-Tracker-3" + log " Spannung: $mpptracker3_voltage V" + log " Strom: $mpptracker3_current A" + log "Generator-MPP-Tracker-4" + log " Spannung: $mpptracker4_voltage V" + log " Strom: $mpptracker4_current A" + log "Netz:" + log " Phase 1:" + log " Spannung: $grid1_voltage V" + log " Strom: $grid1_current A" + log " Phase 2:" + log " Spannung: $grid2_voltage V" + log " Strom: $grid2_current A" + log " Phase 3:" + log " Spannung: $grid3_voltage V" + log " Strom: $grid3_current A" + fi + + # Werte speichern + echo "$power" >"$target/pvwatt" + echo "$energy_total" >"$target/pvkwh" + echo "$energy_day" >"$target/daily_pvkwh" + echo "$energy_month" >"$target/monthly_pvkwh" + echo "$energy_year" >"$target/yearly_pvkwh" + + # Aktuelle Leistung an der Aufrufer zurückliefern + echo "$power" + done } # Sende-Kommando (siehe SolarView-Dokumentation); Beispiele: diff --git a/modules/wr_solarworld/main.sh b/modules/wr_solarworld/main.sh index f7fe7355f..37db35ce9 100644 --- a/modules/wr_solarworld/main.sh +++ b/modules/wr_solarworld/main.sh @@ -5,11 +5,11 @@ emanagerantwort=$(curl --connect-timeout 5 -s "$solarworld_emanagerip/rest/solar wr_watt=$(LC_ALL=C printf "%.0f\n" $(echo $emanagerantwort | jq '.PowerTotalPV')) -#wenn eManager aus bzw. keine Antwort ersetze leeren Wert durch eine 0 +# wenn eManager aus bzw. keine Antwort ersetze leeren Wert durch eine 0 ra='^-?[0-9]+$' if ! [[ $wr_watt =~ $ra ]] ; then - wr_watt="0" + wr_watt="0" fi # PV ezeugte Leistung muss negativ sein diff --git a/modules/wr_solax/solax.py b/modules/wr_solax/solax.py index 607fb1fcd..b5bb43d30 100644 --- a/modules/wr_solax/solax.py +++ b/modules/wr_solax/solax.py @@ -1,16 +1,16 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import struct -import binascii - - +# import os +# import time +# import getopt +# import socket +# import struct +# import binascii from pymodbus.client.sync import ModbusTcpClient from pymodbus.factory import ClientDecoder +ipaddress = str(sys.argv[1]) + def unsigned32(result, addr): low = result.registers[addr] high = result.registers[addr + 1] @@ -26,10 +26,8 @@ def signed16(result, addr): val -= 65535 return val -ipaddress = str(sys.argv[1]) client = ModbusTcpClient(ipaddress, port=502) - resp=client.read_input_registers(10, 2) pv1 = unsigned16(resp, 0) pv2 = unsigned16(resp, 1) diff --git a/modules/wr_studer/main.sh b/modules/wr_studer/main.sh index 9a39bc052..813c2d2d1 100644 --- a/modules/wr_studer/main.sh +++ b/modules/wr_studer/main.sh @@ -5,6 +5,3 @@ python /var/www/html/openWB/modules/wr_studer/studer_wr.py $studer_ip $studer_xt # Rückgabe des Wertes Gesamt-PV-Leistung pvwatt=$( /var/www/html/openWB/ramdisk/pvwatt fi fi - - - - else if [[ $wrsma2ip != "none" ]] && [[ $wrsma3ip != "none" ]] && [[ $wrsma4ip != "none" ]]; then sudo python /var/www/html/openWB/modules/wr_tripower9000/tri90004.py $tri9000ip $wrsma2ip $wrsma3ip $wrsma4ip else - if [[ $wrsma2ip != "none" ]] && [[ $wrsma3ip != "none" ]]; then + if [[ $wrsma2ip != "none" ]] && [[ $wrsma3ip != "none" ]]; then sudo python /var/www/html/openWB/modules/wr_tripower9000/tri90003.py $tri9000ip $wrsma2ip $wrsma3ip else - if [[ $wrsma2ip != "none" ]]; then + if [[ $wrsma2ip != "none" ]]; then sudo python /var/www/html/openWB/modules/wr_tripower9000/tri90002.py $tri9000ip $wrsma2ip else sudo python /var/www/html/openWB/modules/wr_tripower9000/tri9000.py $tri9000ip @@ -35,18 +31,8 @@ else fi fi - - - pvwatt=$( /var/www/html/openWB/ramdisk/pvkwhk - - - - - diff --git a/modules/wr_tripower9000/tri9000.py b/modules/wr_tripower9000/tri9000.py index c2846a6c7..c41a5c434 100755 --- a/modules/wr_tripower9000/tri9000.py +++ b/modules/wr_tripower9000/tri9000.py @@ -1,17 +1,19 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii -ipaddress = str(sys.argv[1]) +# import binascii from pymodbus.client.sync import ModbusTcpClient + +ipaddress = str(sys.argv[1]) + client = ModbusTcpClient(ipaddress, port=502) -#pv watt +# pv watt resp= client.read_holding_registers(30775,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] @@ -24,7 +26,7 @@ f.write(str(final)) f.close() -#pv Wh +# pv Wh resp= client.read_holding_registers(30529,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] @@ -33,9 +35,3 @@ f = open('/var/www/html/openWB/ramdisk/pvkwh', 'w') f.write(str(final)) f.close() - - - - - - diff --git a/modules/wr_tripower9000/tri90002.py b/modules/wr_tripower9000/tri90002.py index c4e31c7ef..9423b9804 100755 --- a/modules/wr_tripower9000/tri90002.py +++ b/modules/wr_tripower9000/tri90002.py @@ -1,44 +1,44 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusTcpClient + ipaddress = str(sys.argv[1]) ip2address = str(sys.argv[2]) -from pymodbus.client.sync import ModbusTcpClient + client = ModbusTcpClient(ipaddress, port=502) client2 = ModbusTcpClient(ip2address, port=502) - -#pv watt +# pv watt resp= client.read_holding_registers(30775,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] all = format(value1, '04x') + format(value2, '04x') wr1w = int(struct.unpack('>i', all.decode('hex'))[0]) -#if final < 0: -# final = 0 -#final = final * -1 -#f = open('/var/www/html/openWB/ramdisk/pvwatt', 'w') -#f.write(str(final)) -#f.close() +# if final < 0: +# final = 0 +# final = final * -1 +# f = open('/var/www/html/openWB/ramdisk/pvwatt', 'w') +# f.write(str(final)) +# f.close() -#pv Wh +# pv Wh resp= client.read_holding_registers(30529,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] all = format(value1, '04x') + format(value2, '04x') wr1wh = int(struct.unpack('>i', all.decode('hex'))[0]) -#f = open('/var/www/html/openWB/ramdisk/pvkwh', 'w') -#f.write(str(final)) -#f.close() - +# f = open('/var/www/html/openWB/ramdisk/pvkwh', 'w') +# f.write(str(final)) +# f.close() -#pv watt +# pv watt resp= client2.read_holding_registers(30775,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] @@ -52,7 +52,7 @@ f.write(str(final)) f.close() -#pv Wh +# pv Wh resp= client2.read_holding_registers(30529,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] @@ -62,9 +62,3 @@ f = open('/var/www/html/openWB/ramdisk/pvkwh', 'w') f.write(str(final)) f.close() - - - - - - diff --git a/modules/wr_tripower9000/tri90003.py b/modules/wr_tripower9000/tri90003.py index dcd6ef1f2..3a50333ca 100755 --- a/modules/wr_tripower9000/tri90003.py +++ b/modules/wr_tripower9000/tri90003.py @@ -1,50 +1,50 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusTcpClient + ipaddress = str(sys.argv[1]) ip2address = str(sys.argv[2]) ip3address = str(sys.argv[3]) -from pymodbus.client.sync import ModbusTcpClient + client = ModbusTcpClient(ipaddress, port=502) client2 = ModbusTcpClient(ip2address, port=502) client3 = ModbusTcpClient(ip3address, port=502) - - -#pv watt +# pv watt resp= client.read_holding_registers(30775,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] all = format(value1, '04x') + format(value2, '04x') wr1w = int(struct.unpack('>i', all.decode('hex'))[0]) -#pv Wh + +# pv Wh resp= client.read_holding_registers(30529,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] all = format(value1, '04x') + format(value2, '04x') wr1wh = int(struct.unpack('>i', all.decode('hex'))[0]) -#pv watt +# pv watt resp= client3.read_holding_registers(30775,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] all = format(value1, '04x') + format(value2, '04x') wr3w = int(struct.unpack('>i', all.decode('hex'))[0]) -#pv Wh +# pv Wh resp= client3.read_holding_registers(30529,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] all = format(value1, '04x') + format(value2, '04x') wr3wh = int(struct.unpack('>i', all.decode('hex'))[0]) - -#pv watt +# pv watt resp= client2.read_holding_registers(30775,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] @@ -58,7 +58,7 @@ f.write(str(final)) f.close() -#pv Wh +# pv Wh resp= client2.read_holding_registers(30529,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] @@ -68,9 +68,3 @@ f = open('/var/www/html/openWB/ramdisk/pvkwh', 'w') f.write(str(final)) f.close() - - - - - - diff --git a/modules/wr_tripower9000/tri90004.py b/modules/wr_tripower9000/tri90004.py index 9df4a7d1e..1d09626fd 100755 --- a/modules/wr_tripower9000/tri90004.py +++ b/modules/wr_tripower9000/tri90004.py @@ -1,68 +1,67 @@ #!/usr/bin/python import sys -import os -import time -import getopt -import socket -import ConfigParser +# import os +# import time +# import getopt +# import socket +# import ConfigParser import struct -import binascii +# import binascii +from pymodbus.client.sync import ModbusTcpClient + ipaddress = str(sys.argv[1]) ip2address = str(sys.argv[2]) ip3address = str(sys.argv[3]) ip4address = str(sys.argv[4]) -from pymodbus.client.sync import ModbusTcpClient client = ModbusTcpClient(ipaddress, port=502) client2 = ModbusTcpClient(ip2address, port=502) client3 = ModbusTcpClient(ip3address, port=502) client4 = ModbusTcpClient(ip4address, port=502) - - - -#pv watt +# pv watt resp= client.read_holding_registers(30775,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] all = format(value1, '04x') + format(value2, '04x') wr1w = int(struct.unpack('>i', all.decode('hex'))[0]) -#pv Wh + +# pv Wh resp= client.read_holding_registers(30529,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] all = format(value1, '04x') + format(value2, '04x') wr1wh = int(struct.unpack('>i', all.decode('hex'))[0]) -#pv watt +# pv watt resp= client3.read_holding_registers(30775,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] all = format(value1, '04x') + format(value2, '04x') wr3w = int(struct.unpack('>i', all.decode('hex'))[0]) -#pv Wh + +# pv Wh resp= client3.read_holding_registers(30529,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] all = format(value1, '04x') + format(value2, '04x') wr3wh = int(struct.unpack('>i', all.decode('hex'))[0]) -#pv watt + +# pv watt resp= client4.read_holding_registers(30775,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] all = format(value1, '04x') + format(value2, '04x') wr4w = int(struct.unpack('>i', all.decode('hex'))[0]) -#pv Wh + +# pv Wh resp= client4.read_holding_registers(30529,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] all = format(value1, '04x') + format(value2, '04x') wr4wh = int(struct.unpack('>i', all.decode('hex'))[0]) - - - -#pv watt +# pv watt resp= client2.read_holding_registers(30775,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] @@ -76,7 +75,7 @@ f.write(str(final)) f.close() -#pv Wh +# pv Wh resp= client2.read_holding_registers(30529,2,unit=3) value1 = resp.registers[0] value2 = resp.registers[1] @@ -86,9 +85,3 @@ f = open('/var/www/html/openWB/ramdisk/pvkwh', 'w') f.write(str(final)) f.close() - - - - - - diff --git a/modules/wr_victron/main.sh b/modules/wr_victron/main.sh index f51e7a7d6..6542d260b 100755 --- a/modules/wr_victron/main.sh +++ b/modules/wr_victron/main.sh @@ -1,8 +1,4 @@ #!/bin/bash -# - - - python /var/www/html/openWB/modules/wr_victron/victron.py $pv1_ipa pvwatt=$( 5 )); then fi echo $pvwatt echo $pvwatt > /var/www/html/openWB/ramdisk/pvwatt - echo $pvkwh > /var/www/html/openWB/ramdisk/pvkwh -#Gesamtz‰hlerstand am WR [kWh] +# Gesamtzählerstand am WR [kWh] pvkwh=$(echo "$pvkwh/1000" |bc) echo $pvkwh > /var/www/html/openWB/ramdisk/pvkwhk