One button code lock
Moderators: grovkillen, Stuntteam, TD-er
One button code lock
Can someone help me get started with a single button code (un)lock. It must activate a relay.
Re: One button code lock
I think you have to be a bit more specific...
What are you thinking of?
One of those 1-Wire i-button key chains?
Or pressing a specific sequence using a normal button?
What are you thinking of?
One of those 1-Wire i-button key chains?
Or pressing a specific sequence using a normal button?
Re: One button code lock
Ahh, I am searching for a one button (un)lock after finishing a button- push sequence. It it is the wrong sequence, the relay must be blocked for a some time. If is as an add-on for my current door openen (extra safety). As you mentioned, a 1 wire solution is also a possibility but I don't know how that works.
Re: One button code lock
Thos w-Wire buttons are like a key chain with something at the end which looks a lot like a coin cell battery.
You can press those against some contacts and then it will transmit a specific ID.
The protocol on the wire is like those 18b20 temperature sensors.
A button push sequence may be a bit tricky to implement as it is quite hard to not make it frustrating to use.
Problem with mechanical switches (especially when used with longer cables) is that they don't make a firm single contact.
They often "bounce" a bit.
So you need to implement some filtering (either in software or via some capacitor, or both) to reject short bounce signals.
However when requiring a tapping sequence you probably need quite a short pulse, but also not accept noise.
That makes it hard to make it right.
The switch plugin can be configured to output different events for short and long pulses.
However when making a long pulse, you also get the event for a short pulse.
This makes capturing a specific sequence of long and short pulses rather complex.
See also:
https://espeasy.readthedocs.io/en/lates ... management
https://espeasy.readthedocs.io/en/lates ... management
You could make something like 4 short pulses and 1 large pulse like this:
You can press those against some contacts and then it will transmit a specific ID.
The protocol on the wire is like those 18b20 temperature sensors.
A button push sequence may be a bit tricky to implement as it is quite hard to not make it frustrating to use.
Problem with mechanical switches (especially when used with longer cables) is that they don't make a firm single contact.
They often "bounce" a bit.
So you need to implement some filtering (either in software or via some capacitor, or both) to reject short bounce signals.
However when requiring a tapping sequence you probably need quite a short pulse, but also not accept noise.
That makes it hard to make it right.
The switch plugin can be configured to output different events for short and long pulses.
However when making a long pulse, you also get the event for a short pulse.
This makes capturing a specific sequence of long and short pulses rather complex.
See also:
https://espeasy.readthedocs.io/en/lates ... management
https://espeasy.readthedocs.io/en/lates ... management
You could make something like 4 short pulses and 1 large pulse like this:
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
// Do stuff like switching a relay to open a door, etc.
// for example: longpulse,N,1,<duration>
// See: https://espeasy.readthedocs.io/en/latest/Plugin/P000_Relay.html?highlight=longpulse#commands
endif
endon
on rules#timer=1 do
let,1,0 // Clear counter
endon
Re: One button code lock
Thos w-wire is New for me button in Google I cant't find anything. The other solution is alsof possible because rhe wires are short button behoren implementing something I want to read more abortus the w-wire switch. Do you have a link?
Re: One button code lock
That's a typo, should be 1-wire: https://www.google.com/search?q=dallas+1-wire+button
/Ton (PayPal.me)
Re: One button code lock
Is the security of the button comparable to the rfid dongle? You hear more and more that rfid drops are easy to crack by a code generator, holding near the reader. Is that also the case with the 1 wire option?
Re: One button code lock
You have to have electrical access to the button.
It isn't RF.
That doesn't mean it is truly safe.
The ESPEasy plugin for these only reads the unique serial number, which is relatively easy to clone.
The button itself does allow for some extra memory and if I'm not mistaken also some other security features like password protected memory. But that's not implemented in ESPEasy.
Maybe the best protection of those is that they are fairly unknown
It isn't RF.
That doesn't mean it is truly safe.
The ESPEasy plugin for these only reads the unique serial number, which is relatively easy to clone.
The button itself does allow for some extra memory and if I'm not mistaken also some other security features like password protected memory. But that's not implemented in ESPEasy.
Maybe the best protection of those is that they are fairly unknown

Re: One button code lock
More like security by obsolescence
Re: One button code lock
Thanks guys, I know if someone wants to do bad things, no security system will stop that. I will order a 1 wire button for testen purpose and deside later what to implement and how. I also test the phisical button solution and test the debounching problemen. Enough for New experiences 

Re: One button code lock
Maybe order a few of them, so you can also test to reject another key.
Re: One button code lock
I received my 1 wire reader and buttons. Installed the latest firmware on my esp8266 and connected the data line of the reader to GPIO 12 and the other wire to gnd. Also added a 4.7k pull-up resister to the 3.3v of the esp. A port number is generated (01-a3-be-8c-01-00-00-b5 [DS1990A]). Now the problem, I push one of the buttons to the reader and nothing happens, log log, nothing. I did not load the i buttons with a serial but assume that something is loaded already. non of the 7 ibuttons show the same result. Any idea what went wrong?
Re: One button code lock
Also no event is generated?
Re: One button code lock
no event was generated and forgot to mention that I selected the 1 wire Dalles sensor from the dropdown
Re: One button code lock
Which plugin exactly?
It isn't the temperature sensor plugin.
It should be the "Switch input - iButton" (plugin P080)
This one should be available in "Collection A" builds.
It isn't the temperature sensor plugin.
It should be the "Switch input - iButton" (plugin P080)
This one should be available in "Collection A" builds.
Re: One button code lock
I selected the Environment - 1-Wire Temperature
I searched for the correct device and found it in the test set A. I gona test it now. To be continued!
I searched for the correct device and found it in the test set A. I gona test it now. To be continued!
Re: One button code lock
At least you know the iButton is working and properly connected, when the temperature plugin can 'see' it 

Re: One button code lock
ha ha, it is all logic. You are right, it working but this is what I see
and this is repeating. What can I do with the info of the key found and how can i Stop the continuing searching for keys. The intervan is set to 60 .752422: DS : iButton searching for address: 0f-ff-8f-47-0e-00-00-f7 [] found:
752522: DS : iButton searching for address: 0f-ff-8f-47-0e-00-00-f7
Re: One button code lock
Hmm now you assume I know how that plugin is working...
I just took a look at the code and noticed it is programmed to be a rather ... interesting design.
You should have the iButton present when opening the web interface page for that task and select the right key from the found devices.
Then save it.
It will be scanned 10x per second to see if that button is present.
When it is present or no longer present, it will generate an event when its detected state has changed since the last PLUGIN_READ call (every N seconds set as "Interval")
To be honest, that's a rather strange design decision as you need to have it pressed for > 1 second to have the event.
And I'm not even mentioning the probably high CPU load of how it is implemented.
I just took a look at the code and noticed it is programmed to be a rather ... interesting design.
You should have the iButton present when opening the web interface page for that task and select the right key from the found devices.
Then save it.
It will be scanned 10x per second to see if that button is present.
When it is present or no longer present, it will generate an event when its detected state has changed since the last PLUGIN_READ call (every N seconds set as "Interval")
To be honest, that's a rather strange design decision as you need to have it pressed for > 1 second to have the event.
And I'm not even mentioning the probably high CPU load of how it is implemented.
Re: One button code lock
That's probably because these iButtons are (often) used the same way as a RFID tag, the 1 second hold-time is probably to be sure it's not triggered by accident, when quickly swiping the button close to the reader.TD-er wrote: ↑05 Jul 2023, 21:26 It will be scanned 10x per second to see if that button is present.
When it is present or no longer present, it will generate an event when its detected state has changed since the last PLUGIN_READ call (every N seconds set as "Interval")
To be honest, that's a rather strange design decision as you need to have it pressed for > 1 second to have the event.
/Ton (PayPal.me)
Re: One button code lock
But why not then generate an event when it is being scanned?
You need to make contact for a while, it isn't RF-ID.
And performing a full search to see what is present... 10x per second for each task you make to support multiple keys... is not really smart programming.
You need to make contact for a while, it isn't RF-ID.
And performing a full search to see what is present... 10x per second for each task you make to support multiple keys... is not really smart programming.
Re: One button code lock
the discussion doesn't give me the impression if the iButton solution is a good oe. I am afraid that it will influence the overall performance of the other devices. I have to test that. Now I made an event. As soon as a certain key with ID (according the log "01-a3-be-8c-01-00-00-b5 [DS1990A]" is read, a test switch must be set to "0".
Result: the key was read successful but the switch did not change. Also tried this id without the "[DS1990A]" but the result was the sam.
Code: Select all
on iButton#All do // %eventvalue% is the actual value that triggered the event
if %eventvalue1%=01-a3-be-8c-01-00-00-b5 [DS1990A]// ibutton to be found
GPIO,13,0 //test switch
else
gpio,13,1
endif
endon
Code: Select all
on iButton#All do // %eventvalue% is the actual value that triggered the event
if %eventvalue1%=01-a3-be-8c-01-00-00-b5// ibutton to be found
GPIO,13,0 //test switch
else
gpio,13,1
endif
endon
Re: One button code lock
You need to add a single asterisk * in the on iButton#All* do line, so the first argument isn't checked for being numeric, like this:
Code: Select all
on iButton#All* do // %eventvalue% is the actual value that triggered the event
if %eventvalue1%=01-a3-be-8c-01-00-00-b5 // ibutton to be found
GPIO,13,0 //test switch
else
gpio,13,1
endif
endon
/Ton (PayPal.me)
Re: One button code lock
It isn't setting the key, but only a 1 or 0 for that specific task.
So imagine you have a task named "dick60" and you name its task value "present", then the event will be something like this:
I suggested to use your name as task name here, as I can assume a specific key being personal.
So imagine you have a task named "dick60" and you name its task value "present", then the event will be something like this:
Code: Select all
dick60#present=1
Re: One button code lock
I cannot follow this, I keep the first event iButton#All* and create another event called Dick60#present like this
but where is the connection with the first event?
Code: Select all
on dick60#present=1 do
gpio,13,1
else
gpio,13,0
endof
endon
Re: One button code lock
You got the syntax wrong:
Or even simpler:
Code: Select all
on dick60#present do
if %eventvalue1%=1
gpio,13,1
else
gpio,13,0
endif
endon
Code: Select all
on dick60#present do
gpio,13,%eventvalue1%
endon
Re: One button code lock
hum, still struggling. This is what I have but see that the first event has the switch 13 . This cannot work in my opinion. I know, I do something wrong but what?
Code: Select all
on iButton#All* do // %eventvalue% is the actual value that triggered the event
if %eventvalue1%=01-a3-be-8c-01-00-00-b5 // Above this voltage the loader is turned on
GPIO,13,1
else
GPIO,13,0
endif
endon
on dick60#present do
if %eventvalue1%=1
gpio,13,1
else
gpio,13,0
endif
endon
Re: One button code lock
How is the ibutton task being called and what is its task value being called?
Can you get the exact event from the logs?
Can you get the exact event from the logs?
Re: One button code lock
this is what is in the log "EVENT: test#All=0" and that is the only one,
Re: One button code lock
So the task is named "test" and you have checked the checkbox to combine it all in one event?
Re: One button code lock
I feel dom, The name of the iBotton is Device: Input - iButton name: test and values: iButton. I only have the 2 scripts as mentioned before. Combine??? I have not see that option
Re: One button code lock
The task name is the name you can give to a task yourself...
That's why I suggested "dick60" as taskname.
But if you have named it "test" that's fine.
The value named "iButton" is also fine.
Just make sure the "Single event with all values:" is unchecked.
So the event will then be: test#iButton.
When that checkbox ("Single event with all values:") is checked, the event will be: test#All
So then we end up with this:
That's why I suggested "dick60" as taskname.
But if you have named it "test" that's fine.
The value named "iButton" is also fine.
Just make sure the "Single event with all values:" is unchecked.
So the event will then be: test#iButton.
When that checkbox ("Single event with all values:") is checked, the event will be: test#All
So then we end up with this:
Code: Select all
on test#iButton do
if %eventvalue1%=1
gpio,13,1
else
gpio,13,0
endif
endon
Re: One button code lock
but this part of reading the value of the key, where is that placed?
if %eventvalue1%=01-a3-be-8c-01-00-00-b5
Re: One button code lock
That was a misconception in my previous response
, the event is called with the result of the state from the button that is selected in the task (you can only pick 1 of the addresses, other iButtons won't respond).
Also, the task should generate an event when the state changes, so from 0 to 1 or from 1 to 0. And that new 0/1 state is the value of %eventvalue1%.
As you can only select 1 iButton-address in the task, only that iButton will be handled, other iBottons presented to the reader will not cause any events.
To be able to handle multiple iButtons with a single task, or a large(-ish) number of iButtons (you can only have 12 tasks on an ESP8266, or 32 on an ESP32 based ESPEasy), the plugin code needs to be changed changed (as might be a good idea anyway, as TD-er pointed out before).

Also, the task should generate an event when the state changes, so from 0 to 1 or from 1 to 0. And that new 0/1 state is the value of %eventvalue1%.
As you can only select 1 iButton-address in the task, only that iButton will be handled, other iBottons presented to the reader will not cause any events.
To be able to handle multiple iButtons with a single task, or a large(-ish) number of iButtons (you can only have 12 tasks on an ESP8266, or 32 on an ESP32 based ESPEasy), the plugin code needs to be changed changed (as might be a good idea anyway, as TD-er pointed out before).
/Ton (PayPal.me)
Re: One button code lock
I tested this solution and works fine but I prefer to wait for a better solution because I do not like the limitations of 1 button. I can buy some RW buttons but a reader to give them the same ID, is quit expensive and if it is correct, you only use it once, during the RW activity.THanks for this discussion! Hope a better solution is presented soon 

Re: One button code lock
You can create a second task with the same plugin (and a different task name) where you select a different tag.
Re: One button code lock
I wanted to test the last remark of the second ibutton. It works perfect. 2 Different ibuttons, 1 reader and 2 diffrent events. Thanks for the solution. I probably build it on an esp32 because of the cpu load.
Re: One button code lock
Not sure if that will make a lot of difference here (ESP32 vs ESP8266) as it isn't a CPU-cycles problem, but a poor design choice based on lots of timeouts.
I will try to have a look at it later this weekend...
I will try to have a look at it later this weekend...
Re: One button code lock
I would appreciate that but also enjoy the nice weather 

Re: One button code lock
tomorrow will have rain (I hope..)
Re: One button code lock
is there any development in the code optimalisation
Re: One button code lock
Nope, not yet.
Have been busy looking into a memory leak which makes units reboot after only days...
Have been busy looking into a memory leak which makes units reboot after only days...
Re: One button code lock
Just curious if there is any development in the optimalisation of the code? No hurry but still interested!
Re: One button code lock
Not yet, as I have been focussing on energy meters in the last 2 months (and stability issues)
But good to have a reminder, as I have to admit, it kinda slipped my mind.
But good to have a reminder, as I have to admit, it kinda slipped my mind.
Re: One button code lock
Still no time for checking the code? No hurry but only a reminder.
Re: One button code lock
Nope not yet, have been extremely busy with other stuff I really didn't wanted to spend time on....
Re: One button code lock
No problem, See it as a reminder. 

Re: One button code lock
Here my reminder for the Ibutton. I know you have more to do but again, it is a reminder 

Re: One button code lock
I try to implement the 1 button solution mentioned earlier. It is a good temporary solution for my Ibutton. I implemented on on esp8266 with the latest firmware. In the log I get this error:
5332292: ACT : (restricted) restrict,1=11 and 1=3
5332297: Command unknown: 1=11 and 1=3
5332300: ACT : let,1,0
5332305: ACT : GPIO,12,0
5332308: GPIO: port#12: set to 0
5332838: SW : LongPress: GPIO= 14 State=0 Output value=11
5332844: EVENT: switch#State=11
5332860: Rules : Prefix command with 'restrict': restrict,11=11 and 0=3
Any Idea?
The code of the pushbutton script:
5332292: ACT : (restricted) restrict,1=11 and 1=3
5332297: Command unknown: 1=11 and 1=3
5332300: ACT : let,1,0
5332305: ACT : GPIO,12,0
5332308: GPIO: port#12: set to 0
5332838: SW : LongPress: GPIO= 14 State=0 Output value=11
5332844: EVENT: switch#State=11
5332860: Rules : Prefix command with 'restrict': restrict,11=11 and 0=3
Any Idea?
The code of the pushbutton script:
Code: Select all
5332292: ACT : (restricted) restrict,1=11 and 1=3
5332297: Command unknown: 1=11 and 1=3
5332300: ACT : let,1,0
5332305: ACT : GPIO,12,0
5332308: GPIO: port#12: set to 0
5332838: SW : LongPress: GPIO= 14 State=0 Output value=11
5332844: EVENT: switch#State=11
5332860: Rules : Prefix command with 'restrict': restrict,11=11 and 0=3
Who is online
Users browsing this forum: Bing [Bot] and 17 guests