Skip to content

Commit

Permalink
2.7.1
Browse files Browse the repository at this point in the history
2.7.1
- Add coding from Pull req #91 (csv export exentsion)
  Add a CSV export extension in the examples/extensions dir. Closes #76

  One CSV file per day is saved.

  extvar configuration:
  "outpath": path where to save CSV files, default: "/home/pi/grottlog"
  "csvheader": comma separated string with fields to store, defaults to all available fields
- Add parameter to enable message retain in MQTT (#84)
  - .ini [MQTT section] retain = True
  - environmental gmqttretain = "True" (docker: -e gmqttretain = "True") 
- Add parameter to enable sent inverter temperature as temperature value to pvoutput (not advised PVOutemp should be outside temperature) Issue #60
  - .ini [PVOutput section] pvtemp = True
  - environmental gpvtemp = "True" (docker: -e gpvtemp = "True")
- Add parameter to disable sending energytoday to pvoutput (disable V1 input). This should show better avarages. Issue: #51  
  - .ini [PVOutput section] pvdisv1 = True
  - environmental gpvdisv1 = "True" (docker: -e gpvdisv1 = "True")
  • Loading branch information
johanmeijer committed Feb 6, 2022
1 parent bd61169 commit 01d693d
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 18 deletions.
20 changes: 19 additions & 1 deletion Version_history.txt
Expand Up @@ -189,4 +189,22 @@ Complement bugfix prepared by KBraham (issue / pull request #41)
- smartmeter topic name can be overridden by:
- mtopicname = <topicname> in .ini [MQTT]
- gmqttmtopicname = "<topicname" environmental
- (b) fix MQTT message is not sent
- (b) fix MQTT message is not sent
2.7.1
- Add coding from Pull req #91 (csv export exentsion)
Add a CSV export extension in the examples/extensions dir. Closes #76

One CSV file per day is saved.

extvar configuration:
"outpath": path where to save CSV files, default: "/home/pi/grottlog"
"csvheader": comma separated string with fields to store, defaults to all available fields
- Add parameter to enable message retain in MQTT (#84)
- .ini [MQTT section] retain = True
- environmental gmqttretain = "True" (docker: -e gmqttretain = "True")
- Add parameter to enable sent inverter temperature as temperature value to pvoutput (not advised PVOutemp should be outside temperature)
- .ini [PVOutput section] pvtemp = True
- environmental gpvtemp = "True" (docker: -e gpvtemp = "True")
- Add parameter to disable sending energytoday to pvoutput (disable V1 input). This should show better avarages. Issue: #51
- .ini [PVOutput section] pvdisv1 = True
- environmental gpvdisv1 = "True" (docker: -e gpvdisv1 = "True")
4 changes: 2 additions & 2 deletions grott.py
Expand Up @@ -10,9 +10,9 @@
#
# For version history see: version_history.txt

# Updated: 2022-01-20'
# Updated: 2022-02-06

verrel = "2.7.0b"
verrel = "2.7.1"

import sys

Expand Down
24 changes: 21 additions & 3 deletions grottconf.py
@@ -1,7 +1,7 @@
#
# grottconf process command parameter and settings file
# Updated: 2022-01-16
# Version 2.7.0a
# Updated: 2022-02-06
# Version 2.7.1

import configparser, sys, argparse, os, json, io
import ipaddress
Expand Down Expand Up @@ -48,6 +48,7 @@ def __init__(self, vrm):
self.mqttauth = False
self.mqttuser = "grott"
self.mqttpsw = "growatt2020"
self.mqttretain = False

#pvoutput default
self.pvoutput = False
Expand All @@ -58,6 +59,8 @@ def __init__(self, vrm):
self.pvinverterid = {}
self.pvsystemid[1] = "systemid1"
self.pvinverterid[1] = "inverter1"
self.pvdisv1 = False
self.pvtemp = False

#influxdb default
self.influx = False
Expand Down Expand Up @@ -216,6 +219,7 @@ def print(self):
print("\tmqtttopic: \t",self.mqtttopic)
print("\tmqttmtopic: \t",self.mqttmtopic)
print("\tmqttmtopicname:\t",self.mqttmtopicname)
print("\tmqtttretain: \t",self.mqttretain)
print("\tmqtttauth: \t",self.mqttauth)
print("\tmqttuser: \t",self.mqttuser)
print("\tmqttpsw: \t","**secret**") #scramble output if tested!
Expand All @@ -225,6 +229,8 @@ def print(self):
print("\tgrowattport: \t",self.growattport)
print("_PVOutput:")
print("\tpvoutput: \t",self.pvoutput)
print("\tpvdisv1: \t",self.pvdisv1)
print("\tpvtemp: \t",self.pvtemp)
print("\tpvurl: \t",self.pvurl)
print("\tpvapikey: \t",self.pvapikey)
print("\tpvinverters: \t",self.pvinverters)
Expand Down Expand Up @@ -328,10 +334,16 @@ def parserset(self):
self.blockcmd = str2bool(self.blockcmd)
self.noipf = str2bool(self.noipf)
self.sendbuf = str2bool(self.sendbuf)
self.pvoutput = str2bool(self.pvoutput)
#
self.nomqtt = str2bool(self.nomqtt)
self.mqttmtopic = str2bool(self.mqttmtopic)
self.mqttauth = str2bool(self.mqttauth)
self.mqttretain = str2bool(self.mqttretain)
#
self.pvoutput = str2bool(self.pvoutput)
self.pvdisv1 = str2bool(self.pvdisv1)
self.pvtemp = str2bool(self.pvtemp)
#
self.influx = str2bool(self.influx)
self.influx2 = str2bool(self.influx2)
self.extension = str2bool(self.extension)
Expand Down Expand Up @@ -364,10 +376,13 @@ def procconf(self):
if config.has_option("MQTT","topic"): self.mqtttopic = config.get("MQTT","topic")
if config.has_option("MQTT","mtopic"): self.mqttmtopic = config.get("MQTT","mtopic")
if config.has_option("MQTT","mtopicname"): self.mqttmtopicname = config.get("MQTT","mtopicname")
if config.has_option("MQTT","retain"): self.mqttretain = config.getboolean("MQTT","retain")
if config.has_option("MQTT","auth"): self.mqttauth = config.getboolean("MQTT","auth")
if config.has_option("MQTT","user"): self.mqttuser = config.get("MQTT","user")
if config.has_option("MQTT","password"): self.mqttpsw = config.get("MQTT","password")
if config.has_option("PVOutput","pvoutput"): self.pvoutput = config.get("PVOutput","pvoutput")
if config.has_option("PVOutput","pvtemp"): self.pvtemp = config.get("PVOutput","pvtemp")
if config.has_option("PVOutput","pvdisv1"): self.pvdisv1 = config.get("PVOutput","pvdisv1")
if config.has_option("PVOutput","pvinverters"): self.pvinverters = config.getint("PVOutput","pvinverters")
if config.has_option("PVOutput","apikey"): self.pvapikey = config.get("PVOutput","apikey")
# if more inverter are installed at the same interface (shinelink) get systemids
Expand Down Expand Up @@ -451,11 +466,14 @@ def procenv(self):
if os.getenv('gmqtttopic') != None : self.mqtttopic = self.getenv('gmqtttopic')
if os.getenv('gmqttmtopic') != None : self.mqttmtopic = self.getenv('gmqttmtopic')
if os.getenv('gmqttmtopicname') != None : self.mqttmtopicname = self.getenv('gmqttmtopicname')
if os.getenv('gmqttretain') != None : self.mqttretain = self.getenv('gmqttretain')
if os.getenv('gmqttauth') != None : self.mqttauth = self.getenv('gmqttauth')
if os.getenv('gmqttuser') != None : self.mqttuser = self.getenv('gmqttuser')
if os.getenv('gmqttpassword') != None : self.mqttpsw = self.getenv('gmqttpassword')
#Handle PVOutput variables
if os.getenv('gpvoutput') != None : self.pvoutput = self.getenv('gpvoutput')
if os.getenv('gpvtemp') != None : self.pvtemp = self.getenv('gpvtemp')
if os.getenv('gpvdisv1') != None : self.pvdisv1 = self.getenv('gpvdisv1')
if os.getenv('gpvapikey') != None : self.pvapikey = self.getenv('gpvapikey')
if os.getenv('gpvinverters') != None : self.pvinverters = int(self.getenv('gpvinverters'))
for x in range(self.pvinverters+1) :
Expand Down
44 changes: 32 additions & 12 deletions grottdata.py
@@ -1,5 +1,6 @@
# grottdata.py processing data functions
# Version 2.7.0b
# Version 2.7.1
# Updated: 2022-02-06

#import time
from datetime import datetime, timedelta
Expand Down Expand Up @@ -100,6 +101,7 @@ def procdata(conf,data):
else:
novalidrec = True

conf.layout = layout
if conf.verbose : print("\t - " + "Record layout used : ", layout)

#Decrypt
Expand Down Expand Up @@ -430,8 +432,12 @@ def procdata(conf,data):
else : mqtttopic = conf.mqtttopic
print("\t - " + 'Grott MQTT topic used : ' + mqtttopic)

try:
publish.single(mqtttopic, payload=jsonmsg, qos=0, retain=False, hostname=conf.mqttip,port=conf.mqttport, client_id=conf.inverterid, keepalive=60, auth=conf.pubauth)
if conf.mqttretain:
if conf.verbose: print("\t - " + 'Grott MQTT message retain enabled')

try:
#v2.7.1 add retrain variable
publish.single(mqtttopic, payload=jsonmsg, qos=0, retain=conf.mqttretain, hostname=conf.mqttip,port=conf.mqttport, client_id=conf.inverterid, keepalive=60, auth=conf.pubauth)
if conf.verbose: print("\t - " + 'MQTT message message sent')
except TimeoutError:
if conf.verbose: print("\t - " + 'MQTT connection time out error')
Expand Down Expand Up @@ -475,11 +481,19 @@ def procdata(conf,data):
pvdata = {
"d" : pvodate,
"t" : pvotime,
"v1" : definedkey["pvenergytoday"]*100,
#2.7.1 "v1" : definedkey["pvenergytoday"]*100,
"v2" : definedkey["pvpowerout"]/10,
"v6" : definedkey["pvgridvoltage"]/10
}
#print(pvheader)
if not conf.pvdisv1 :
pvdata["v1"] = definedkey["pvenergytoday"]*100
else:
if conf.verbose : print("\t - " + "Grott PVOutput send V1 disabled")

if conf.pvtemp :
pvdata["v5"] = definedkey["pvtemperature"]/10

#print(pvdata)
if conf.verbose : print("\t\t - ", pvheader)
if conf.verbose : print("\t\t - ", pvdata)
reqret = requests.post(conf.pvurl, data = pvdata, headers = pvheader)
Expand Down Expand Up @@ -601,16 +615,22 @@ def procdata(conf,data):
except :
if conf.verbose : print("\t - " + "Grott import extension failed:", conf.extname)
return

try:
ext_result = module.grottext(conf,result_string,jsonmsg)
if conf.verbose :
print("\t - " + "Grott extension processing ended : ", ext_result)
except Exception as e:
print("\t - " + "Grott extension processing error ")
print(e)
return

if conf.verbose :
print("\t - " + "Grott extension processing ended : ", ext_result)
#print("\t -", ext_result)
print("\t - " + "Grott extension processing error:", repr(e))
import traceback
traceback.format_exc()
#print("\t - " + "Grott extension processing error ")
#print(e)
#return

#if conf.verbose :
#print("\t - " + "Grott extension processing ended : ", ext_result)
##print("\t -", ext_result)
else:
if conf.verbose : print("\t - " + "Grott extension processing disabled ")

0 comments on commit 01d693d

Please sign in to comment.