tkurki / signalk-mqtt-gw

Signal K server plugin that provides gateway functionality between Signal K and MQTT
Apache License 2.0
14 stars 7 forks source link

Offer device discovery broadcast over MQTT #45

Open GraffJosh opened 1 month ago

GraffJosh commented 1 month ago

This one might be a bit out of scope of this plugin, but home assistant offers automatic device configuration using discovery broadcast topics. Right now I'm faking it by broadcasting them FROM home assistant with the requisite details.

It might be too home assistant specific to be worth implementing, but it would make it a lot easier to use with other tools.

tkurki commented 1 month ago

Can you provide more details? Certainly doable i would think.

tkurki commented 1 month ago

See also https://github.com/SignalK/signalk-server/issues/1374#issuecomment-1955036156

GraffJosh commented 1 month ago

Yeah, this might be a rework of the Homeassistant plugin, though I haven't had success with it just yet. The idea is that HA is looking for a JSON string that describes the device. In the case of SK, this would probably define the 'vessel' (and all subtopics) as the device, and the subtopics as sensors on that device:

Some information here: https://www.home-assistant.io/integrations/sensor.mqtt/#:~:text=Or%20set%20up%20via%20MQTT%20discovery

Some more information on the 'device' concept on this forum: https://community.home-assistant.io/t/creating-a-device-with-multiple-sensor-entities-via-mqtt-discovery/584372/4?

It looks like each sensor gets a mqtt discovery JSON pub, and the device tag in that JSON package links them together.

GraffJosh commented 1 month ago

Per your comment, I have HA reading the sensors quite well, configured individually in the HA yaml config, but they aren't capable of being device-grouped in that method, and all units and metadata have to be configured manually.

I haven't yet sent data from HA to SK, but from what I've seen that might be straightforward, I'll try it in a few weeks.

tkurki commented 1 month ago

This is certainly doable, but probably nontrivial. It would be great if somebody who uses SK and HA both actively would pick this up so that real world testing is included in the development loop.

I can provide generic assistance.