Mqtt/Pico/W WHEN event block

Issue #332 resolved
Hans Braakmann created an issue

Could it be that the WHEN hat block is not working correctly under the Pilot version of MicroBlocks.

Two scripts: one works the other doesn’t execute the WHEN hat block.

Thank you.

Comments (13)

  1. John Maloney repo owner

    "when <condition>" hats must be running in order to respond to their conditions.

    You can start all the "when <condition>" hats by clicking the green arrow or you can click on individual "when <condition>" hats to start or stop them. When running, a green halo will appear around the script. Are you seeing that green halo around all your "when <condition>" hats?

  2. Hans Braakmann reporter

    That’s the problem for my first script as seen above. In script one the variable state on/off doesn't get executed under the [When_state = on] hat block. The [if statement] in script 2 in contrary to script 1 does work. I find this curious…is it not?

  3. John Maloney repo owner

    Yes, that is definitely curious. Does it start working if you click the stop button and then the green arrow to restart all the scripts?

    I tried to reproduce this problem with a simple test case that doesn't use MQTT. At first it appeared to work as expected but after running for 30-45 minutes the "when" hats stopped responding. So it looks like there is a bug but it's not easy to reproduce.

    Which microcontroller board are you using?

  4. John Maloney repo owner

    Thanks! There is a bug. It's subtle and hard to reproduce but I think I'm on its track...

  5. John Maloney repo owner

    Found the bug! It was a task scheduling issue that was sometimes triggered by the WiFi connection primitive -- but only when the connection process took over a certain amount of time, which made it hard to reproduce. The fix will be in the next Pilot release, which should be out by early next week.

  6. Hans Braakmann reporter

    Thanks, I will give it a try when the next Pilot release is available. I having second thoughts on the When hat block will trigger the mqtt state variable. When reading through your experiences the When block stopped working after some time, while in my case the When block never got triggered. Keeping my fingers crossed. Thank you.

  7. Hans Braakmann reporter

    Tested it with sending mqtt messages to neopixels connected to the Pico/W …and the when hat block now works and fires like a charm. Thank you.

  8. Log in to comment