Changes in trunk [77:83]


Ignore:
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/S_VistaAlarmPanel1.xml

    r77 r83  
    88        <stateVariable> 
    99            <name>PluginVersion</name> 
    10             <datatype>string</datatype> 
     10            <dataType>string</dataType> 
    1111        </stateVariable> 
    1212        <stateVariable> 
    1313            <name>DebugMode</name> 
    14             <datatype>boolean</datatype> 
     14            <dataType>boolean</dataType> 
    1515        </stateVariable> 
    1616        <stateVariable> 
    1717            <name>NumPartitions</name> 
    18             <datatype>ui1</datatype> 
     18            <dataType>ui1</dataType> 
    1919        </stateVariable> 
    2020        <stateVariable> 
    2121            <name>KeypadAddresses</name> 
    22             <datatype>string</datatype> 
     22            <dataType>string</dataType> 
    2323        </stateVariable> 
    2424        <stateVariable> 
    2525            <name>ChimeMode</name> 
    26             <datatype>boolean</datatype> 
     26            <dataType>boolean</dataType> 
    2727        </stateVariable> 
    2828        <stateVariable> 
    2929            <name>ConnectionDown</name> 
    30             <datatype>boolean</datatype> 
     30            <dataType>boolean</dataType> 
    3131        </stateVariable> 
    3232        <stateVariable> 
    3333            <name>Zones</name> 
    34             <datatype>string</datatype> 
     34            <dataType>string</dataType> 
    3535        </stateVariable> 
    3636        <stateVariable> 
    3737            <name>SecureStore</name> 
    38             <datatype>boolean</datatype> 
     38            <dataType>boolean</dataType> 
    3939        </stateVariable> 
    4040        <stateVariable> 
    4141            <name>TTL</name> 
    42             <datatype>ui2</datatype> 
     42            <dataType>ui2</dataType> 
    4343        </stateVariable> 
    4444        <stateVariable> 
    4545            <name>AlarmZone</name> 
    46             <datatype>ui1</datatype> 
     46            <dataType>ui1</dataType> 
    4747        </stateVariable> 
    4848        <stateVariable> 
    4949            <name>CheckConnectionTimer</name> 
    50             <datatype>ui2</datatype> 
     50            <dataType>ui2</dataType> 
    5151        </stateVariable> 
    5252        <stateVariable> 
    5353            <name>VirtualZones</name> 
    54             <datatype>string</datatype> 
     54            <dataType>string</dataType> 
    5555        </stateVariable> 
    5656        <stateVariable> 
    5757            <name>DisableSendStar</name> 
    58             <datatype>boolean</datatype> 
     58            <dataType>boolean</dataType> 
    5959        </stateVariable> 
    6060    </serviceStateTable> 
  • trunk/L_VistaAlarmPanel1.lua

    r77 r83  
    88 
    99-- Constants 
    10 local VERSION = "2.45" 
     10local VERSION = "3.89" 
    1111 
    1212local NUM_PARTITIONS = 1 -- Number of partitions. 
     
    500500        table.insertSet(g_faultedZones, zone) 
    501501    end 
    502  
     502     
    503503    debug("(VistaAlarmPanel::addFaultedZone) Set zone #"..zone.." to tripped.") 
    504504end 
     
    512512 
    513513    table.removeItem(g_faultedZones, zone) 
    514  
     514     
    515515    luup.variable_set(SID.SECURITY_SENSOR, "Tripped", "0", g_zones[zone].device) 
    516  
     516     
    517517    debug("(VistaAlarmPanel::removeFaultedZone) Set zone #"..zone.." to not tripped.") 
    518518end 
     
    537537        return true 
    538538    end 
    539  
     539     
    540540    partNo = tonumber(partNo, 10) 
    541541 
     
    743743            if (faulted) then 
    744744                addFaultedZone(k) 
    745             else 
     745            else  
    746746                removeFaultedZone(k) 
    747747            end 
     
    753753-- Process "!RFX" messages 
    754754-- 
    755 -- Example messages: 
     755-- Example messages:  
    756756-- !RFX:0180036,80 
    757757-- 
     
    759759    -- break the incoming message into sections (I wish Lua had real regex handling :( 
    760760    local sections = {data:match('^!RFX:(%d%d%d%d%d%d%d),(%x%x)$')} 
    761  
     761     
    762762    if (not sections or #sections == 0) then 
    763763        log ("(VistaAlarmPanel::processRFXMessage) Invalid RFX message received: " .. data) 
    764764        return false 
    765765    end 
    766  
     766     
    767767    local serial = sections[1] 
    768768    local rawDeviceData = tonumber(sections[2], 16) 
    769  
     769         
    770770    -- decode raw device data 
    771771    local flags = {} 
     
    780780    loop[4] = bit.band(rawDeviceData, 0x40) > 0 
    781781    loop[1] = bit.band(rawDeviceData, 0x80) > 0 
    782  
     782         
    783783    if (DEBUG_MODE) then 
    784784        local message = "(VistaAlarmPanel::processExMessage) Decoded RFX message: serial = " .. serial 
     
    787787        end 
    788788        for k, v in pairs(flags) do 
    789             message = message .. ", flags." .. k .. " = " .. tostring(v) 
     789            message = message .. ", flags." .. k .. " = " .. tostring(v)             
    790790        end 
    791791        debug (message) 
     
    799799        return true 
    800800    end 
    801  
     801         
    802802    -- update Zone tripped statuses 
    803803    for i = 1, 4 do 
    804804        updateZoneByAddress(serial, i, loop[i]) 
    805805    end 
    806  
     806     
    807807    return true 
    808808end 
     
    828828 
    829829    debug("(VistaAlarmPanel::processExMessage) Decoded " .. sections[1] .. 
    830         " message: address = " .. address  .. ", channel = " .. channel .. 
     830        " message: address = " .. address  .. ", channel = " .. channel ..  
    831831        ", faulted = " .. tostring(faulted) .. ", supervision = " .. tostring(supervision)) 
    832  
     832             
    833833    if (not supervision) then 
    834834        updateZoneByAddress(address, channel, faulted) 
    835835    end 
    836  
     836     
    837837    return true 
    838838end 
     
    845845    luup.sleep(SLEEP_MS) 
    846846end 
    847  
     847         
    848848function processIncoming (data) 
    849849 
     
    947947        ", lul_value_old = " .. (lul_value_old or "nil") .. 
    948948        ", lul_value_new = " .. (lul_value_new or "nil")) 
    949  
     949         
    950950    local securitySensor = g_securitySensors[tonumber(lul_device)] 
    951  
     951     
    952952    if (securitySensor and lul_value_new == "0" or lul_value_new == "1") then 
    953953        sendVirtualZoneStatus (securitySensor.zone, lul_value_new) 
     
    10371037        debug("(VistaAlarmPanel::appendPartitions) Appending partition #"..i..".") 
    10381038        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) 
    10401040    end 
    10411041end 
     
    10551055        end 
    10561056        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"  
    10581058            channel = tonumber(zoneChannel, 10), 
    10591059            type = zoneType 
     
    11341134function vistaStartup (lul_device) 
    11351135    log("Honeywell Ademco Vista Alarm Panel Plugin version "..VERSION) 
    1136  
    11371136    lug_device = lul_device 
     1137     
    11381138    luup.variable_set(SID.PANEL, "PluginVersion", VERSION, lul_device) 
    11391139 
     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   
    11401166    getDebugMode() 
    11411167 
     
    11901216    -- Initialize virtual zones 
    11911217    initVirtualZones() 
    1192  
     1218     
    11931219    -- Start the TTL timer. 
    11941220    ttlCountdownTimer() 
     
    11991225    -- Start the timer that checks the connection status. 
    12001226    luup.call_delay("checkConnection", CHECK_CONNECTION_DELAY, "") 
     1227     
     1228    if (luup.version_major >= 7) then 
     1229        luup.set_failure(0, lul_device) 
     1230  end 
    12011231 
    12021232    log("(VistaAlarmPanel::main) SUCCESS: Startup successful.") 
Note: See TracChangeset for help on using the changeset viewer.