Skip to content

Commit

Permalink
Merge pull request #169 from markt-asf/add-inverter-map
Browse files Browse the repository at this point in the history
Add an inverter serial <-> inverter type map
  • Loading branch information
johanmeijer authored Nov 2, 2022
2 parents 5b0c25b + c30ef8b commit 83530c5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions grottconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def __init__(self, vrm):
self.decrypt = True
self.compat = False
self.invtype = "default" #specify sepcial invertype default (spf, sph)
self.invtypemap = {}
self.includeall = False #Include all defined keys from layout (also incl = no)
self.blockcmd = False #Block Inverter and Shine configure commands
self.noipf = False #Allow IP change if needed
Expand Down Expand Up @@ -200,6 +201,7 @@ def print(self):
print("\tdecrypt: \t",self.decrypt)
print("\tcompat: \t",self.compat)
print("\tinvtype: \t",self.invtype)
print("\tinvtypemap: \t",self.invtypemap)
print("\tinclude_all: \t",self.includeall)
print("\tblockcmd: \t",self.blockcmd)
print("\tnoipf: \t",self.noipf)
Expand Down Expand Up @@ -360,6 +362,7 @@ def procconf(self):
if config.has_option("Generic","compat"): self.compat = config.getboolean("Generic","compat")
if config.has_option("Generic","includeall"): self.includeall = config.getboolean("Generic","includeall")
if config.has_option("Generic","invtype"): self.invtype = config.get("Generic","invtype")
if config.has_option("Generic","invtypemap"): self.invtypemap = eval(config.get("Generic","invtypemap"))
if config.has_option("Generic","inverterid"): self.inverterid = config.get("Generic","inverterid")
if config.has_option("Generic","blockcmd"): self.blockcmd = config.get("Generic","blockcmd")
if config.has_option("Generic","noipf"): self.noipf = config.get("Generic","noipf")
Expand Down Expand Up @@ -427,6 +430,7 @@ def procenv(self):
if os.getenv('gcompat') != None : self.compat = self.getenv('gcompat')
if os.getenv('gincludeall') != None : self.includeall = self.getenv('gincludeall')
if os.getenv('ginvtype') != None : self.invtype = self.getenv('ginvtype')
if os.getenv('ginvtypemap') != None : self.invtypemap = eval(self.getenv('ginvtypemap'))
if os.getenv('gblockcmd') != None : self.blockcmd = self.getenv('gblockcmd')
if os.getenv('gnoipf') != None : self.noipf = self.getenv('gnoipf')
if os.getenv('gtime') in ("auto", "server") : self.gtime = self.getenv('gtime')
Expand Down
24 changes: 23 additions & 1 deletion grottdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,28 @@ def procdata(conf,data):
if conf.compat is False:
# new method if compat = False (automatic detection):

if (conf.invtype == "default") :
# Handle systems with mixed invtype
if (ndata > 50) :
# There is enough data for an inverter serial number
inverterType = "default"

inverterSerial = result_string[76:96]
inverterSerial = codecs.decode(inverterSerial, "hex").decode('utf-8')
if conf.verbose:
print("\t - Possible Inverter serial", inverterSerial)

# Lookup inverter type based on inverter serial
try:
inverterType = conf.invtypemap[inverterSerial]
print("\t - Matched inverter serial to inverter type", inverterType)
except:
inverterType = "default"
print("\t - Inverter serial not recognised - using inverter type", inverterType)

if (inverterType != "default") :
layout = layout + inverterType.upper()

if conf.verbose:
print("\t - " + 'Growatt new layout processing')
print("\t\t - " + "decrypt : ",conf.decrypt)
Expand Down Expand Up @@ -633,4 +655,4 @@ def procdata(conf,data):
##print("\t -", ext_result)
else:
if conf.verbose : print("\t - " + "Grott extension processing disabled ")

0 comments on commit 83530c5

Please sign in to comment.