Results 1 to 5 of 5

Thread: Speak all violated security zones

  1. #1
    Join Date
    Apr 2004
    Location
    Dearborn, MI
    Posts
    1,967

    Default Speak all violated security zones

    Code:
    Voice :Speak("The System will  NOT be armed")
    
    -- Change these to your zone names ['elk zone name']='spoken voice name'
    local zones = {
        ['Front Door'] = 'Front Door',
        ['Back Door'] = 'Back Door',
        ['Kitchen Window E'] = 'Kitchen East Side Window',
        ['Kitchen Window S'] = 'Kitchen South Side Window',
        ['Living Room S'] = 'Living Room South Side Window',
        ['Guest Room E'] = 'Guest Room East Side Window',
        ['Bedroom E'] = 'Bedroom East Side Window',
        ['Den W'] = 'Den West Side Window',
        ['Den N'] = 'Den North Side Window',
    }
    
    
    -- builds device list control using filter list
    -- filter = {location = ,name = , devicetype = )
    
    
    
    
    local function BuildDeviceListControl (filterlist)
        local changed = false
    
    	
    -- device list
        local dl = {}
        
        for _,filter in ipairs (filterlist) do
            local list = DeviceManager:GetDevices (filter.Location,filter.Name,filter.DeviceType,filter.Abilities) 
    
            for _,device in ipairs (list) do
                table.insert (dl,device)
            end
        end
    
        table.sort (dl,function (a,b) return a:GetLocationName () < b:GetLocationName () end )
        
        local locnamelist = {}
        local devicesindextopath = {}
    
        
        for i,d in ipairs (dl) do
            table.insert (locnamelist, d:GetLocationName())
            devicesindextopath [i-1] = d:GetPath () -- itemindex is 0 based
        end
        
        if table.getn (locnamelist) < 1 then -- no devices
            table.insert (locnamelist,nodevices)
        end
        
        return locnamelist, devicesindextopath -- true if the any of the menus changed
    end
    
    local FilterList = {{DeviceType = 'Security\\Zone'}}
    local Devices, Paths = BuildDeviceListControl (FilterList)
    
    for k,v in ipairs(Paths) do
        local device = DeviceManager:GetDeviceUsingPath (v)
    	
        if device then
    	
            if device:GetControl('Condition'):GetValue() == 'Violated' and zones[device:GetName()] then
    
    		
    		print (zones[device:GetName()], device:GetName())
                Voice :Speak(zones[device:GetName()]..' Violated')
    
            end
        end
    end
    Last edited by jwilson56; November 7th, 2008 at 09:02 AM.
    John

    Now Playing skin creator

    Girder 5.0 / Elk-M1EZ8 / Ocelot / SECU-16IR /SECU-16I / SECU-16 / BobCat Humidity
    JRMC 11.1 / M-Audio Delta 410 / Xitel HIFI Pro / Xitel HIFI Link
    NetRemote 2.0 / 6 Zone whole house audio delivering 1580 watts RMS total
    ELO 15" Touchscreen, Nokia 770 and Advent 3500PC Mobile PC 7" TS
    Droid 2 Global

    Click here to visit my Nowplaying Showcase Blog

  2. #2
    Join Date
    Jun 2008
    Posts
    1,016

    Default

    John,

    This looks more complicated then needed -> do you just want to speak all security zones that are not ready?

    Also, it looks like the Elk is setting a security zone to "Violated" , not using G DM Convention "Not Ready".... this will break any code that expects a security zone to have Ready or Not Ready states.

  3. #3
    Join Date
    Apr 2004
    Location
    Dearborn, MI
    Posts
    1,967

    Default

    Well this is why the forum was created... some of us new to this. Complicated or not it does work.

    I passed the Violated info to Rick.
    John

    Now Playing skin creator

    Girder 5.0 / Elk-M1EZ8 / Ocelot / SECU-16IR /SECU-16I / SECU-16 / BobCat Humidity
    JRMC 11.1 / M-Audio Delta 410 / Xitel HIFI Pro / Xitel HIFI Link
    NetRemote 2.0 / 6 Zone whole house audio delivering 1580 watts RMS total
    ELO 15" Touchscreen, Nokia 770 and Advent 3500PC Mobile PC 7" TS
    Droid 2 Global

    Click here to visit my Nowplaying Showcase Blog

  4. #4
    Join Date
    Jun 2008
    Posts
    1,016

    Default

    Code:
    local sz = DeviceManager:GetDevices (false,false,'Security\\Zone')
    
    for _,device in ipairs (sz) do
    	if device:GetControlValue ('Condition') ~= 'Ready' then
    		print (device:GetLocationName (),' is not ready')
    	else
    		print (device:GetLocationName (),' is ready')
    	end
    end
    this shows the state of all security zones.....

    to specify what to speak, you could use the DM pages to edit the device description field and speak that text.

    if you want to sort the list do....


    Code:
    
    
    local sz = DeviceManager:GetDevices (false,false,'Security\\Zone')
    
    table.sort (sz,
    	function (a,b)
    		return a:GetLocationName () < b:GetLocationName ()
    	end
    )
    
    for _,device in ipairs (sz) do
    	if device:GetControlValue ('Condition') ~= 'Ready' then
    		print (device:GetLocationName (),' is not ready')
    	else
    		print (device:GetLocationName (),' is ready')
    	end
    end

  5. #5
    Join Date
    May 2004
    Location
    Dallas, TX
    Posts
    1,068

    Default

    Mike,

    Your method will work just fine, if you wanted to cycle through all the Security\Zones. The original script was setup to just check a few specific zones. Could the original script be less complicated, yes. With that, I have modified the script to be less complicated.

    Code:
    Voice:Speak("The System will NOT be armed")
    
    -- Change the path to match the devices you want announced,
    -- The path names are available in the Device Manager Screen
    -- TTSName is the text that will be spoken for each device
    local zones = {
        { TTSName = 'Front Door', Path = [[ncc-1701\ElkM1EZ8\Zone 1]] },
        { TTSName = 'Back Door', Path = [[ncc-1701\ElkM1EZ8\Zone 2]] },
        { TTSName = 'Garage Door', Path = [[ncc-1701\ElkM1EZ8\Zone 3]] },
    }
    
    for k,v in ipairs(zones) do
    	local device = DeviceManager:GetDeviceUsingPath (v.Path)
    	if device then
    		if device:GetControlValue ('Condition') == 'Violated' then
    			print (v.TTSName..' Violated')
                Voice:Speak(v.TTSName..' Violated')
    		end
    	end
    end
    I chose to have the TTSName in the script to keep things all in one place.

    On the Violated/Normal vs Not Ready/Ready issue, I agree with you on that and will make that change. Once I make that change, I will modify the script in this post to reflect the changes.
    Rick

    Girder 5.0 - Elk M1 Gold - JRMC 11.1 w/ M-Audio Delta 410 - NetRemote 2.0 - Panasonic KX-TA624 Phone System - ZoneMinder DVR
    Girder 5 Plugins - Elk M1/EZ8, Email Manager, Girder Backup, Ocelot, xAP Speedfan, xAP Ping, xAP Zoneminder and many more.


    Visit My Showcase

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •