Page 1 of 1

ESPEasy - Device=PushButton - Delays of feedback [ISSUE FIXED]

Posted: 17 Oct 2016, 10:29
by papperone
Hi, I've been running this issue since I started using ESPEasy and I cannot find a way to solve it even looking at the code.
I setup a push button (physically attached to GPIO13/D7 to one of my unit) as per below:
Image

No matter what I setup (I tried literally everythign!) once I press the button I've an immediate change of its status to "1" that is triggering a relay.
But it takes around 1300ms (as per below screeshot) after I release the button until the device status is back to 0; this means if someone push the button meanwhile nothing happens!!!
Image

How can I have immediate reset of device status once button is released?
I've a virtual switch on node-red that sends on/off command to the same relay and this is perfectly working and I can send command once after the other without delays or lags.
If anyone can help or address me to the right piece of code handling this behaviour I'll be very thankfull...

Re: ESPEasy - Device=PushButton - Delays of feedback

Posted: 18 Oct 2016, 10:32
by papperone
Am I the only one with this problem?
Isn't there any other user using ESPEasy to get input from a physical push-button?

Re: ESPEasy - Device=PushButton - Delays of feedback

Posted: 18 Oct 2016, 13:31
by moelski
Hi !

EVENT: indicates that you are using Rules ...
And the Rules are only fired once a second. Look at the code:

Code: Select all

void runOncePerSecond()
{
.....
  if (Settings.UseRules)
    rulesTimers();
I think that is your missing second ... And while the runOncePerSecond has to do a lot other stuff ... You end up with 1300ms ...

I suppose :ugeek:

Re: ESPEasy - Device=PushButton - Delays of feedback

Posted: 18 Oct 2016, 14:45
by papperone
moelski wrote:Hi !

EVENT: indicates that you are using Rules ...
And the Rules are only fired once a second. Look at the code:

Code: Select all

void runOncePerSecond()
{
.....
  if (Settings.UseRules)
    rulesTimers();
I think that is your missing second ... And while the runOncePerSecond has to do a lot other stuff ... You end up with 1300ms ...

I suppose :ugeek:
Thanks moelski, this indeed makes sense...
Now the issue is how to fix it :( I will give a thought this evening once back home...

Re: ESPEasy - Device=PushButton - Delays of feedback

Posted: 19 Oct 2016, 11:31
by moelski
Hi !
Now the issue is how to fix it
Good question 8-)

* You could move the rule handling in the 100ms timer...
* You can add a custom timer for rules ... (I have done that with my Wifi Candle. It uses 40Hz update rate ...)
* Maybe write a plugin that don´t depend on rules ...

I think there are quit a few options. But most of them need coding ... :roll:

Re: ESPEasy - Device=PushButton - Delays of feedback

Posted: 19 Oct 2016, 11:56
by papperone
Coding is the less of my worries :) I just want make sure I choose the best option with minimal impact for me.
I guess the safest is to write my own plugin so I will disconnect from all the rules while maintaininig easy upgrate to future version of ESPEasy, but I do like as well the custom timer option...

I need further testing as I do believe there are other sources of delays, in the way the switch is handled in ESPEasy actual code, but it's just a sensation that needs to be confirmed or not looking to the code!

Will keep you updated on the evolution...

Re: ESPEasy - Device=PushButton - Delays of feedback

Posted: 20 Oct 2016, 07:48
by papperone
moelski wrote:* You can add a custom timer for rules ... (I have done that with my Wifi Candle. It uses 40Hz update rate ...)
Can you elaborate a bit more on this? Maybe shareing your wifi candle code will help me to leverage this technique and try to implement it for my push button handling...

Re: ESPEasy - Device=PushButton - Delays of feedback

Posted: 26 Oct 2016, 17:50
by Martinus
papperone wrote:Hi, I've been running this issue since I started using ESPEasy and I cannot find a way to solve it even looking at the code.
I setup a push button (physically attached to GPIO13/D7 to one of my unit) as per below:
Image

No matter what I setup (I tried literally everythign!) once I press the button I've an immediate change of its status to "1" that is triggering a relay.
But it takes around 1300ms (as per below screeshot) after I release the button until the device status is back to 0; this means if someone push the button meanwhile nothing happens!!!
Image

How can I have immediate reset of device status once button is released?
I've a virtual switch on node-red that sends on/off command to the same relay and this is perfectly working and I can send command once after the other without delays or lags.
If anyone can help or address me to the right piece of code handling this behaviour I'll be very thankfull...
This could be due to the default 1000 mSec delay after sending stuff to your controller. Try what happens if you set it to 0.

Re: ESPEasy - Device=PushButton - Delays of feedback

Posted: 26 Oct 2016, 20:09
by papperone
Martinus wrote: This could be due to the default 1000 mSec delay after sending stuff to your controller. Try what happens if you set it to 0.
I am not sure I understand. I don't see any delay parameter in the controller setup I have when I connect to ESPEasy device. Can you help clarify?

PS in RC firmware the footer should be changed to new domain instead of www.esp8266.nu

Re: ESPEasy - Device=PushButton - Delays of feedback

Posted: 26 Oct 2016, 22:08
by Martinus
Check this setting in tools/advanced menu:

Message Delay (ms):

defaults to 1000 but can be lowered. This could be the delay that you're experiencing.

Re: ESPEasy - Device=PushButton - Delays of feedback

Posted: 27 Oct 2016, 11:11
by papperone
Martinus wrote:Check this setting in tools/advanced menu:

Message Delay (ms):

defaults to 1000 but can be lowered. This could be the delay that you're experiencing.
Thanks Martinus, that was it! I admit I've never realize there was such parameter in the Advanced Tab.
FYI bringing it to 0 did not work as the button behaviour was faster but unstable, with lots of false event.
With tome trial&error I set it to 100ms, really stable and button reacts real time even with multiple pushes one after the other!

Thanks again, I'll update the title as issue is fixed :D

Re: ESPEasy - Device=PushButton - Delays of feedback [ISSUE FIXED]

Posted: 14 Nov 2017, 23:50
by Domosapiens
Thanks Martinus for this explanation.
I thought this variable was related to MQTT only.

Some of my DS18B20 have an update rate of 500msec (close to the heater), so I tried to lower the message delay to 400msec.
The result was a very spiked memory usage: from normal operation 20300 bytes down to spikes of 14200 and even 12600.
Can you understand why? Is it something to worry about?

Martinus, what will happen with the measurements made every 500msec when the messages to the controller are send only every 1000msec?

@papperone: did you check your memory usage with the 100msec setting?
Thanks
Domosapiens

Re: ESPEasy - Device=PushButton - Delays of feedback [ISSUE FIXED]

Posted: 15 Nov 2017, 06:56
by papperone
Domosapiens wrote: 14 Nov 2017, 23:50 Thanks Martinus for this explanation.
I thought this variable was related to MQTT only.

Some of my DS18B20 have an update rate of 500msec (close to the heater), so I tried to lower the message delay to 400msec.
The result was a very spiked memory usage: from normal operation 20300 bytes down to spikes of 14200 and even 12600.
Can you understand why? Is it something to worry about?

Martinus, what will happen with the measurements made every 500msec when the messages to the controller are send only every 1000msec?

@papperone: did you check your memory usage with the 100msec setting?
Thanks
Domosapiens
I did and I saw no differences... this setting, in my case, was only affecting the reactiveness of some devices (swtiches) that's it...