Closed nadrog closed 11 months ago
InfluxDB 2 has an internal data type per measurement (= Signal K path) that is locked in place when you write the first value.
The plugin uses Signal K schema to try to retrieve the Influx data type to use for each measurement / path. If the schema provides a unit for the path the value is assumed to be a number, otherwise the data type of the JavaScript value is used to derive the Influx data type to use.
The difference is explained by this
> sk.getUnits('vessels.self.notifications.environment.inside.humidity')
undefined
> sk.getUnits('vessels.self.notifications.environment.inside.temperature')
'K'
which seems to me to be a bug in getUnits
implementation.
But I think a better fix would be to assume all values under notifications
are objects and force that data type.
Actually, according to SignalK specification, my example only works because I wrongly used inside.humidity
instead of SignalK's inside.relativeHumidity
. Although, there's some inconsistency here as the spec defines outside.humidity
instead of outside.relativeHumidity
. Also, in SignalK server, the unit for notifications.environment.inside.humidity
is ratio
...
Anyway, in the SignalK spec, there are two matches for vessels.self.notifications.environment.inside.temperature
:
/vessels/<RegExp>/notifications/<RegExp>
: This regex pattern is used for validation of the path of the alarm. No units are defined/vessels/<RegExp>/environment/inside/temperature
: The unit is defined as Kelvin.Based on this, for the complete solution, I would say that
Until this is done, can you implement a workaround and use sk.getUnits
only if path does not match /vessels/<RegExp>/notifications/<RegExp>
?
v1.6.2 should be available shortly.
Just tested it and it works ok. Thanks!
On Fri, Dec 29, 2023 at 4:55 PM Teppo Kurki @.***> wrote:
v1.6.2 should be available shortly.
— Reply to this email directly, view it on GitHub https://github.com/tkurki/signalk-to-influxdb2/issues/47#issuecomment-1872185615, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXQ47ZZW4LRJQT7GZFBN3TYL3RV5AVCNFSM6AAAAABBFLOZHWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZSGE4DKNRRGU . You are receiving this because you authored the thread.Message ID: @.***>
Sending certain notifications throws error: "
Error creating point notifications.environment.inside.temperature:[object Object] => number source:undefined
". This is after I extended the debug to include the source as well.This happens when sending notifications created by Zones plugin, but I was not able to identify the reason.
This case does NOT throw an error:
and creates the following record in InfluxDB2:
{"state":"normal","message":"vlag","method":["visual","sound"],"timestamp":"2023-12-28T10:36:21.348Z"}
All others, like this one, do throw the error above but I fail to see any meaningful distinction.
If this matters, this is running on Nixos 23.11 signalk 2.4.1 is installed with "npm config set prefix /home/user/.npm-apackages" as global install is not supported on Nixos npm is 9.8.1 node is v18.18.2