There is no "Tripped" action for a security sensor, so it will not work. It seems that you want to do this with Luup code, so there is no need to use the HTTP requests, there are dedicated functions in Lua for this too :
You can use the following code and change it based on your needs :
for dev, attr in pairs(luup.devices) do
if attr.category_num == "4" and attr.subcategory_num == "3" then
luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", "0", dev)
end
end
Thanks!!.. yes… I am using it in luup… I did the http call cause sometimes its easier to debug…
You method works without the if the statement
which means I can run it, and reset each security sensor from tripped 1 to 0
but with the if statement the line never runs…
[code]for k, v in pairs(luup.devices) do
luup.task(k,1,“I got here”, 1)
if v.category_num == “4” and v.subcategory_num == “3” then
luup.task(“Yes”,1,“I got here”, 2)
luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", "0", k)
end
A little help please? The following code does not appear to “untrip” my sensors. Does anyone see the problem?
– (motion sensors)
for k, v in pairs(luup.devices) do
luup.task(k,1,“I got here”, 1)
if v.category_num == “4” and v.subcategory_num == “3” then
luup.task(“Yes”,1,“I got here”, 2)
luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", "0", k)
end
end
– (door sensors)
for k, v in pairs(luup.devices) do
luup.task(k,1,“I got here”, 1)
if v.category_num == “11” and v.subcategory_num == “0” then
luup.task(“Yes”,1,“I got here”, 2)
luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", "0", k)
end
A little help please? The following code does not appear to "untrip" my sensors. Does anyone see the problem?
It may be that your calls to luup.task(…) are blowing-up and aborting the code. See here for the correct way to use the handle (fourth argument).
You might find LuaTest helpful for debugging code like this. It gives fairly clear error messages and also allows the use of print(…) statements to show progress.
A little help please? The following code does not appear to “untrip” my sensors. Does anyone see the problem?
It may be that your calls to luup.task(…) are blowing-up and aborting the code. See here for the correct way to use the handle (fourth argument).
You might find LuaTest helpful for debugging code like this. It gives fairly clear error messages and also allows the use of print(…) statements to show progress.[/quote]
I’m not a programmer, sorry! When I hear “removing the quotes was the problem”, I think either you need to remove the quotes to solve the problem, or removing the quotes WAS the problem :-).
I duplicated the code for the door sensor devices (I just changed the category and subcategory).
I liked the old script days when I could step code through line by line. If anyone can discern specifically what is wrong with my code, please let me know. Others seem to have this running.
If anyone can discern specifically what is wrong with my code, please let me know.
Try this:
-- (motion sensors)
for k, v in pairs(luup.devices) do
if v.category_num == 4 and v.subcategory_num == 3 then
luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", "0", k)
end
end
-- (door sensors)
for k, v in pairs(luup.devices) do
if v.category_num == 11 and v.subcategory_num == 0 then
luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", "0", k)
end
end
If anyone can discern specifically what is wrong with my code, please let me know.
Try this:
-- (motion sensors)
for k, v in pairs(luup.devices) do
if v.category_num == 4 and v.subcategory_num == 3 then
luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", "0", k)
end
end
-- (door sensors)
for k, v in pairs(luup.devices) do
if v.category_num == 11 and v.subcategory_num == 0 then
luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", "0", k)
end
end
[/quote]
Thank you RexBeckett, works perfectly! I manually set a couple motion sensors to “Tripped” = 1 and then ran the code. Everything is untripped now :-).
Best Home Automation shopping experience. Shop at Ezlo!