johanmeijer / grott

Growatt inverter monitor
https://github.com/johanmeijer/grott/wiki
398 stars 113 forks source link

Crash with SDM630 + influx #214

Open egguy opened 2 years ago

egguy commented 2 years ago

Hi,

There's a crash of grott if influxDB is activated and there's an SDM630, I use the 6.7.7 branch.

Traceback (most recent call last):
  File "grott/grott.py", line 35, in <module>
    proxy.main(conf)
  File "grottproxy.py", line 144, in main
    self.on_recv(conf)
  File "grott/grottproxy.py", line 238, in on_recv
    procdata(conf,data)    
  File "grott/grottdata.py", line 590, in procdata
    "measurement" : definedkey["pvserial"],

The config is as follows:

[Generic]
# Specify verbose for extended messaging
verbose = True
invtype=default
invtypemap = {"REH1B1700D": "tl3", "NWCOA44008": "sph"}

[influx]
# Influxdb parameters definitions

influx = False

The problem seems to be coming from the missing pvserial key which is not present in the record file from grottconf.py.

Here is the code:

a=b"""\x00\x01\x00\x06\x01\x69\x50\x1b\x09\x33\x2c\x42\x20\x46\x4c\x77\x35\x2a\x77\x61\x74\x74\x47\x72\x6f\x77\x61\x74\x74\x47\x72\x6f\x77\x61\x74\x74\x47\x72\x6e\x34\x74\x78\x68\x54\x71\x73\x76\x5e\x4d\x4d\x69\x4a\x5d\x5b\x52\x4c\x5a\x72\x4a\x43\x45\x56\x40\x5a\x73\x5e\x56\x4f\x4f\x40\x58\x75\x41\x59\x59\x54\x58\x59\x74\x45\x41\x4f\x4d\x59\x43\x70\x5c\x5b\x5b\x4c\x41\x46\x69\x4b\x43\x45\x56\x4c\x5a\x7f\x5e\x5e\x45\x53\x5a\x45\x6b\x40\x5c\x42\x4f\x42\x58\x77\x5c\x56\x5b\x51\x5a\x43\x6b\x42\x41\x4e\x4d\x46\x47\x73\x5c\x5e\x5b\x53\x47\x41\x69\x44\x43\x45\x52\x41\x5a\x75\x5e\x5e\x59\x50\x58\x44\x69\x47\x43\x47\x4f\x4d\x58\x72\x4b\x5e\x59\x53\x58\x42\x76\x4a\x41\x40\x4d\x59\x45\x70\x46\x41\x44\x4d\x44\x5a\x7e\x5e\x5b\x4e\x4f\x4c\x58\x7f\x44\x41\x45\x4d\x45\x47\x69\x44\x43\x45\x4f\x46\x58\x74\x44\x41\x44\x4d\x45\x44\x70\x5c\x5f\x5b\x55\x46\x5a\x77\x5e\x5d\x42\x4f\x42\x58\x74\x40\x41\x46\x4d\x45\x45\x69\x45\x43\x46\x53\x5a\x4c\x6b\x43\x5c\x59\x58\x58\x45\x74\x4a\x41\x43\x50\x58\x40\x77\x44\x41\x4e\x4d\x40\x44\x70\x5c\x57\x5b\x55\x44\x42\x69\x44\x43\x47\x4f\x44\x58\x77\x5c\x5f\x5b\x51\x5a\x44\x6b\x42\x41\x47\x4d\x44\x5a\x77\x5e\x5f\x59\x51\x58\x44\x69\x42\x43\x47\x4f\x44\x58\x77\x5c\x5f\x5b\x51\x5a\x44\x6b\x42\x41\x47\x4d\x44\x5a\x77\x5e\x5f\x59\x51\x58\x44\x69\x42\x43\x47\x4f\x44\x58\x77\x5c\x5f\x5b\x51\x5a\x44\x6b\x42\x41\x47\x4d\x44\x5a\x77\x5e\x5f\x59\x51\x58\x44\x69\x42\x43\x47\x4f\x44\x58\x77\x5c\x5f\x5b\x51\x5a\x44\x6b\x42\x41\x47\x4d\x44\x5a\x77\x5e\x4d\xf7"""
from grottconf import Conf
from grottdata import procdata
conf = Conf("2.7.7")
procdata(conf, a)
johanmeijer commented 2 years ago

Yes make sence. Pvserial is the key for adding a measurement in influxdb. The SDM630 layout definition does not has a PVSerial in it. I hard coded a device key (with SDM630) in it, but that is not used with influxdb yet.

As temp solution we can create a layout definition with a pvserial key (next to device) in it. I will look for a more permanent solution in the code (in my head it was already there, I do not know anymore why have not implemented it yet).

e.g.

 "pvserial"                : {"value": "SDM630","type" : "def","incl" : "yes"},