MQTT import - problem

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
giorgino
Normal user
Posts: 63
Joined: 24 Oct 2022, 21:06

MQTT import - problem

#1 Post by giorgino » 16 Feb 2023, 23:07

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

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MQTT import - problem

#2 Post by TD-er » 17 Feb 2023, 09:02

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.

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: MQTT import - problem

#3 Post by Ath » 17 Feb 2023, 09:48

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.
/Ton (PayPal.me)

giorgino
Normal user
Posts: 63
Joined: 24 Oct 2022, 21:06

Re: MQTT import - problem

#4 Post by giorgino » 21 Feb 2023, 23:40

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

giorgino
Normal user
Posts: 63
Joined: 24 Oct 2022, 21:06

Re: MQTT import - problem

#5 Post by giorgino » 21 Feb 2023, 23:57

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....

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 24 guests