tkurki / signalk-to-influxdb2

Apache License 2.0
6 stars 4 forks source link

feature: use data type from signalk-schema #14

Closed tkurki closed 1 year ago

tkurki commented 1 year ago

Use @signalk/signalk-schema.getUnits to derive data type in InfluxDb: if the schema has unit for the path and the unit is not a timestamp force numeric data type in Influxdb.

This will prevent value type related errors where the first value that is written to Influx has a bogus data type and all subsequent values just create errors because the type that ended in Influx is off.

Fixes #7.

ostroesser commented 1 year ago

Hi,

In my case there was a wrong type casting because some value was 'null' the first time the measurement was sent to influxdb This PR will without a doubt fix the type issue; however will null values in input be handled correctly, or will they end up throwing the same type error (inserting string "null" over whichever numeric type the value is) ?

Cheers, Olivier

tkurki commented 1 year ago

Thanks for reminding me about the possibility of nulls. I added a test case for it - the updated logic already kept nulls from being inserted for values with paths in the schema.