SignalK / vedirect-serial-usb

18 stars 14 forks source link

add path for relay state #54

Closed davidsanner closed 1 year ago

davidsanner commented 1 year ago

Access relay state of BMV via path: /signalk/v1/api/vessels/self/electrical/batteries/relay/value

davidsanner commented 1 year ago

Good question - I tried that but the path would look like this which didn't make sense to me. signalk/v1/api/vessels/self/electrical/batteries/*/relay/value

I'm not sure of the best path since we're talking about a relay which can have a variety of uses but definitely associated with the batteries (BMV in my case). If the Victron/BMV device was named in the settings/config-data then it could be used to generate a path something like this: electrical.batteries.vedirect.relay OR electrical.batteries.BMV712.relay

KEGustafsson commented 1 year ago

Path is a template and * replaced by the parser with correct string/value that has been entered to plugin config.

davidsanner commented 1 year ago

I thought that might be the case which is more involved. I'm still not sure what the best generic path would be, maybe something like this? electrical.batteries.bmv..relay electrical.batteries.vedirect..relay or just electrical.batteries.*.relay

btw, my ~/.signalk/plugin-config-data/vedirect-signalk.json seems to have duplicate data for values.

Thanks

KEGustafsson commented 1 year ago

It has to be electrical.batteries.*.relay or similar with different path to support multiple devices, basically there is no other options. Question was gentle hint to correct it ;)

If you put there fixed path, then in case of two or more similar devices, all devices are writing to same path and you see only the data from one device, not from all (latest updating device).

If put there fixed .bmv. and you have e.g. two bmv devices (bmv1 and bmv2), you see the problem... path would be always electrical.batteries.bmv.relay

davidsanner commented 1 year ago

Created new PR with electrical.batteries.*.relay https://github.com/SignalK/vedirect-serial-usb/pull/55