Page 1 of 1

problem with remote control

Posted: 19 May 2019, 11:34
by maystero
Hi!
Sorry for my english. I don't speak very well.
But I will try explain my problem

I have module ESP8266 with ESP EASY (mega-20190511)
To the module is connected LED's
diagram:
https://zapodaj.net/b77b12f1d9907.png.html


I create rule:

Code: Select all

// klawisz_1
on IR_RECEIVER#IR do
  if [IR_RECEIVER#IR]=2049  //
       if [zmienna_1#Switch_1]=0
      TaskValueSet 2,1,1
      else 
      TaskValueSet 2,1,0
    endif
    gpio,14,[zmienna_1#Switch_1]
  endif
//Delay 1000 
Endon
the problem is with the remote controla lot of orders "2049" and the diode has a random status

how fix my rule?

Re: problem with remote control

Posted: 19 May 2019, 13:15
by rayE
I believe you cannot nest multiple if statements, only one is allowed. This may be the problem? Look in debug log, im certain you will see one of those nested if's is ignored?

Ray

Re: problem with remote control

Posted: 19 May 2019, 19:28
by maystero
Log with out DELAY 1000 at RULES

Code: Select all

58713: IRSEND,RAW2,C6C6L6C7C7B7B8B9A8A9A99K9,38,99,88
58748: EVENT: IR_RECEIVER#IR=3268448703
59762: IRSEND,RC5,801
59798: EVENT: IR_RECEIVER#IR=2049
59854: ACT  : TaskValueSet 2,1,1
59863: Command: taskvalueset
59888: ACT  : gpio,14,1
59891: SW   : GPIO 14 Set to 1
60050: SW  : GPIO=14 State=1 Output value=1
60057: EVENT: zmienna_1#Switch_1=1.00
60102: IRSEND,RC5,801
60136: EVENT: IR_RECEIVER#IR=2049
60200: ACT  : TaskValueSet 2,1,0
60210: Command: taskvalueset
60231: ACT  : gpio,14,0
60234: SW   : GPIO 14 Set to 0
60443: SW  : GPIO=14 State=0 Output value=0
60451: EVENT: zmienna_1#Switch_1=0.00
60492: IRSEND,RC5,801
60526: EVENT: IR_RECEIVER#IR=2049
60582: ACT  : TaskValueSet 2,1,1
60592: Command: taskvalueset
60617: ACT  : gpio,14,1
60620: SW   : GPIO 14 Set to 1
60813: SW  : GPIO=14 State=1 Output value=1
60821: EVENT: zmienna_1#Switch_1=1.00
62130: WD   : Uptime 1 ConnectFailures 0 FreeMem 12424 WiFiStatus 3
Log with DELAY 1000 at RULES

Code: Select all

143241: IRSEND,RC5,801
143245: EVENT: IR_RECEIVER#IR=2049
143305: ACT  : TaskValueSet 2,1,0
143315: Command: taskvalueset
143335: ACT  : gpio,14,0
143338: SW   : GPIO 14 Set to 0
143341: ACT  : delay 1000
143350: Command: delay
144511: SW  : GPIO=14 State=0 Output value=0
144518: EVENT: zmienna_1#Switch_1=0.00
144756: IRSEND,RC5,801
144791: EVENT: IR_RECEIVER#IR=2049
144847: ACT  : TaskValueSet 2,1,1
144857: Command: taskvalueset
144882: ACT  : gpio,14,1
144885: SW   : GPIO 14 Set to 1
144887: ACT  : delay 1000
144896: Command: delay
146053: SW  : GPIO=14 State=1 Output value=1
146060: EVENT: zmienna_1#Switch_1=1.00
146102: IRSEND,RC5,801
146136: EVENT: IR_RECEIVER#IR=2049
146196: ACT  : TaskValueSet 2,1,0
146207: Command: taskvalueset
146226: ACT  : gpio,14,0
146229: SW   : GPIO 14 Set to 0
146232: ACT  : delay 1000
146240: Command: delay
147399: SW  : GPIO=14 State=0 Output value=0
147406: EVENT: zmienna_1#Switch_1=0.00
147446: EVENT: Clock#Time=Sun,17:27

Re: problem with remote control

Posted: 20 May 2019, 02:17
by rayE

Re: problem with remote control

Posted: 20 May 2019, 03:40
by rayE
Something like this......................?

Code: Select all

// klawisz_1
on IR_RECEIVER#IR do
   if [IR_RECEIVER#IR]=2049 and [zmienna_1#Switch_1]=0
       TaskValueSet 2,1,1
   else 
       TaskValueSet 2,1,0
       gpio,14,[zmienna_1#Switch_1]
   endif
//Delay 1000 
Endon

Re: problem with remote control

Posted: 20 May 2019, 18:43
by maystero
rayE wrote:
20 May 2019, 03:40
Something like this......................?

Code: Select all

// klawisz_1
on IR_RECEIVER#IR do
   if [IR_RECEIVER#IR]=2049 and [zmienna_1#Switch_1]=0
       TaskValueSet 2,1,1
   else 
       TaskValueSet 2,1,0
       gpio,14,[zmienna_1#Switch_1]
   endif
//Delay 1000 
Endon
Every time is set GPIO 14 Set to 0

Code: Select all

83711098: ACT : TaskValueSet 2,1,0
83711108: Command: taskvalueset
83711127: ACT : gpio,14,0
83711130: SW : GPIO 14 Set to 0
83711296: IRSEND,RC5,801
83711299: EVENT: IR_RECEIVER#IR=2049
83711353: ACT : TaskValueSet 2,1,1
83711363: Command: taskvalueset
83711551: IRSEND,RC5,801
83711554: EVENT: IR_RECEIVER#IR=2049
83711612: ACT : TaskValueSet 2,1,0
83711623: Command: taskvalueset
83711641: ACT : gpio,14,0
83711644: SW : GPIO 14 Set to 0
83711951: IRSEND,RC5,801
83711954: EVENT: IR_RECEIVER#IR=2049
83712008: ACT : TaskValueSet 2,1,1
83712018: Command: taskvalueset
83712205: IRSEND,RC5,801
83712208: EVENT: IR_RECEIVER#IR=2049
83712296: ACT : TaskValueSet 2,1,0
83712306: Command: taskvalueset
83712325: ACT : gpio,14,0
83712327: SW : GPIO 14 Set to 0
dosn't work

Re: problem with remote control

Posted: 21 May 2019, 01:01
by rayE
This follows your original logic without nested if's. If this is not working then check your logic!

Code: Select all

on IR_RECEIVER#IR do
   if [IR_RECEIVER#IR]=2049 and [zmienna_1#Switch_1]=0
       TaskValueSet 2,1,1 
       gpio,14,[zmienna_1#Switch_1]      
   endif  
   
   if [IR_RECEIVER#IR]=2049 and [zmienna_1#Switch_1]=1
       TaskValueSet 2,1,0 
       gpio,14,[zmienna_1#Switch_1]      
   endif  
Endon

Re: problem with remote control

Posted: 21 May 2019, 19:37
by maystero
rayE wrote:
21 May 2019, 01:01
This follows your original logic without nested if's. If this is not working then check your logic!

Code: Select all

on IR_RECEIVER#IR do
   if [IR_RECEIVER#IR]=2049 and [zmienna_1#Switch_1]=0
       TaskValueSet 2,1,1 
       gpio,14,[zmienna_1#Switch_1]      
   endif  
   
   if [IR_RECEIVER#IR]=2049 and [zmienna_1#Switch_1]=1
       TaskValueSet 2,1,0 
       gpio,14,[zmienna_1#Switch_1]      
   endif  
Endon
So, I chcek my logic. Look like OK
At the moment RULE's dosn't work.
LED on the gpio,14 only blinking one time, at all.


Look to the LOG

Code: Select all

486070: EVENT: IR_RECEIVER#IR=2049
486123: ACT : TaskValueSet 2,1,1
486133: Command: taskvalueset
486151: ACT : gpio,14,1
486154: SW : GPIO 14 Set to 1
486158: ACT :
486189: ACT : TaskValueSet 2,1,0
486198: Command: taskvalueset
486216: ACT : gpio,14,0
486219: SW : GPIO 14 Set to 0
486422: IRSEND,RC5,801
486425: EVENT: IR_RECEIVER#IR=2049
486479: ACT : TaskValueSet 2,1,1
486489: Command: taskvalueset
486507: ACT : gpio,14,1
486510: SW : GPIO 14 Set to 1
486514: ACT :
486547: ACT : TaskValueSet 2,1,0
486558: Command: taskvalueset
486603: ACT : gpio,14,0
486606: SW : GPIO 14 Set to 0

Re: problem with remote control

Posted: 21 May 2019, 23:44
by ThomasB
It looks to me that the second IF statement will undo the action of the first IF. So it won't work correctly.

And for accurate help, guys like me need more information to fully understand all the issues. Including screen shots of ESPEasy's device pages so the details can be reviewed. If English language is an issue then the screenshots can say a lot without writing many words.

But for now I'll make my own best-guess assumptions about your project and suggest you try the experimental code shown below. Beware, it is untested (but it can serve as an example).

Code: Select all

On System#Boot do
 let,1,0             // INIT LED STATE FLAG (using System Var)
 gpio,14,[VAR#1]    // D5 LED OFF
endon

on IR_RECEIVER#IR=2049 do
   if %v1%=0      // LED STATE IS CURRENTLY OFF
       let,1,1        // TOGGLE LED STATE ON
   else
       let,1,0        // TOGGLE LED STATE OFF
   endif 
    gpio,14,[VAR#1]  // UPDATE D5 LED PIN.
endon
This example toggles the D5 LED whenever the IR remote sees a new code 2049. It may be necessary to send a different IR code before resending a new code 2049.

- Thomas