Author Topic: Creating alarm for both Time AND State of switch  (Read 287 times)

Offline iflatow

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Creating alarm for both Time AND State of switch
« on: August 12, 2017, 12:46:08 pm »
Need help creating scene with just scene creation tools on Vera, for an alarm that goes off at 10 pm if a door has been left open. I tried combining a trigger of both device (door switch) and time (schedule) but alarm went off at desired time, regardless of whether door was open or closed.  I need an "and" to include both time and device. Looks like what Vera scene creator has in an "or" situation. Of course, I may (probably?) be missing something. Suggestions are welcome. Thanks.

Offline jswim788

  • Hero Member
  • *****
  • Posts: 538
  • Karma: +29/-2
Re: Creating alarm for both Time AND State of switch
« Reply #1 on: August 12, 2017, 05:01:05 pm »
See this post for some examples.  You'll set you scene to run at 10 PM, then qualify it with conditional code in your scene.  http://forum.micasaverde.com/index.php/topic,18679.msg141959.html#msg141959

You need to change it to be a security sensor instead of a switch, so it might look like this:
Code: [Select]
local tripped = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", dID)
return (tripped == "1")
that will get the status of the sensor, and if it is equal to the string "1", it will return true which will allow the scene to run.  Otherwise the scene won't run.  Do remember to change the dID to the actual device ID of your sensor.

Offline HarryB

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Re: Creating alarm for both Time AND State of switch
« Reply #2 on: August 13, 2017, 03:34:30 pm »
I made a mistake in describing my situation. It is NOT a door switch I have, but a door sensor. The sensor shows "red" on the controller page when the door is "open". So it knows that the door is open. So did I need the "conditional scene execution?"

1. Why can I not set up a scene just "test" to see if that sensor is "red" (door open) at a certain time, e.g. 10pm, and set off the alarm if it is?

2. Do I still need to insert this code (for an ID #23)
local tripped = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", 23)
return (tripped == "1")

Sorry to be so dense...

Thanks.

Offline jswim788

  • Hero Member
  • *****
  • Posts: 538
  • Karma: +29/-2
Re: Creating alarm for both Time AND State of switch
« Reply #3 on: August 13, 2017, 04:25:42 pm »
I think you are asking why the AND function is not built in without the lua code.  And the answer is that Vera just hasn't provided that yet, but it is coming.  If you use the iOS app, you can have it now with the latest firmware.  And if you are willing to load other plugins such as PLEG or AltUI, you can get it there too. But the AND simply isn't there yet for scenes at this time in the standard GUI, so you have use a small bit of lua or use the other plugins.

#1 is exactly what I described.  The scene triggers at 10PM, checks to see if the door is open, then runs the scene if true.

In the web GUI, go to the devices page, click on the door sensor device you will use, click on the advanced tab.  That will show the Device ID (23 in your example).  Scroll down and you'll see the variables for the device.  Probably you'll see "Tripped" there.  If not, maybe "Status"?  In either case note what it is, and hover your mouse over the variable.  This will show you the Service ID.  It is very likely to be the URN string I list below.  If it is "Tripped" and the same URN, then use the code I posted.  If not, modify to match appropriately.  It's a little confusing at first, but not too hard once you get used to it.  You are simply identifying the variable you want to test and you need the variable name, the Service ID, and the Device ID in order to do that.  Once you have those 3, it's easy to check the value.


Offline HarryB

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Re: Creating alarm for both Time AND State of switch
« Reply #4 on: August 13, 2017, 06:08:41 pm »
I tried the IOS app. Two triggers...time and sensor.  Checked box "only if all triggers are tripped at same time."
Success!  BTW, when I tried "hovering" over the variable in the GUI, nothing happened.  No service ID appeared.

Thanks for your thoughtful and prompt help.

Ira



I think you are asking why the AND function is not built in without the lua code.  And the answer is that Vera just hasn't provided that yet, but it is coming.  If you use the iOS app, you can have it now with the latest firmware.  And if you are willing to load other plugins such as PLEG or AltUI, you can get it there too. But the AND simply isn't there yet for scenes at this time in the standard GUI, so you have use a small bit of lua or use the other plugins.

#1 is exactly what I described.  The scene triggers at 10PM, checks to see if the door is open, then runs the scene if true.

In the web GUI, go to the devices page, click on the door sensor device you will use, click on the advanced tab.  That will show the Device ID (23 in your example).  Scroll down and you'll see the variables for the device.  Probably you'll see "Tripped" there.  If not, maybe "Status"?  In either case note what it is, and hover your mouse over the variable.  This will show you the Service ID.  It is very likely to be the URN string I list below.  If it is "Tripped" and the same URN, then use the code I posted.  If not, modify to match appropriately.  It's a little confusing at first, but not too hard once you get used to it.  You are simply identifying the variable you want to test and you need the variable name, the Service ID, and the Device ID in order to do that.  Once you have those 3, it's easy to check the value.

Offline jswim788

  • Hero Member
  • *****
  • Posts: 538
  • Karma: +29/-2
Re: Creating alarm for both Time AND State of switch
« Reply #5 on: August 13, 2017, 09:20:02 pm »
BTW, when I tried "hovering" over the variable in the GUI, nothing happened.  No service ID appeared.
In the web GUI, not the iOS GUI, right?  And you hover over the variable name on the left, not the value on the right.