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 that you accept these cookies being set.

Use Apple Airtag instead of Rfid tag
#10
(22.09.2023, 06:31)RomansP Wrote:
(20.09.2023, 15:03)Novodk Wrote:
(20.09.2023, 12:51)admin Wrote: You need to create a resident script that executes ow.list() every second or so. Then you can perform required action when a device with a given ID is present or not.

A bit out of my comfort zone Smile
Do you have any example code, in that direction to get me started?

Hello Novodk.

This is resident script for you.

Code:
require('ow') function findDifferences(list, prev_list)   local new_ids = {}   local removed_ids = {}   -- Check for new IDs   if list then     for id, _ in pairs(list) do       if not prev_list or not prev_list[id] then         table.insert(new_ids, id)       end     end   end   -- Check for removed IDs   if prev_list then     for id, _ in pairs(prev_list) do       if not list[id] then         table.insert(removed_ids, id)       end     end   end   return new_ids, removed_ids end list = ow.list() local new_ids, removed_ids = findDifferences(list, prev_list) if #new_ids > 0 then   log("New IDs:")   for _, id in ipairs(new_ids) do     log(id, list[id])   end end if #removed_ids > 0 then   log("Removed IDs:")   for _, id in ipairs(removed_ids) do     log(id, prev_list[id])   end end prev_list = list

Thank you RomansP
Is it correct that the script adds the rfid tag ID to a table and after a short time it removes it again?
[Image: 5U9xe0L.png]

If that is the case, how do I use the information from that table?
Reply


Messages In This Thread
RE: Use Apple Airtag instead of Rfid tag - by Novodk - 22.09.2023, 20:07

Forum Jump: