Hi
Calling all the lua experts out there,
When someone has time - please could they help update the following code so that the printed list is sorted in order of the oldest one first (longest period since Sensor was last updated)
[code]-- Basis taken from Door/Window sensor check and speech annotation by Pasqual Zottola
local devcnt = 0
local devno = 0
local numopen = 0
local isare = “is”
local opensensors = " "
local SSID = “urn:micasaverde-com:serviceId:SecuritySensor1”
for deviceNo,d in pairs(luup.devices) do
if d.category_num == 4 then
local tripped = luup.variable_get(SSID, "Tripped", deviceNo) or "Nil"
local lastTrip = luup.variable_get (SSID, "LastTrip", deviceNo) or os.time()
local timeString = os.date(" %Y/%m/%d - %X", lastTrip)
lastTrip = tonumber (lastTrip)
if (tripped == "1") then
opensensors = opensensors .. ". " .. d.description
numopen = numopen + 1
end
print (
lastTrip …
’ a.k.a ’ … timeString …
’ : ’ … d.description … " Sensor was last tripped")
devcnt = devcnt + 1
end
end
if numopen == 0 then --If there are no sensors tripped, log and announce!
print ("- - - - ")
print(‘There were ’ … devcnt … ’ door and window sensors found and all are closed’)
else --If there are any sensors tripped, log and announce!
if numopen > 1 then
isare = “are”
end
print ("- - - - ")
print (‘There were ’ … devcnt … ’ door and window sensors found and ’ … numopen … " " … isare … ’ currently open’ … opensensors)
end[/code]