- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
/D_RFIDTransmitter.json
r1 r3 29 29 "Position": "0", 30 30 "TabType": "flash", 31 "ControlGroup":[ 32 { 33 "id":"1", 34 "isSingle":"1" 35 }, 36 { 37 "id":"2", 38 "isSingle":"1" 39 } 40 ], 31 41 "Control": [ 32 42 { 43 "ControlGroup":"1", 33 44 "ControlType": "button", 34 45 "Label": { … … 57 68 }, 58 69 { 70 "ControlGroup":"2", 59 71 "ControlType": "button", 60 72 "Label": { … … 167 179 "eventList": { 168 180 "event_1": { 169 "label": "Home \/Away",181 "label": "Home or Away", 170 182 "serviceId": "urn:micasaverde-com:serviceId:SecuritySensor1", 171 183 "argumentList": { … … 179 191 "name": "Tripped", 180 192 "comparisson": "=", 181 "prefix": "Home or Away ",193 "prefix": "Home or Away?", 182 194 "suffix": "" 183 195 } … … 185 197 }, 186 198 "event_2": { 187 "label": "Armed Home \/Away,199 "label": "Armed Home or Away", 188 200 "serviceId": "urn:micasaverde-com:serviceId:SecuritySensor1", 189 201 "serviceStateTable": { … … 202 214 "name": "Tripped", 203 215 "comparisson": "=", 204 "prefix": "Home or Away ",216 "prefix": "Home or Away?", 205 217 "suffix": " " 206 218 } 207 219 } 208 } 220 }, 221 "event_3": { 222 "label": "Battery level goes below", 223 "serviceId": "urn:micasaverde-com:serviceId:HaDevice1", 224 "argumentList": { 225 "argument_1": { 226 "dataType": "i4", 227 "name": "BatteryLevel", 228 "comparisson": "<", 229 "suffix": "%" 230 } 231 } 232 } 209 233 }, 210 234 "DeviceType": "urn:schemas-micasaverde-com:device:MotionSensor:1", -
/I_ActiveRFID.xml
r1 r3 10 10 <functions> 11 11 function RFIDStartup(lul_device) 12 RFID_RecDev = lul_device 12 13 RFID_Tag_Index = {} 13 14 RFID_Buffer_Index = {} 14 RFID_Expire = {} 15 RFID_Buffers = {} 16 RFID_Data = {} 17 RFID_Data[lul_device] = "" 15 RFID_Data = "" 18 16 luup.log("Running I_ActiveRFID.xml") 19 17 local txCount = luup.variable_get("urn:ActiveRFID:serviceId:ActiveRFID1","Transmitters",lul_device) … … 23 21 expireTime = luup.variable_get("urn:ActiveRFID:serviceId:ActiveRFID1","Expire Time",lul_device) 24 22 end 25 RFID_Expire [lul_device]= expireTime .. "s"26 RFID_Buffers [lul_device] = (math.floor((expireTime - 1)/(2.5))+1)23 RFID_Expire = expireTime .. "s" 24 RFID_Buffers = (math.floor((expireTime)/(2.5))+1) 27 25 if (txCount == nil) then 28 26 luup.variable_set("urn:ActiveRFID:serviceId:ActiveRFID1","Transmitters",0,lul_device) … … 42 40 luup.variable_set("urn:ActiveRFID:serviceId:RFIDTransmitter1","TagID","Enter 4-digit ID",k) 43 41 else 44 local RecTagID = lul_device .. TagID 45 local RecTagBuffer 46 RFID_Tag_Index[RecTagID] = k 47 for i=1,RFID_Buffers[lul_device] do 48 RecTagBuffer = RecTagID .. "," .. i 49 RFID_Buffer_Index[RecTagBuffer] = 0 42 local TagBuffer 43 RFID_Tag_Index[TagID] = k 44 for i=1,RFID_Buffers do 45 TagBuffer = TagID .. i 46 RFID_Buffer_Index[TagBuffer] = 0 50 47 end 51 48 if (TrippedStatus == "1") then 52 luup.call_timer("verifyBuffer", 1, RFID_Expire [lul_device],"",RecTagID)49 luup.call_timer("verifyBuffer", 1, RFID_Expire,"",TagID) 53 50 end 54 luup.log("RFID Transmitter " .. TagID .. ", Receiver " .. lul_device .. " indexed at " .. RecTagID .. ".")51 luup.log("RFID Transmitter " .. TagID .. ", Receiver " .. lul_device .. " indexed.") 55 52 end 56 53 if (TrippedStatus == nil) then … … 63 60 luup.log("ActiveRFID startup complete") 64 61 end 65 function setBuffer(rectagid) 66 local RecTagBuffer 67 local RecTagDev = RFID_Tag_Index[rectagid] 68 local TagID = string.sub(rectagid,-4) 69 local RecDev = tonumber(string.sub(rectagid,0,-5)) 70 local TrippedStatus = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped",RecTagDev) 62 function setBuffer(tagid) 63 local TagBuffer 64 local TagDev = RFID_Tag_Index[tagid] 65 local TrippedStatus = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped",TagDev) 71 66 if (TrippedStatus == "0") then 72 luup.log("RFID Tag " .. TagID .. ", Device " .. RecTagDev .. " tripped.")73 luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped","1", RecTagDev)67 luup.log("RFID Tag " .. tagid .. ", Device " .. TagDev .. " tripped.") 68 luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped","1",TagDev) 74 69 end 75 for i=1,RFID_Buffers [RecDev]do76 RecTagBuffer = rectagid .. ",".. i77 if (RFID_Buffer_Index[ RecTagBuffer] == 0) then78 RFID_Buffer_Index[ RecTagBuffer] = 179 luup.call_timer("resetBuffer", 1, RFID_Expire [RecDev],"",RecTagBuffer)70 for i=1,RFID_Buffers do 71 TagBuffer = tagid .. i 72 if (RFID_Buffer_Index[TagBuffer] == 0) then 73 RFID_Buffer_Index[TagBuffer] = 1 74 luup.call_timer("resetBuffer", 1, RFID_Expire,"",TagBuffer) 80 75 break 81 76 end 82 77 end 83 78 end 84 function resetBuffer( rectagbuffer)85 local RecTagID = string.sub(rectagbuffer,1,(string.find(rectagbuffer,",")-1))86 RFID_Buffer_Index[ rectagbuffer] = 087 verifyBuffer( RecTagID)79 function resetBuffer(tagbuffer) 80 local TagID = string.sub(tagbuffer,1,4) 81 RFID_Buffer_Index[tagbuffer] = 0 82 verifyBuffer(TagID) 88 83 end 89 function verifyBuffer( rectagid)90 local RecTagBuffer84 function verifyBuffer(tagid) 85 local TagBuffer 91 86 local TagVerified = "0" 92 local RecTagDev = RFID_Tag_Index[rectagid] 93 local TagID = string.sub(rectagid,-4) 94 local RecDev = tonumber(string.sub(rectagid,0,-5)) 95 local TrippedStatus = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped",RecTagDev) 96 for i=1,RFID_Buffers[RecDev] do 97 RecTagBuffer = rectagid .. "," .. i 98 if (RFID_Buffer_Index[RecTagBuffer] == 1) then 87 local TagDev = RFID_Tag_Index[tagid] 88 local TrippedStatus = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped",TagDev) 89 for i=1,RFID_Buffers do 90 TagBuffer = tagid .. i 91 if (RFID_Buffer_Index[TagBuffer] == 1) then 99 92 TagVerified = "1" 100 93 break … … 102 95 end 103 96 if (TrippedStatus == "1" and TagVerified == "0") then 104 luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped","0", RecTagDev)105 luup.log("RFID Tag " .. TagID .. ", Device " .. RecTagDev .. " untripped.")97 luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped","0",TagDev) 98 luup.log("RFID Tag " .. tagid .. ", Device " .. TagDev .. " untripped.") 106 99 end 107 100 end 108 function handle_incoming(serdata ,recdevice)101 function handle_incoming(serdata) 109 102 if (serdata == " ") then 110 local TagID = string.sub(RFID_Data [recdevice],1,4)111 local RFIDStrength = string.sub(RFID_Data [recdevice],5,7)103 local TagID = string.sub(RFID_Data,1,4) 104 local RFIDStrength = string.sub(RFID_Data,5,7) 112 105 RFIDStrength = tonumber(RFIDStrength) 113 local RecTagID = recdevice .. TagID 114 local TAGDEV = RFID_Tag_Index[RecTagID] 115 if (TAGDEV == nil) then 116 luup.log("RFID tag " .. TagID .. " found by receiver " .. recdevice .. ", but not assigned to a device.") 106 local TagDev = RFID_Tag_Index[TagID] 107 if (TagDev == nil) then 108 luup.log("RFID tag " .. TagID .. " found by receiver " .. RFID_RecDev .. ", but not assigned to a device.") 117 109 else 118 setBuffer( RecTagID)110 setBuffer(TagID) 119 111 end 120 RFID_Data [recdevice]= ""112 RFID_Data = "" 121 113 else 122 RFID_Data [recdevice] = RFID_Data[recdevice].. serdata114 RFID_Data = RFID_Data .. serdata 123 115 end 124 116 end … … 126 118 <incoming> 127 119 <lua> 128 handle_incoming(lul_data ,lul_device)129 120 handle_incoming(lul_data) 121 </lua> 130 122 </incoming> 131 123 <startup>RFIDStartup</startup>
Note: See TracChangeset
for help on using the changeset viewer.