datenschuft / SMA-EM

SMA Energymeter measurement
GNU General Public License v2.0
95 stars 39 forks source link

influxdb field type conflict #52

Closed mkarg75 closed 3 years ago

mkarg75 commented 3 years ago

I've setup influxdb as a target for smaemd and after a while of smoothless operation, I get this error in the smaemd log:

Mär 29 18:27:03 kryha sma-daemon.py[15123]: Influxdb connected to 'None' @ '127.0.0.1'(SMA)
Mär 29 18:27:03 kryha sma-daemon.py[15123]: InfluxDBError: 400: {"error":"partial write: field type conflict: input field \"pdirectusage\" on measurement \"SMAEM\" is type integer, already exists as type float dropped=1"}
Mär 29 18:27:03 kryha sma-daemon.py[15123]: InfluxDB failed data:18:26:46 [{'measurement': 'SMAEM', 'tags': {'serial': 1901701531}, 'time': '2021-03-29T16:26:46Z', 'fields': {'p2supply': 62.6, 'pconsumecounter': 30439.0556, 'psupplycounter': 9147.1964, 'pbattery': 0.0, 'phouse': 953.9, 'pusage': 953.9, 'p1supply': 0.0, 'pdirectusage': 537, 'p3supply': 0.0, 'psupply': 0.0, 'pconsume': 416.9, 'p1consume': 226.8, 'p3consume': 252.7, 'p2consume': 0.0, 'pvpower': 537.0}}]
Mär 29 18:27:03 kryha sma-daemon.py[15123]: InfluxDB: data skipping

My assumption is that once the value gets low enough, it comes in as an integer, while it used to be a float for larger values. Unfortunately I have no idea how to prevent this from happening, but maybe there's a way to force a data type?

mkarg75 commented 3 years ago

Looks like I got a fix, I'm just not sure yet about the full consequences. I've changed line 153 in influxdb.py so that it reads data['pdirectusage'] = float(pdirectusage) which casts it to a float variable. Looking further in the file, I guess this needs to be repeated for the kostal inverter special treatment as well?

datenschuft commented 3 years ago

thanks - pull request merged