In my LAN there are several MQTT-enabled devices (Tasmota) and I am writing an MQTT client (Javascript, through mosquitto websocket and PAHO client library).
Which is the best way to discover all online devices in the LAN and their corresponding device name? I thought using the LWT message that every device sends, but I don't know how to subscribe to all LWT message from unknown devices.
The LWT "Online" messages are coming through with this path: tele/<device_name>/LWT
, but I don't want to subscribe to ALL "tele" messages, as they are too many.
You can use single level wildcard topics.
e.g.
tele/+/LWT
This will get you all the topics that start with tele
and end with LWT
with only on element in the middle.