which MQTT format is used with which firmware

There are 11 replies in this Thread which was already clicked 379 times. The last Post () by MycroftVonLipwig.

  • Currently i use the 1PM with factory firmware


    i have heared that newer shellies(with newer firmware) switched from several mqtt topics to 1 big topic with everything in it.


    so from several topics:

    shellies/shelly1pm-xxxxxxxx/relay/0

    shellies/shelly1pm-xxxxxxxx/relay/0/power

    shellies/shelly1pm-xxxxxxxx/relay/0/power/energy


    to something like this(did not see the actual string so interpreting)


    {

    "Relay" : On,

    "LastUpdate" : "2021-12-07 17:39:07",

    "power" : 8,

    "description" : "shelly1pm-xxxxxxxx",

    "energy" : 150,


    }


    fromj what firmware levels will this new stringtype be implemented or is it only implemented with different series like the plus series

  • the new MQTT format is valid for all Gen2 devices: Plus and the Pro series

    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

  • yep, the old Shelly 1PM is not affected by these changes. don't worry..

    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

  • Hi,


    Isn't it possible to switch the Shelly Plus 1PM back to the old multiple-topics MQTT format?

    I'm using HomeBridge with the mqttthing plugin and it's hard to manipulate JSON.


    Thanks,

    pHiL

  • Hi again,


    If not, how can I get the status of the switch with a single request?

    In other words, the equivalent of gen1 API: shellies/<model>-<deviceid>/relay/0


    Tx,

    pHiL

  • I finally found a way to get the on/off status based on the "apower" property of the notifications:


                "topics": {
                    "getOnline": "shellyplus1pm-XXXXXXXXXXXX/online",
                    "getOn": {
                        "topic": "shellyplus1pm-XXXXXXXXXXXX/events/rpc",
                        "apply": "if(message.includes('apower')) { return JSON.parse(message).params['switch:0'].apower==0 ? 'false' : 'true'; }"
    },
                    "setOn": {
                        "topic": "shellyplus1pm-XXXXXXXXXXXX/rpc",
                        "apply": "return JSON.stringify({id:1, src:'shellyplus1pm-XXXXXXXXXXXX', method:'Switch.Toggle', params:{id:0}})"
    }
    },
                "onlineValue": "true",
                "onValue": "true",

                "offValue": "off",



    Gen2 device API is really a step back compared to v1!
    Look at how easy it was with API v1 (below) compared to API v2 (above):


                "topics": {
                    "getOnline": "shellies/shelly1-XXXXXXXXXXXX/online",
                    "getOn": "shellies/shelly1-XXXXXXXXXXXX/relay/0",
                    "setOn": "shellies/shelly1-XXXXXXXXXXXX/relay/0/command"
    },
                "onlineValue": "true",
                "onValue": "on",
                "offValue": "off",


    As indicated in this article, using a single topic for all messages is an anti pattern of MQTT.


    Best,

    pHiL

  • I am 100% with you. I only recently installed two different Shelly switches, one Shelly 1L and another Shelly 1Plus, the latter supposedly being a 2nd generation device. The MQTT messaging on the 1L device is miles superior to the one on the 1Plus. I have yet to figure out how to get subscribe to a simple notification once the relay comes on. The webhooks integration also doesn't work. I am using the same URL on both devices, and only the 1L actually triggers the webhook. This is really annoying to say the least. I really don't want much, just the ability to detect when the device switches state in realtime.


  • Thankyou so much for this! works perfectly though I agree, it should not be required if MQTT standards were adhered to or at least consistency with their own product lines that came before. Just an option switch for MQTT Classic or JSON payload would be fine.


    I wonder if it is possible to create a script that monitors the states and publishes to MQTT with desired format. Why the prefix "shellie" was also dropped is infuriating also as I have various other topics and not being able to filter on shellies/# but subscribe to # just to see if the new devices are publishing is not ideal.

  • Spoke too soon, for some reason it stopped working so currently using:

    Code
                "topics": {
                    "getOnline": "Shelly/online",
                    "getOn": "Shelly/status/input:0"
                },
                "onValue": "{\"id\":0,\"state\":true}",
                "offValue": "{\"id\":0,\"state\":false}",

    Which seems to work.


    Had to enable "Generic status update over MQTT" on the Shelly Plus 1 but closer to what it used to be with out the need for the apply:. I only need to know when the switch is physically toggled for my use case so have not tried setON.

  • [talking about Gen2 / Plus 1PM]


    Ah, wanted to chime in and say something about a setting for notifications. I think you can change the prefixes so your shelly's would be filterable, according to the configuration page:

    topic_prefix, putting that to 'shellies/<number>' should work (?).


    MQTT | Shelly Technical Documentation
    The MQTT component handles configuration and status of the outbound MQTT connection. Here, you can find how to configure your device to connect to an MQTT…
    shelly-api-docs.shelly.cloud


    The setting for notifications is false by default, but you found that one. status_ntf

    Edited once, last by yaMMer: forum section ().

  • The topic prefix is configurable in the GUI too (0.9.1>), though not labelled, in Mqtt settings under the connection type and server field. What I found out is you can use a forward slash in that topic prefix which means you can have shellies/devicefreindlyname as the topic prefix and when troubleshooting subscribe to shellies/# to see all gen 1 and gen 2 devices.


    Code
    {"enable":true,"server":"192.168.x.x","user":null,"pass":null,"topic_prefix":"shellies/BedRoomShelly","rpc_ntf":true,"status_ntf":true}

    roc is also in the GUI as a switch and so is ntf (generic) but neither give a nice gen 1 like experience, the experience why I ditched all ZWAVE modules and went All-In on Shelly. Gen 2 MQTT is a total cop out. Hopefully they will read these threads and implement at least the option to use proper MQTT not JSON nonsense.


    I will now go scourer the document you posted Lin to, to see if I can find any useful bits! Thanks!

    I did not think to look at the api guide for config but there may be something missing from the GUI that is only available by api.