Gen 2 - MQTT discovery

  • Hi,

    I have a question about Gen2 devices discovery via MQTT. In Gen1 devices there was 'shellies/announce' topic in which all devices could be discovered.

    I have problem with Gen2 devices. As far I had figured only via NDS there is possibility to discover devices.

    Do you have any clue how to discover Shelly Gen2 devices via MQTT without using NDS.

    I know that I can subscribe '#' or similar and figure what devices are in network but only Shelly Plus 1PM sends regular traffic via MQTT


  • Hi and welcome to the forum. :)

    If you setup MQTT in every shelly, it send messages to your broker with all datapoints.

  • Hi,


    generally I have no problem with MQTT. The problem is with Gen2 device discovery via MQTT. In Gen2 MQTT is different than Gen1. Take a look here: https://shelly-api-docs.shelly…Overview/RPCChannels#mqtt

    In Gen1 there was one topic shellies/# with announces etc. And every device could be discovered via MQTT (off course only when MQTT was configured). And most of devices were sending once a while messages.

    In Gen2 every device got its own topic, and every client got own topic to. And that works well.


    But Gen2 does not send any announces via MQTT (as far I see) and there are two ways to detect device:
    - use mDNS - which will give you all informations (but works only in LAN and sometimes it take a while to find device)
    - you must know device names - and then try to subscribe proper topics etc.

    And that is the problem - is there any other method to find the device via MQTT...

  • All devices NG are sending state after the reboot.

    That's what i see.

  • From what I know there's currently no announce topic via MQTT but you can customize the topic so you don't have to know the device names at all..


    With this configuration you'd have to subscribe to either #livingroom or #livingroom/ceilinglight as topic.

    1x Shelly4ProPlus, 10x Shelly1, 7x Shelly 1PM, 2xShelly 1L, 9x Shelly 2.5, 3x Shelly2, 1x Shelly EM, 2x ShellyDimmer, 3x ShellyDimmer2, 1x Shelly 3EM, 1x Shelly4Pro, 1x Shelly Button1, 4x Shelly Duo, 1x, ShellyDuo G10, 3x ShellyVintage, 1x Shelly Bulb, 8x ShellyDuoG10RGB, 1x ShellyPlug, 2x ShellyRGBW2, 5x Shelly PlugS. 1x Shelly Sense, 3x Shelly i3, 1x Shelly Gas, 4x Shelly H&T, 1x Shelly Flood, 2x ShellyDoor&Window2, 3x TempAddon, 1x ShellyMotion

  • yeah i have the same exact problem... the common mqtt commands/topic were removed for some reason...

    It makes it really hard to keep code simple... the announce was great to get information programmatically at run time instead of having to know a priori.

    i asked this in the facebook group, let see what they say:

    3) how are you supposed to discover the environment?

    In gen 1 i could simply send "announce" to "/shellies/command" and listen to "/shellies/announce" .. that allowed me to programmatically discover all shellies and therefore to subscribe to the correct topic (which always was /shellies/$id (with $ID being the value reported by the shelly into the announce reply)

    is there anything i can do with gen 2?
    I understand that i can use "Shelly.GetDeviceInfo" but i must know already what topic to listen to, i cannot obviously guess it, and i cannot learn it ...

    am i missing something ?
    what was the rationale behind the decision to remove those "common" topics? they were absolutely important in my opinion.. i would love to see them coming back in the near future

  • Hi everyone,
    I answered some of the questions of Andres in FB. Let me post here an article we wrote in our docs about MQTT.

    MQTT Setup | Shelly-NG Devices API Docs
    Here is a simple scenario to help you connect your device over MQTT.

    As mentioned by someone else - while setting up Gen2 device a prefix topic can be used. say - LivingRoom. Subscribing to LivingRoom/# will allow you to see all posts there.