Page 2 of 2

Re: One button code lock

Posted: 26 Oct 2023, 11:30
by Ath
Why is this in your log?

Code: Select all

Command unknown: 1=11 and 1=3
Something strange in your rules?

Re: One button code lock

Posted: 26 Oct 2023, 12:31
by Dick60
Thanks for the tip, I checked the code and now is this part working.
I typed Elseif and not Else if.
Here the correct code

Code: Select all

on Switch#State do
 if %eventvalue1%=1
 let,1,[int#1]+1 // Count pulses
    timerset,1,1 // Set timer to clear the counter    
  else
  if  %eventvalue1%=11 and [int#1]=3
    // Accept the code
    let,1,0 // Clear counter
   GPIO,12,0
  endif
  endif
endon

on rules#timer=1 do
  let,1,0 // Clear counter
endon

Re: One button code lock

Posted: 26 Oct 2023, 16:57
by Dick60
Is it possible, instead of counting only the button pushes, to sum the value of the GPIO. For example: 2 short and 2 long results in a 24 (1+1+11+11) so I can do something with the value of the sum and the number or pushes. (switch on an led or something. This is my setup, sofar. The problem is that GPIO,12,0 is not executed. I see both the long and short pulses, the reset of the Variables by Timer 1 but no execution of GPIO,2,0.

Code: Select all

on Switch#State do
 if %eventvalue1%=1
 let,1,[int#1]+1 // Count pulses
    timerset,1,1 // Set timer1 to clear the counter    
  else
if  %eventvalue1%=11
let,2,[int#2]+1 //Count long press 
timerset,1,1
else
  if  [int#2]=2 and [int#1]=5 //2 long and 3 short
    // Accept the code
    let,1,0 // Clear counter 1
    let,2,0 // Clear counter 2
   GPIO,12,0
timerset,2,5 //Set timer 2 to turn off led
  endif
  endif
  endif
endon 

on rules#timer=1 do
  let,1,0 // Clear counter 1
  let,2,0 //Clear counter 2
endon

on rules#timer=2 do
  GPIO,12,1 
endon

Re: One button code lock

Posted: 27 Oct 2023, 11:25
by Dick60
After a lot of testing, the final script is working . I played with the timer and this is the final working solution:

Code: Select all

on Switch#State do
 if %eventvalue1%=1
 let,1,[int#1]+1 // Count pulses
    timerset,1,3 // Set timer to clear the counter    
  elseif %eventvalue1%=11
let,2,[int#2]+1 //sum long press 
timerset,1,3
else
  if  [int#2]=1 and [int#1]=2 //1 long and 1 short
    // Accept the code
    let,1,0 // Clear counter
    let,2,0 // Clear counter
   GPIO,12,0
timerset,2,5
  endif
  endif
endon 

on rules#timer=1 do
  let,1,0 // Clear counter
  let,2,0
endon

on rules#timer=2 do
  GPIO,12,1 
endon

Re: One button code lock

Posted: 25 Nov 2023, 11:27
by Dick60
Is there already some time for reviewing and optimization of the E-button plugin? If not, see it as a reminder.

Re: One button code lock

Posted: 16 Apr 2024, 08:01
by Dick60
Anyone time for optimizing the Ibutton plugin?

Re: One button code lock

Posted: 10 May 2024, 22:31
by Ath
@Dick60 I've added a PR that should resolve your issues, it adds an event <taskname>#Address,<state>[,<address_high>,<address_low>] when the new option Event with iButton address is enabled and the Device Address is set to None.

A test-build can be obtained from this GH Actions run

Please report your findings here ;)

Re: One button code lock

Posted: 11 May 2024, 19:02
by Dick60
At the moment I am not in the position to test the solution but next week, I share my findings. Thanks in advanced.