Hi TD-er,
thanks for replying.
My configuration:
Using Wemos D1 mini - 4MB - V3.0.0
Firmware: Mega, v2.0-20180217
MQTT: OpenHab 2.1
All push buttons and relays defined in DEVICES as "Switch input - PCF8574".
The situation is the following:
I want to use two push button to activate two relays for raising and lowering a window blind.
So the logic will be:
- push button 1 (UP)
- if blind is moving up stop it
- if blind is moving down, stop down and move up for 10 seconds
- if blind is still, move blind up for 10 seconds
- push button 2 (DOWN)
- if blind is moving stop it
- if blind is moving up, stop up and move down for 10 seconds
- if blind is still, move blind up for 10 seconds
In order to control 3 blinds from a single ESP8266, I am using 2x 8574A port expander (12 PINS in total).
One for push buttons and one for controlling relays.
The problem is the following:
I press PUSH BUTTON 1 and blinds move up.
I immediately press again PUSH BUTTON 1 (within 1 second) and nothing happens (it should stop the blind)
I press again PUSH BUTTON 1 (after 2 or 3 seconds) and the the blind stops.
In other words, after pressing the PUSH BUTTON for the first time (changing the state from 1 to 0), the push button does not respond for 2 or 3 seconds and then it responds again.
Looking in the DEBUG LOG it seems that the rule itself is executed in 891 ms, then 643 ms are due to MQTT and finally the state of the GPIO is changed after another 662 ms.
Total of 2.2 seconds.
So the GPIO changes back from 0 to 1 only AFTER 2.2 seconds, even if I have released the push button immediately.
And after another 682ms the blind stops. Total of almost 3 seconds. Too much in case of an emergency.
Code:
Code: Select all
On System#Boot do
PCFGPIO,65,1 //push up
PCFGPIO,66,1 //push down
PCFGPIO,73,1 //relay up
PCFGPIO,74,1 //relay down
taskvalueset 2,1,1 //InputPush0
taskvalueset 3,1,1 //InputPush1
taskvalueset 4,1,1 //Relay0
taskvalueset 5,1,1 //Relay1
endon
on InputPush0#state=0 do
if [Relay0#state]=1 // if relay UP=OFF
PCFGPIO,74,1 //stop down
delay 200 //to avoid risk of sending double command
PCFLongPulse,73,0,10 //start up for 10 seconds
PCFGPIO,65,1 // reset push button
else
PCFGPIO,73,1 //stop up
PCFGPIO,74,1 //stop down
PCFGPIO,65,1 // reset push button
endif
endon
on InputPush1#state=0 do
if [Relay1#state]=1 // if relay DOWN=OFF
PCFGPIO,73,1 //stop up
delay 200 //to avoid risk of sending double command
PCFLongPulse,74,0,10 //start down for 10 seconds
PCFGPIO,66,1 // reset push button
else
PCFGPIO,73,1 //stop up
PCFGPIO,74,1 //stop down
PCFGPIO,66,1 // reset push button
endif
endon
Code: Select all
LOG:
02-19-2018 22:22:53 Kernel.Debug 192.168.1.219 ESP9 EspEasy: WD : Uptime 127 ConnectFailures 0 FreeMem 17112
02-19-2018 22:22:53 Kernel.Debug 192.168.1.219 ESP9 EspEasy: UDP : Send Sysinfo message
02-19-2018 22:22:54 Kernel.Debug 192.168.1.219 ESP9 EspEasy: PCF : State 0
02-19-2018 22:22:54 Kernel.Debug 192.168.1.219 ESP9 EspEasy: EVENT: InputPush0#state=0.00
02-19-2018 22:22:54 Kernel.Debug 192.168.1.219 ESP9 EspEasy: ACT : PCFGPIO,74,1
02-19-2018 22:22:54 Kernel.Debug 192.168.1.219 ESP9 EspEasy: PCF : GPIO 74 Set to 1
02-19-2018 22:22:54 Kernel.Debug 192.168.1.219 ESP9 EspEasy: ACT : delay 200
02-19-2018 22:22:54 Kernel.Debug 192.168.1.219 ESP9 EspEasy: ACT : PCFLongPulse,73,0,10
02-19-2018 22:22:54 Kernel.Debug 192.168.1.219 ESP9 EspEasy: PCF : GPIO 73 Pulse set for 10 S
02-19-2018 22:22:54 Kernel.Debug 192.168.1.219 ESP9 EspEasy: ACT : PCFGPIO,65,1
02-19-2018 22:22:54 Kernel.Debug 192.168.1.219 ESP9 EspEasy: PCF : GPIO 65 Set to 1
02-19-2018 22:22:55 Kernel.Debug 192.168.1.219 ESP9 EspEasy: EVENT: Processing time:891 milliSeconds
02-19-2018 22:22:55 Kernel.Debug 192.168.1.219 ESP9 EspEasy: MQTT : /ESP9/InputPush0/state 0
02-19-2018 22:22:55 Kernel.Debug 192.168.1.219 ESP9 EspEasy: PCF : State 0
02-19-2018 22:22:55 Kernel.Debug 192.168.1.219 ESP9 EspEasy: EVENT: Relay0#state=0.00
02-19-2018 22:22:55 Kernel.Debug 192.168.1.219 ESP9 EspEasy: EVENT: Processing time:643 milliSeconds
02-19-2018 22:22:55 Kernel.Debug 192.168.1.219 ESP9 EspEasy: MQTT : /ESP9/Relay0/state 0
02-19-2018 22:22:55 Kernel.Debug 192.168.1.219 ESP9 EspEasy: MQTT : Topic: /ESP9/InputPush0/state
02-19-2018 22:22:55 Kernel.Debug 192.168.1.219 ESP9 EspEasy: MQTT : Payload: 0
02-19-2018 22:22:55 Kernel.Debug 192.168.1.219 ESP9 EspEasy: PCF : State 1
02-19-2018 22:22:55 Kernel.Debug 192.168.1.219 ESP9 EspEasy: EVENT: InputPush0#state=1.00
02-19-2018 22:22:56 Kernel.Debug 192.168.1.219 ESP9 EspEasy: EVENT: Processing time:662 milliSeconds
02-19-2018 22:22:56 Kernel.Debug 192.168.1.219 ESP9 EspEasy: MQTT : /ESP9/InputPush0/state 1
02-19-2018 22:22:56 Kernel.Debug 192.168.1.219 ESP9 EspEasy: MQTT : Topic: /ESP9/Relay0/state
02-19-2018 22:22:56 Kernel.Debug 192.168.1.219 ESP9 EspEasy: MQTT : Payload: 0
02-19-2018 22:22:56 Kernel.Debug 192.168.1.219 ESP9 EspEasy: PCF : State 0
02-19-2018 22:22:56 Kernel.Debug 192.168.1.219 ESP9 EspEasy: EVENT: InputPush0#state=0.00
02-19-2018 22:22:57 Kernel.Debug 192.168.1.219 ESP9 EspEasy: ACT : PCFGPIO,73,1
02-19-2018 22:22:57 Kernel.Debug 192.168.1.219 ESP9 EspEasy: PCF : GPIO 73 Set to 1
02-19-2018 22:22:57 Kernel.Debug 192.168.1.219 ESP9 EspEasy: ACT : PCFGPIO,74,1
02-19-2018 22:22:57 Kernel.Debug 192.168.1.219 ESP9 EspEasy: PCF : GPIO 74 Set to 1
02-19-2018 22:22:57 Kernel.Debug 192.168.1.219 ESP9 EspEasy: ACT : PCFGPIO,65,1
02-19-2018 22:22:57 Kernel.Debug 192.168.1.219 ESP9 EspEasy: PCF : GPIO 65 Set to 1
02-19-2018 22:22:57 Kernel.Debug 192.168.1.219 ESP9 EspEasy: EVENT: Processing time:682 milliSeconds