Control by MQTT

  • Hi,

    I have successfully connect my PLUS 1PM to my broker. (screenshot 1)

    All I want to do with this device is to activate and deactivate the relay by MQTT. All the other things I don't need. I will also never subscribe to any topic of this device.

    But I find as good as NO info about the topic and payload to do this.

    What I did found is that the topic should be: shellies/zwembad/relay/0/command and the payload simply on or off

    But this does not work.

    I do receive messages, but on completely different topic structures (screenshot 2)

    Do I need to do scripting to get started with MQTT controlling the device?

    Long story short: I have 1 (new) shelly device, what is the topic and payload to control the relay?

    Thanks

    Der Inhalt kann nicht angezeigt werden, da Sie keine Berechtigung haben, diesen Inhalt zu sehen.

    Der Inhalt kann nicht angezeigt werden, da Sie keine Berechtigung haben, diesen Inhalt zu sehen.
  • example for mosquitto_pub, message (-m) has to be JSON.

    Code
    mosquitto_pub -h localhost -p 1883 -u admin -P admin -t zwembad/rpc -m '{"id":124, "src":"zwembad", "method":"Switch.Set", "params":{"id":0,"on":true}}'

    >100 Shellies, darunter so gut wie alles was der Hersteller produziert hat. ;)
    :!: ich beantworte grundsätzlich keine Fragen per persönlicher Nachricht:!:

    Einmal editiert, zuletzt von Seven of Nine (17. Juli 2022 um 08:37)

  • Thanks,
    you have put me on the right way.

    The documentation is really confusing, but finally, with copy-past and a lot of testing I found the right topic and payload.

    Topic: zwembad/rpc ==> Where zwembad is the configured device name, don't forget the /rpc
    Payload: {"id":1, "src":"PFC100", "method": "Switch.Set", "params":{"id":0,"on":true} } ==> Where the first ID and SRC is something you choose, this comes back in the confirmation message.

    This can be closed

    Der Inhalt kann nicht angezeigt werden, da Sie keine Berechtigung haben, diesen Inhalt zu sehen.

  • Thanks,
    you have put me on the right way.

    The documentation is really confusing, but finally, with copy-past and a lot of testing I found the right topic and payload.

    Topic: zwembad/rpc ==> Where zwembad is the configured device name, don't forget the /rpc
    Payload: {"id":1, "src":"PFC100", "method": "Switch.Set", "params":{"id":0,"on":true} } ==> Where the first ID and SRC is something you choose, this comes back in the confirmation message.

    This can be closed

    Der Inhalt kann nicht angezeigt werden, da Sie keine Berechtigung haben, diesen Inhalt zu sehen.

    Hello,

    i am trying for some hours to do the same - switching the relay from MQTT, but it does not work.

    in my opinion i am using the same "order" as Nick - but the relay does not switch...

    is there anything else to configure on the ShellyPlus1PM?

    Code
    mosquitto_pub -t 'shellyTest/rpc' -m '{"id":124, "src":"shellyTest","method":"Switch.Set", "params":{"id":0,"on":true}}'

    with the http commands it works fine - both possibilites known to me work:

    Code
    http://192.168.2.xxx/relay/0?turn=on
    http://192.168.2.xxx/rpc/Switch.Set?id=0&on=true

    getting status infos like power and energy via mqtt works also fine only relay switching does not...

    thynk you for your help,

    Karl

  • Additional Information:

    Every Shelly device publishes and subscribes to specific preset topics, such as "command/switch:0" or "shellys/command..." You can control your Shelly devices by sending your commands to these specific topics. For "command/switch:0," your payload should consist of "on" , "off" or "toggle". All Shelly devices are listening to the "shellys/command" topic, so publishing commands there can be useful for executing bash commands like updating all devices, and nice other purposes.

    Der Inhalt kann nicht angezeigt werden, da Sie keine Berechtigung haben, diesen Inhalt zu sehen.

    I initially searched for instructions on how to use them and stumbled upon this post. However, through some trial and error, I managed to make it work. I hope that anyone who finds themselves in a similar situation through a Google search can now save some time. ;)

    Einmal editiert, zuletzt von _[Deleted]_ (25. September 2023 um 08:41)