This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

1-wire keyfob and reader
#1
Are these 1-wire keyfob and reader supported by the lm4?:
http://shop.loxone.com/enuk/electronic-key-fob.html
http://shop.loxone.com/enuk/ibutton-reader.html

Or do you have/know a better one?
Reply
#2
Yes, it will work but some extra scripting is required. Key fobs are different from 1-wire sensors as they appear as a new device with unique id for a short amount of time and then disappear. I'll provide an example on how to monitor 1-wire bus for new devices later on.
Reply
#3
(12.05.2016, 11:44)admin Wrote: Yes, it will work but some extra scripting is required. Key fobs are different from 1-wire sensors as they appear as a new device with unique id for a short amount of time and then disappear. I'll provide an example on how to monitor 1-wire bus for new devices later on.

thanks
Reply
#4
Here's a basic example, create a resident script with sleep time = 0. os.sleep at the end tells how often the 1-Wire bus is polled for new devices. Can you explain what kind of task do you have, some kind of access / door control or similar? I can provide a better example if the details are known Smile

Code:
if not ow then
  require('ow')
  
  -- list of allowed devices
  allowed = { '3A.B9901C000000' }
end

-- list of connected devices
visible = ow.list(true)

-- find if any allowed devices are present
for _, id1 in ipairs(visible) do
  for _, id2 in ipairs(allowed) do
    if id1 == id2 then
      -- do something here
    end
  end
end

os.sleep(0.5)
Reply
#5
(13.05.2016, 06:39)admin Wrote: Here's a basic example, create a resident script with sleep time = 0. os.sleep at the end tells how often the 1-Wire bus is polled for new devices. Can you explain what kind of task do you have, some kind of access / door control or similar? I can provide a better example if the details are known Smile

Yes i can give you more details.

We like to make a simple access control for a building with 25 apartments and 1 central control room. Every apartment and the control room has a LogicMachine Ambient with 1-wire devices, like the Keyfob and reader.

Our goal:
1: keyfobs are added and deleted with the LogicMachine Ambient in de control room and synced with the LogicMachine Ambient in the apartment (local variable).
The benefit for using local variable in the apartment LogicMachine for storing the keyfobs is that every apartment can be used standalone for controlling the acces,
only adding and deleting keys is controlled from central.
Example:
Key 1 and 2 is added and synced to Apartment 1
Key 3 and 4 is added and synced to Apartment 2
Key 99 is added and send to Apartment 1 and 2
Key 4 is deleted and synced to Apartment 2

2:
In the apartments we have a reader. When the right keyfob (assigned by the central control room) is hold for the reader then a output contact on the 1-wire PUZZLE is activated to control the door for some seconds.

3:
Maybe a end-user app to add and delete the keyfobs and assign them to a apartment, is this possible?
Then its also possible to store more information for a keyfob, like a username or unique number.
Reply
#6
my CPU/IO goes from 0.3 to 0.5 when i activate this script (CPU/IO: 0.59 0.43 0.28)

Is there a less resource heavy way for this command:
visible = ow.list(true)

when i disable the line: os.sleep(0.5)

my cpu/io is > 2.00
Reply
#7
Without os.sleep your script is consuming all available CPU resources.

The only way to check for new devices is to do polling, so there's no way to further optimize this script. You can try increasing sleep value to lower CPU load. I suppose users can hold the keyfob a little bit longer if they have proper feedback (door opening).
Reply
#8
Hello I know this post it's very old,
But I'm trying to do a control acces with LM5 with two 1-wire bus,
How can I differentiate between one and the other?
I just need to know when a keyfob it is placed and removed and if ithis it's on bus 1 or 2
Thank You in advance...
BR
Jose
Reply
#9
(13.09.2018, 11:39)Jose Wrote: Hello I know this post it's very old,
But I'm trying to do a control acces with LM5 with two 1-wire bus,
How can I differentiate between one and the other?
I just need to know when a keyfob it is placed and removed and if ithis it's on bus 1 or 2
Thank You in advance...
BR
Jose

1 wire devices have fixed ID which you will see in LM.
Reply
#10
You can use this function to list devices on a certain 1-Wire bus:
Code:
require('ow')

function list(bus)
  local res = {}
  local dir = ow.dir('/uncached/bus.' .. bus) or {}
  for _, entry in ipairs(dir) do
    local chunks = entry:split('/')
    if #chunks == 4 and chunks[ 4 ]:match('^%x%x%.') then
      res[ #res + 1 ] = chunks[ 4 ]
    end
  end

  return res
end

log(list(0))
log(list(1))
Reply
#11
(13.09.2018, 12:38)admin Wrote: You can use this function to list devices on a certain 1-Wire bus:
Code:
require('ow')

function list(bus)
 local res = {}
 local dir = ow.dir('/uncached/bus.' .. bus) or {}
 for _, entry in ipairs(dir) do
   local chunks = entry:split('/')
   if #chunks == 4 and chunks[ 4 ]:match('^%x%x%.') then
     res[ #res + 1 ] = chunks[ 4 ]
   end
 end

 return res
end

log(list(0))
log(list(1))

Thank you very much.
I will try it.
Reply


Forum Jump: