I decided I wanted to open my Garage with the same RFID i use for work (HID RFID)
I have interfaced an old Ebay RFID reader to a Network POE Arduino. This is now run out to the garage with a single cat 5 cable. I can successfully connect to the Arduino on 192.168.1.177 on port 23 using putty, each time a card is scanned the Arduino spits out the card # followed by a crlf. So the hardware works great. The Arduino will take a few hundred separate connections at a time, if a card is scanned it will send it to all of the PC’s connected on port 23.
On to the Vera code.
I stole some code from the Sharp TV plugin, so you will see some left overs that I don’t think will hurt anything for now. Currently the code should just spit the scanned card # into the log. My end goal is to have one device added for each card that I would like to use. I would store the card number in the plugin and choose what that card will do via the Vera interface. (one card could just open the garage door while another could be used by the housekeeper to open the garage door, unlock the door from the garage to the house and disarm the home DSC alarm)
“I_ArdRFID.xml”
<?xml version="1.0"?>
<implementation>
<settings>
<protocol>crlf</protocol>
</settings>
<functions>
function RFIDStartup(lul_device)
local ipAddress, trash, ipPort
luup.log("Starting ArdRFID")
if (string.match(luup.devices[lul_device].ip, "(^(.*)(:(%d+))$")) then
ipAddress, trash, ipPort = string.match(luup.devices[lul_device].ip, "^(.*)(:(%d+))$")
else
ipAddress = luup.devices[lul_device].ip
ipPort = 23
luup.log("Setting to default port 23 ArdRFID")
end
if ((ipAddress ~= nil) and (ipAddress ~= "")) then
luup.log("Running I_ArdRFID.xml")
luup.io.open(lul_device, ipAddress, ipPort)
else
luup.log("No IP address specified for %s " .. tostring(lul_device))
end
end
</functions>
<incoming>
<lua>
luup.log("Received data from Arduino " .. tostring(lul_data))
</lua>
</incoming>
<startup>RFIDStartup</startup>
</implementation>
“D_ArdRFID.json”
{
"flashicon": "icons\/IR_Transmitter.swf",
"imgIconBody": "",
"imgIconDimmable": "",
"imgIconTurnable": "",
"imgIconMin": "",
"imgIconMax": "",
"halloIconsDir": "pics\/hallo",
"inScene": "1",
"DisplayStatus": {
"Service": "urn:micasaverde-com:serviceId:DiscretePower1",
"Variable": "Status",
"MinValue": "0",
"MaxValue": "1"
},
"doc_url": {
"doc_language": 1,
"doc_manual": 1,
"doc_version": 1,
"doc_platform": 0,
"doc_page": "devices"
},
"ToggleButton": 1,
"Tabs": [
{
"Label": {
"lang_tag": "tabname_control",
"text": "Control"
},
"Position": "0",
"TabType": "flash",
"SceneGroup": [
{
"id": "1",
"top": "0.5",
"left": "0",
"x": "2",
"y": "2,5"
}
],
"ControlGroup": [
{
"id": "1",
"isSingle": "1",
"scenegroup": "1"
},
{
"id": "2",
"isSingle": "1",
"scenegroup": "1"
},
{
"id": "3",
"isSingle": "1"
}
],
"Control": [
{
"ControlGroup":"1",
"ControlType": "button",
"Label": {
"lang_tag": "cmd_off",
"text": "Off"
},
"top": "1.5",
"left": "0",
"Display": {
"Service": "urn:micasaverde-com:serviceId:DiscretePower1",
"Value": "0",
"Top": 90,
"Left": 50,
"Width": 75,
"Height": 20
},
"Command": {
"Service": "urn:micasaverde-com:serviceId:DiscretePower1",
"Action": "Off"
}
},
{
"ControlGroup":"1",
"ControlType": "button",
"Label": {
"lang_tag": "cmd_on",
"text": "On"
},
"top": "1.5",
"left": "1",
"Display": {
"Service": "urn:micasaverde-com:serviceId:DiscretePower1",
"Variable": "Status",
"Value": "1",
"Top": 90,
"Left": 145,
"Width": 75,
"Height": 20
},
"Command": {
"Service": "urn:micasaverde-com:serviceId:DiscretePower1",
"Action": "On"
}
},
{
"ControlType": "variable",
"Display": {
"Service": "urn:micasaverde-com:serviceId:InputSelection1",
"Variable": "Input",
"Top": 20,
"Left": 50,
"Width": 200,
"Height": 20
}
},
{
"ControlType": "label",
"Label": {
"lang_tag": "device_control_page",
"text": "Volume:"
},
"Display": {
"Top": 30,
"Left": 50,
"Width": 120,
"Height": 20
}
},
{
"ControlGroup": "2",
"ControlHeader": "1",
"ControlType": "slider",
"top": "0",
"left": "0",
"Display": {
"Service": "urn:micasaverde-com:serviceId:Volume2",
"Variable": "Volume",
"ID": "Volume",
"MinValue": "10",
"MaxValue": "60",
"Top": 45,
"Left": 50,
"Width": 200,
"Height": 20
},
"Command": {
"Service": "urn:micasaverde-com:serviceId:Volume2",
"Action": "SetVolume",
"Parameters": [
{
"Name": "newTargetValue",
"ID": "Volume"
}
]
}
},
{
"ControlGroup":"3",
"ControlType": "button",
"Label": {
"lang_tag": "cmd_mute",
"text": "Mute"
},
"Display": {
"Service": "urn:micasaverde-com:serviceId:Volume2",
"Variable": "Status",
"Value": "0",
"Top": 45,
"Left": 230,
"Width": 75,
"Height": 20
},
"Command": {
"Service": "urn:micasaverde-com:serviceId:Volume2",
"Action": "ToggleMute"
}
},
]
},
{
"Label": {
"lang_tag": "settings",
"text": "Settings"
},
"Position": "1",
"TabType": "javascript",
"ScriptName": "shared.js",
"Function": "simple_device"
},
{
"Label": {
"lang_tag": "advanced",
"text": "Advanced"
},
"Position": "2",
"TabType": "javascript",
"ScriptName": "shared.js",
"Function": "advanced_device"
},
],
"DeviceType": "urn:schemas-micasaverde-com:device:RFID:1",
}
“D_ArdRFID.xml”
<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<deviceType>urn:schemas-micasaverde-com:device:RFID:1</deviceType>
<staticJson>D_ArdRFID.json</staticJson>
<friendlyName>ArdRFID Interface</friendlyName>
<manufacturer>Todd</manufacturer>
<manufacturerURL>http://www.canadiangeek.com</manufacturerURL>
<modelDescription>RFID interface made from Network Arduino</modelDescription>
<modelName>Dont have one Yet</modelName>
<modelNumber>1.0</modelNumber>
<UDN>uuid:2ff93ec0-c2f8-11dd-ad8b-08fff0c9a37</UDN>
<protocol>crlf</protocol>
<handleChildren>1</handleChildren>
<implementationList>
<implementationFile>I_ArdRFID.xml</implementationFile>
</implementationList>
<serviceList>
</serviceList>
</device>
</root>
Now when I upload the files and run them i see this in the logs.
01 10/21/13 22:13:17.283 Device_LuaUPnP::LoadDeviceDoc #32 can’t parse name /uuid:4d494342-5342-5645-0020-000001c9d534 <0x2b026000>
01 10/21/13 22:13:17.283 JobHandler_LuaUPnP::CreateDevice_LuaUPnP failed to load 32/I_ArdRFID.xml so device 32 is offline <0x2b026000>
01 10/21/13 22:13:17.624 Device_LuaUPnP::CreateServices Aborting device 32 because the topmost device has no interface <0x2b026000>
01 10/21/13 22:13:17.624 JobHandler_LuaUPnP::CreateAllServices failed to create 32 <0x2b026000>
01 10/21/13 22:13:17.682 Device_LuaUPnP::CreateImplementations Aborting 32 because it failed to load <0x2b026000>
01 10/21/13 22:13:17.683 JobHandler_LuaUPnP::CreateAllImplementations failed to create 32 <0x2b026000>
Thoughts?