Page 1 of 1

MQTT import - problem

Posted: 16 Feb 2023, 23:07
by giorgino
Hi, I'm using from many time MQTT import to get value from home assitant pushbutton: when the button goes to 1, rules in espeasy call a command PULSE,19,0,500 to command a relay

It was all working good

Then I upgrade to latest espeasy and now when button goes to 1, ESPEASY send two times the PULSE command.

here the RULES:

on LuciP9_a#luce_R=1.00 do
Pulse,5,0,500
endon



and here the LOG:

228203709: IMPT : [LuciP9_a#luce_R] : 1.00
228203710: EVENT: LuciP9_a#luce_R=1
228203725: ACT : Pulse,5,0,500
228204229: GPIO : port 5. Pulse set for 500 ms
228204237: EVENT: LuciP9_a#luce_R=1.00
228204246: ACT : Pulse,5,0,500
228204748: GPIO : port 5. Pulse set for 500 ms



Believe me: with older espeasy it works good

Thank you

Re: MQTT import - problem

Posted: 17 Feb 2023, 09:02
by TD-er
It does seem to receive the event twice.
What I find a bit strange is that you try to match the rule with a floating point value (1.00) instead of an integer value (1)
So maybe the older ESPEasy build didn't match the 1.00 due to a rounding error?
Which version was the older build?

Can you use some tool like MQTT Explorer and let it subscribe to this same topic to see if you do see multiple messages.
I think it is only one, as I only see one "IMPT" message in your logs.
But then I wonder why there are multiple events with different eventvalues.

Do you have multiple MQTT import tasks active? Is it possible multiple tasks can subscribe to the same topic?

Oh and just as a tip, using longpulse (or longpulse_ms) will return immediately and thus not block any code execution on the ESP.
See: https://espeasy.readthedocs.io/en/lates ... ernal-gpio

N.B. In this use case, if you use longpulse (or the msec variant), it may hide this issue/bug, so it may no longer show this behavior.

Re: MQTT import - problem

Posted: 17 Feb 2023, 09:48
by Ath
I think the "Generate events for accepted topics" has to be turned off, because it will now generate duplicate events. first with the incoming "1", and later with "1.00" for the Values event, as that has 2 decimals configured by default.

Re: MQTT import - problem

Posted: 21 Feb 2023, 23:40
by giorgino
thank you ATH, but
I think the "Generate events for accepted topics" has to be turned off, because it will now generate duplicate events. first with the incoming "1", and later with "1.00" for the Values event, as that has 2 decimals configured by default.
give back this

432333775: IMPT : [LuciP9_a#luce_L] : 1.00

without any effect on the rules

Code: Select all

on LuciP9_a#luce_L=1.00 do
Pulse,16,0,500
endon

Re: MQTT import - problem

Posted: 21 Feb 2023, 23:57
by giorgino
now with the trick fron TD-er it works:
433073782: IMPT : [LuciP9_a#luce_L] : 1.00
433073784: EVENT: LuciP9_a#luce_L=1
433073799: ACT : longpulse_ms,16,0,500
433073802: TIMER: disable timer
433073803: GPIO : port 16. Pulse H:500 ms
433073812: EVENT: LuciP9_a#luce_L=1.00
433073819: ACT : longpulse_ms,16,0,500
433073822: TIMER: disable timer
433073822: GPIO : port 16. Pulse H:500 ms
but I think sure it receive the event twice, without any reason....