MQTT send control issues

For general Flowcode discussion that does not belong in the other sections.
Post Reply
RGV250
Posts: 441
http://meble-kuchenne.info.pl
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 46 times
Been thanked: 45 times

MQTT send control issues

Post by RGV250 »

Hi,
I have modified the Environmental monitoring and control example and it is working fine sending the data from the ESP32 to the web app. Unfortunately I cannot figure out what is going wrong in the other direction, when i try the original example it seems worse as every message seems to reboot the ESP32.
In my attempt it does not reboot the ESP32 but the data is always zero. The debug messages output on the web app shows what I think it the correct message. The issue seems to be in the ESP32 code, I have put lots of debug messages in to see where it is failing and that seems to be the Index has a value of -1 so it never gets to the decode macro.

This is what I see in the serial monitor, all seems to be what I would expect until the -1 as the "Decision" is looking for Index >= 0
These are for each click on the radio buttons.
mtx_demo_switchdata
Success
{"AvgCfg":66}
-1
IndexFailed

mtx_demo_switchdata
Success
{"AvgCfg":67}
-1
IndexFailed

mtx_demo_switchdata
Success
{"AvgCfg":19}
-1
IndexFailed

mtx_demo_switchdata
Success
{"AvgCfg":67}
-1
IndexFailed

This is where I think the issue is.
FC.jpg
FC.jpg (63.75 KiB) Viewed 55 times
WebApp_MQTT_Client_EcoEye5C.fcweb
(78.9 KiB) Downloaded 7 times
ESP_MQTT_Client_EcoEye3D.fcfx
(60.86 KiB) Downloaded 8 times
Any help would help with hair loss :lol:

Regards,
Bob

BenR
Matrix Staff
Posts: 2171
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 592 times
Been thanked: 780 times

Re: MQTT send control issues

Post by BenR »

Hi Bob,

I think this is your problem. Its being passed a variable which is empty but this should be the string of the data tag your looking for.

Img1.jpg
Img1.jpg (14.45 KiB) Viewed 48 times

Should instead look like this with quotation marks around the tag.

Img2.jpg
Img2.jpg (21.21 KiB) Viewed 48 times

RGV250
Posts: 441
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 46 times
Been thanked: 45 times

Re: MQTT send control issues

Post by RGV250 »

Hi Ben,
First off, thanks for the incredibly quick reply and even better that it worked.

I must have looked at all the code around there hundreds of time yesterday and I did not see it.

I do have an issue with this though (hopefully I don't sound ungrateful), I think FC should have picked this up as an error.
When I selected the variable it was from the dropdown list so FC knew it was a string being selected (and the type it was expecting should be a string) so it would be nice if the quote marks are added or an error shown if the quote marks are missing.

Regards,
Bob

Steve-Matrix
Matrix Staff
Posts: 1844
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 268 times
Been thanked: 432 times

Re: MQTT send control issues

Post by Steve-Matrix »

Hi Bob,

Flowcode cannot pick this up as an error. Passing a literal string "abc" will search for that name. Passing a variable will search for the *value* of that variable. There are legitimate times when you might want to pass a variable (for example, there may be multiple "Name0", Name1" , etc values you are trying to find and you can use a variable to create the string each time).

You passed a string variable, and so Flowcode (quite rightly) assumed you wanted to search for the value of that string variable (which, because you have not set it, is actually blank).

Post Reply