Thanks Parkerc, I had a feeling that there are more than just door/window sensors in category 4 but it was a simple starting point. Can anyone think of a specific attribute of these devices that is unique? I noticed that when I check the type of my devices, the Wintop sensors show up as motion sensors, and my Schlage sensors show up as window sensors so type doesn’t seem reliable either. Since The names of all of my sensors have either the word “door” or “window” in them, I could add a string.find() command to look for either “door” or “window” in the description.
Thanks
Pasqual
You then need to look at sub-categories but as you may find, they are either not defined or incorrectly defined.
http://wiki.micasaverde.com/index.php/Luup_Device_Categories
Hi Pasquel
As it is now - it actually works nicely for me as an ‘occupancy checking tool’ as the Ping sensor is used to track a few mobile phones.
Good idea about adding a filter, maybe if your code could allow for optional filters - so you could go from the top level Device, to the service, and then (if needed) down to aspects of the device description itself - that would certainly give it flexibility to be used for any broad or specific set of TTS checks you would want done.
Another idea for you…
- add the ability to retrieve and use the ‘name’ of the room the sensor is in to the TTS - that way it could say “the door is open”
I’ll definitely look into subcategories but was worried that one improperly reported device would mess that up. That’s why I just decided to put the words “door” or “window” in the description. Of course there could be other devices with those words in there too!
Parkerc, I was going to retrieve and announce the room name for the devices, but my descriptions for the door & window sensors have the room name in them (i.e. Family Room Window 1, Front Door) bottom line is it would be minimal coding to add room names in if needed.
Thanks
Pasqual
Thanks @Pasqualz
I understand, people will have different set ups and like you I also have a some devices that have the room name in the description, however since adopting the room approach, I’ve tried to change more of them over.
Keep up the good work, I like what you’ve done, mix your code with the random words post (previous page) and that could make it a little more dynamic/different.
I’m always excited to see how people are building TTS with Vera and Sonos - so please keep sharing ![]()
Hi I just came across Pasqualz’ script by accident and it addresses something I posted in a couple of other forums. I also want to announce tripped window and door sensors. I am trying to limit it only to door and window sensors though and not quite sure I understand what is going on. I thought I could just change the device in the following line to urn:schemas-micasaverde-com:device:DoorSensor:1, but that does not seem to work and it just reports all as closed. Why is this? Is there another way I can strip out motion sensors from the list?
local tripped = luup.variable_get(“urn:micasaverde-com:serviceId:SecuritySensor1”
Excellent work by the way!
If I have understood you correctly - it looks like you have tried to replace a ‘serviceId’ with a ‘device’. These are different things.
I’m not entirely sure how to do it myself, but you will need to add a device filter first, so it looks just for that device type, and then check for the serviceId or you could do it the other way round.
So when it finds everything that has tripped it then only speaks the ones that are a door/window sensor device.
I worked it out by adding subcategory in as motions are 3 and door window sensors are 1.
Cheers
Hi @borat
Great news - Feel free to post your updated code so others can make use of it
Sure here you go:
– Door/Window sensor check and speech annotation by Pasqual Zottola
local vol = 60
local son = 23
local devcnt = 0
local devno = 0
local numopen = 0
local isare = “is”
local opensensors = " "
luup.log(‘Commencing sensor device search loop’)
for deviceNo,d in pairs(luup.devices) do
if d.category_num == 4 and d.subcategory_num == 1 then
local tripped = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", deviceNo) or "Nil"
if (tripped == "1") then
opensensors = opensensors .. ". " .. d.description .. ","
numopen = numopen + 1
end
luup.log(d.description … ’ status:’ … tripped … ’ Dev #’ … deviceNo … ’ id:’ … d.id … ’ cat #:’ … d.category_num … ’ type:’ … d.device_type)
devcnt = devcnt + 1
end
end
if numopen == 0 then --If there are no sensors tripped, log and announce!
luup.log(‘There were ’ … devcnt … ’ door and window sensors found and all are closed’)
luup.call_action(“urn:micasaverde-com:serviceId:Sonos1”, “Say”, {Text=devcnt … " sensors were checked, and all are closed. House is secure. Goodbye!", Language=“en”, Volume=vol}, son)
else --If there are any sensors tripped, log and announce!
if numopen > 1 then
isare = “are”
end
luup.log(‘There were ’ … devcnt … ’ door and window sensors found and ’ … numopen … " " … isare … ’ open’ … opensensors)
luup.call_action(“urn:micasaverde-com:serviceId:Sonos1”, “Say”, {Text=“Warning! House may not be secure,” … devcnt … " sensors were checked and " … numopen … " " … isare … " open. Check," … opensensors, Language=“en”, GroupDevices=“32”, Volume=vol}, son)
end
Hi
I’m a non-programmer.
I was able to use this code to a certain extent. Some how I was not able to get the TTS work on this. I changed the device name to match mine in two places before using this code.
Any help is appreciated.
Sharad
[quote=“sharadmenawat, post:111, topic:173177”]Hi
I’m a non-programmer.
I was able to use this code to a certain extent. Some how I was not able to get the TTS work on this. I changed the device name to match mine in two places before using this code.
Any help is appreciated.
Sharad[/quote]
We may be able to help if you post the actual Lua code you are using and explain what does and doesn’t work.
I’ve used the code given below. I was able to get change notifications when run the scene but some how the TTS part never returned the voice prompts. I changed the name for Sonos as it is in my Vera3.
Code:
– Door/Window sensor check and speech annotation by Pasqual Zottola
local vol = 60
local son = 23
local devcnt = 0
local devno = 0
local numopen = 0
local isare = “is”
local opensensors = " "
luup.log(‘Commencing sensor device search loop’)
for deviceNo,d in pairs(luup.devices) do
if d.category_num == 4 and d.subcategory_num == 1 then
local tripped = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", deviceNo) or "Nil"
if (tripped == "1") then
opensensors = opensensors .. ". " .. d.description .. ","
numopen = numopen + 1
end
luup.log(d.description .. ’ status:’ .. tripped .. ’ Dev #’ .. deviceNo .. ’ id:’ .. d.id .. ’ cat #:’ .. d.category_num .. ’ type:’ .. d.device_type)
devcnt = devcnt + 1
end
end
if numopen == 0 then --If there are no sensors tripped, log and announce!
luup.log(‘There were ’ .. devcnt .. ’ door and window sensors found and all are closed’)
luup.call_action(“urn:micasaverde-com:serviceId:Sonos”, “Say”, {Text=devcnt .. " sensors were checked, and all are closed. House is secure. Goodbye!", Language=“en”, Volume=vol}, son)
else --If there are any sensors tripped, log and announce!
if numopen > 1 then
isare = “are”
end
luup.log(‘There were ’ .. devcnt .. ’ door and window sensors found and ’ .. numopen .. " " .. isare .. ’ open’ .. opensensors)
luup.call_action(“urn:micasaverde-com:serviceId:Sonos”, “Say”, {Text=“Warning! House may not be secure,” .. devcnt .. " sensors were checked and " .. numopen .. " " .. isare .. " open. Check," .. opensensors, Language=“en”, GroupDevices=“32”, Volume=vol}, son)
end
I changed the name for Sonos as it is in my Vera3.
You have changed the service ID in the action calls. This is a constant regardless of what you call the device on your system. Change them back to “urn:micasaverde-com:serviceId:Sonos1” as in the original code.
RexBeckett - I made the change and created a new scene for testing. I created a scene where a door sensor activates and then expects TTS output. But the TTS output not played on Sonos.
Can you confirm TTS works normally , when you just enter text into the device ?
Also, please post the code you are testing here. That way people can help you see if any errors exist,
[quote=“parkerc, post:116, topic:173177”]Can you confirm TTS works normally , when you just enter text into the device ?
Also, please post the code you are testing here. That way people can help you see if any errors exist,[/quote]
Yes the TTS works when I enter the text in TTS box and use “Say”.
The code I’m using is posted below:
– Door/Window sensor check and speech annotation by Pasqual Zottola
local vol = 60
local son = 23
local devcnt = 0
local devno = 0
local numopen = 0
local isare = “is”
local opensensors = " "
luup.log(‘Commencing sensor device search loop’)
for deviceNo,d in pairs(luup.devices) do
if d.category_num == 4 and d.subcategory_num == 1 then
local tripped = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", deviceNo) or "Nil"
if (tripped == "1") then
opensensors = opensensors .. ". " .. d.description .. ","
numopen = numopen + 1
end
luup.log(d.description … ’ status:’ … tripped … ’ Dev #’ … deviceNo … ’ id:’ … d.id … ’ cat #:’ … d.category_num … ’ type:’ … d.device_type)
devcnt = devcnt + 1
end
end
if numopen == 0 then --If there are no sensors tripped, log and announce!
luup.log(‘There were ’ … devcnt … ’ door and window sensors found and all are closed’)
luup.call_action(“urn:micasaverde-com:serviceId:Sonos1”, “Say”, {Text=devcnt … " sensors were checked, and all are closed. House is secure. Goodbye!", Language=“en”, Volume=vol}, son)
else --If there are any sensors tripped, log and announce!
if numopen > 1 then
isare = “are”
end
luup.log(‘There were ’ … devcnt … ’ door and window sensors found and ’ … numopen … " " … isare … ’ open’ … opensensors)
luup.call_action(“urn:micasaverde-com:serviceId:Sonos1”, “Say”, {Text=“Warning! House may not be secure,” … devcnt … " sensors were checked and " … numopen … " " … isare … " open. Check," … opensensors, Language=“en”, GroupDevices=“32”, Volume=vol}, son)
end
I see that you are using a device number of 23 for your Sonos - as in the original code. I doubt that, by co-incidence, your Sonos is the same device number as the codes’s author. Change this line:
local son = 23
to use the actual device number of your Sonos. You can get this from the Sonos device’s Advanced tab.
I see that you are using a device number of 23 for your Sonos - as in the original code. I doubt that, by co-incidence, your Sonos is the same device number as the codes’s author. Change this line:
local son = 23
to use the actual device number of your Sonos. You can get this from the Sonos device’s Advanced tab.[/quote]
Yes this made the Sonos speak up
but now when there are tripped devices I’m hearing only one message “Zero devcices are checked and all are closed. House is secure. Good Bye”
This is false sense of security. Can you help here?
Sharad
Yes this made the Sonos speak up ;) but now when there are tripped devices I'm hearing only one message "Zero devcices are checked and all are closed. House is secure. Good Bye"
You will get this message if the code does not find any devices in your system where the device_category is 4 and the sub_category is 1 (door & window sensors).
What sensors are you using? Check on each device’s Advanced tab for the values in the category_num and subcategory_num fields. You may need to modify the code to suit your mix of devices.
FYI: These are the standard Device Categories.