- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/S_VistaAlarmPanel1.xml
r77 r83 8 8 <stateVariable> 9 9 <name>PluginVersion</name> 10 <data type>string</datatype>10 <dataType>string</dataType> 11 11 </stateVariable> 12 12 <stateVariable> 13 13 <name>DebugMode</name> 14 <data type>boolean</datatype>14 <dataType>boolean</dataType> 15 15 </stateVariable> 16 16 <stateVariable> 17 17 <name>NumPartitions</name> 18 <data type>ui1</datatype>18 <dataType>ui1</dataType> 19 19 </stateVariable> 20 20 <stateVariable> 21 21 <name>KeypadAddresses</name> 22 <data type>string</datatype>22 <dataType>string</dataType> 23 23 </stateVariable> 24 24 <stateVariable> 25 25 <name>ChimeMode</name> 26 <data type>boolean</datatype>26 <dataType>boolean</dataType> 27 27 </stateVariable> 28 28 <stateVariable> 29 29 <name>ConnectionDown</name> 30 <data type>boolean</datatype>30 <dataType>boolean</dataType> 31 31 </stateVariable> 32 32 <stateVariable> 33 33 <name>Zones</name> 34 <data type>string</datatype>34 <dataType>string</dataType> 35 35 </stateVariable> 36 36 <stateVariable> 37 37 <name>SecureStore</name> 38 <data type>boolean</datatype>38 <dataType>boolean</dataType> 39 39 </stateVariable> 40 40 <stateVariable> 41 41 <name>TTL</name> 42 <data type>ui2</datatype>42 <dataType>ui2</dataType> 43 43 </stateVariable> 44 44 <stateVariable> 45 45 <name>AlarmZone</name> 46 <data type>ui1</datatype>46 <dataType>ui1</dataType> 47 47 </stateVariable> 48 48 <stateVariable> 49 49 <name>CheckConnectionTimer</name> 50 <data type>ui2</datatype>50 <dataType>ui2</dataType> 51 51 </stateVariable> 52 52 <stateVariable> 53 53 <name>VirtualZones</name> 54 <data type>string</datatype>54 <dataType>string</dataType> 55 55 </stateVariable> 56 56 <stateVariable> 57 57 <name>DisableSendStar</name> 58 <data type>boolean</datatype>58 <dataType>boolean</dataType> 59 59 </stateVariable> 60 60 </serviceStateTable> -
trunk/L_VistaAlarmPanel1.lua
r77 r83 8 8 9 9 -- Constants 10 local VERSION = " 2.45"10 local VERSION = "3.89" 11 11 12 12 local NUM_PARTITIONS = 1 -- Number of partitions. … … 500 500 table.insertSet(g_faultedZones, zone) 501 501 end 502 502 503 503 debug("(VistaAlarmPanel::addFaultedZone) Set zone #"..zone.." to tripped.") 504 504 end … … 512 512 513 513 table.removeItem(g_faultedZones, zone) 514 514 515 515 luup.variable_set(SID.SECURITY_SENSOR, "Tripped", "0", g_zones[zone].device) 516 516 517 517 debug("(VistaAlarmPanel::removeFaultedZone) Set zone #"..zone.." to not tripped.") 518 518 end … … 537 537 return true 538 538 end 539 539 540 540 partNo = tonumber(partNo, 10) 541 541 … … 743 743 if (faulted) then 744 744 addFaultedZone(k) 745 else 745 else 746 746 removeFaultedZone(k) 747 747 end … … 753 753 -- Process "!RFX" messages 754 754 -- 755 -- Example messages: 755 -- Example messages: 756 756 -- !RFX:0180036,80 757 757 -- … … 759 759 -- break the incoming message into sections (I wish Lua had real regex handling :( 760 760 local sections = {data:match('^!RFX:(%d%d%d%d%d%d%d),(%x%x)$')} 761 761 762 762 if (not sections or #sections == 0) then 763 763 log ("(VistaAlarmPanel::processRFXMessage) Invalid RFX message received: " .. data) 764 764 return false 765 765 end 766 766 767 767 local serial = sections[1] 768 768 local rawDeviceData = tonumber(sections[2], 16) 769 769 770 770 -- decode raw device data 771 771 local flags = {} … … 780 780 loop[4] = bit.band(rawDeviceData, 0x40) > 0 781 781 loop[1] = bit.band(rawDeviceData, 0x80) > 0 782 782 783 783 if (DEBUG_MODE) then 784 784 local message = "(VistaAlarmPanel::processExMessage) Decoded RFX message: serial = " .. serial … … 787 787 end 788 788 for k, v in pairs(flags) do 789 message = message .. ", flags." .. k .. " = " .. tostring(v) 789 message = message .. ", flags." .. k .. " = " .. tostring(v) 790 790 end 791 791 debug (message) … … 799 799 return true 800 800 end 801 801 802 802 -- update Zone tripped statuses 803 803 for i = 1, 4 do 804 804 updateZoneByAddress(serial, i, loop[i]) 805 805 end 806 806 807 807 return true 808 808 end … … 828 828 829 829 debug("(VistaAlarmPanel::processExMessage) Decoded " .. sections[1] .. 830 " message: address = " .. address .. ", channel = " .. channel .. 830 " message: address = " .. address .. ", channel = " .. channel .. 831 831 ", faulted = " .. tostring(faulted) .. ", supervision = " .. tostring(supervision)) 832 832 833 833 if (not supervision) then 834 834 updateZoneByAddress(address, channel, faulted) 835 835 end 836 836 837 837 return true 838 838 end … … 845 845 luup.sleep(SLEEP_MS) 846 846 end 847 847 848 848 function processIncoming (data) 849 849 … … 947 947 ", lul_value_old = " .. (lul_value_old or "nil") .. 948 948 ", lul_value_new = " .. (lul_value_new or "nil")) 949 949 950 950 local securitySensor = g_securitySensors[tonumber(lul_device)] 951 951 952 952 if (securitySensor and lul_value_new == "0" or lul_value_new == "1") then 953 953 sendVirtualZoneStatus (securitySensor.zone, lul_value_new) … … 1037 1037 debug("(VistaAlarmPanel::appendPartitions) Appending partition #"..i..".") 1038 1038 local parameters = SID.PANEL..",KeypadAddresses=" 1039 luup.chdev.append(lug_device, rootPtr, "vista_partition_"..i, "Ademco Vista Partition "..i, "urn:schemas-micasaverde-com:device: AlarmPartition:2", "D_VistaAlarmPartition1.xml", "", parameters, false)1039 luup.chdev.append(lug_device, rootPtr, "vista_partition_"..i, "Ademco Vista Partition "..i, "urn:schemas-micasaverde-com:device:VistaAlarmPartition:2", "D_VistaAlarmPartition1.xml", "", parameters, false) 1040 1040 end 1041 1041 end … … 1055 1055 end 1056 1056 g_zones[zoneNo] = { 1057 address = zoneAddress, -- keep address as string because RF serial # "0000012" != address "12" 1057 address = zoneAddress, -- keep address as string because RF serial # "0000012" != address "12" 1058 1058 channel = tonumber(zoneChannel, 10), 1059 1059 type = zoneType … … 1134 1134 function vistaStartup (lul_device) 1135 1135 log("Honeywell Ademco Vista Alarm Panel Plugin version "..VERSION) 1136 1137 1136 lug_device = lul_device 1137 1138 1138 luup.variable_set(SID.PANEL, "PluginVersion", VERSION, lul_device) 1139 1139 1140 -- IP based serial port code 1141 -- Copyright (C) 2009-2011 Deborah Pickett 1142 -- Adapted From: http://code.mios.com/trac/mios_caddxnx584/browser/trunk/L_CaddxNX584Security.lua 1143 local ioDevice = luup.variable_get("urn:micasaverde-com:serviceId:HaDevice1", "IODevice", lul_device) 1144 local useSocket = false 1145 if (ioDevice == nil or ioDevice == "") then 1146 luup.log("(VistaAlarmPanel::main) No IO device specified; going to check for IP based config") 1147 useSocket = true 1148 end 1149 if (useSocket) then 1150 local ip = luup.devices[lul_device].ip 1151 luup.log("(VistaAlarmPanel::main) Configured ip address: " .. ip) 1152 local ipv4, tcpport = ip:match("(%d+%.%d+%.%d+%.%d+):(%d+)") 1153 if (ipv4 ~= nil and tcpport ~= nil) then 1154 luup.log(string.format("(VistaAlarmPanel::main) Opening socket to %s port %s", ipv4, tcpport)) 1155 luup.io.open(lul_device, ipv4, tcpport) 1156 else 1157 luup.log("(VistaAlarmPanel::main) No serial device specified; exiting") 1158 return false, "(VistaAlarmPanel::main) No serial device specified. Please configure the plugin.", 1159 string.format("%s[%d]", luup.devices[lul_device].description, lul_device) 1160 end 1161 else 1162 luup.log("(VistaAlarmPanel::main) Opening serial port") 1163 end 1164 -- End IP based serial port code 1165 1140 1166 getDebugMode() 1141 1167 … … 1190 1216 -- Initialize virtual zones 1191 1217 initVirtualZones() 1192 1218 1193 1219 -- Start the TTL timer. 1194 1220 ttlCountdownTimer() … … 1199 1225 -- Start the timer that checks the connection status. 1200 1226 luup.call_delay("checkConnection", CHECK_CONNECTION_DELAY, "") 1227 1228 if (luup.version_major >= 7) then 1229 luup.set_failure(0, lul_device) 1230 end 1201 1231 1202 1232 log("(VistaAlarmPanel::main) SUCCESS: Startup successful.")
Note: See TracChangeset
for help on using the changeset viewer.