🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Subscribing to MQTT doesn't work

    UIFlow
    2
    8
    9.7k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      lederschnautz
      last edited by

      Hi everyone

      I'm new to m5stacks and uiFlow and hope someone could help me.

      I want my m5stack to subscribe to the MQTT Topic of my smart mailbox and react somehow when a letter was delivered. I use Mosquitto as my broker which is an addon to Home Assistant.

      As a quick test I did the following in uiFlow. I want the RGB turn green when the payload "arrived" is picked up in the topic "mailbox/action".
      0_1589066138399_f6044632-8412-4901-aa74-1bfc3b52c881-image.png

      The publish part works fine, I can pick up the readings of the ENV Unit inside Home Assistant. What doesn't work is the subscribe part, i can't pick up anything with my m5stack. If i subscribe to to the topic inside Home Assistant to check it, it works.
      0_1589066213292_ccce12c5-c3d4-4b5f-aff5-4ac885359664-image.png

      Thanks for letting me know if there is some error in the code or you know what else could be wrong.

      1 Reply Last reply Reply Quote 0
      • world101W
        world101
        last edited by world101

        What are you using to send the payload "arrived" to the mailbox/action topic?

        Edit: never mind, now I see you published with mosquito in the second pic. I’m running the same setup, so let me do a test.

        1 Reply Last reply Reply Quote 0
        • L
          lederschnautz
          last edited by

          Thanks.
          Yes, to test it I sent the payload via the publish feature inside HA. Of course, the goal would be, that the payload is sent by the esp32 in my mailbox (DFrobot Firebeetle). This is working fine, as I have other automations inside HA that react to the "arrived" payload.

          1 Reply Last reply Reply Quote 0
          • world101W
            world101
            last edited by

            You can read through this thread to see some limitations with M5Stack and MQTT.

            Do you know if HA Mosquitto adds the retain flag by default on publish?

            1 Reply Last reply Reply Quote 0
            • L
              lederschnautz
              last edited by

              I read some parts of this thread yesterday. ; ) I couldn't figure out whether the retain flag is set or not. But I tried it as well in the services tab where I set "retain: false" and it sadly didn't change a thing.
              I thought that I probably have another problem, as most people in that thread only had problems with subscribing to multiple topics, no?

              1 Reply Last reply Reply Quote 0
              • world101W
                world101
                last edited by

                Looking at your flow again, I don’t see the “mqtt start” block. Drag that into your flow just below the MQTT connection details and hopefully that fixes it.

                L 1 Reply Last reply Reply Quote 0
                • L
                  lederschnautz @world101
                  last edited by

                  @world101
                  Thank you very much, that fixed it!!! Many many thanks.

                  world101W 1 Reply Last reply Reply Quote 0
                  • world101W
                    world101 @lederschnautz
                    last edited by

                    @lederschnautz

                    Great. Glad I could help.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post