We have moved at community.getvera.com

Author Topic: Repeated notifications on Trigger  (Read 2606 times)

Offline agold

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Repeated notifications on Trigger
« on: September 02, 2013, 09:57:51 pm »
Newbie here.  I replaced my homeseer trial with a Vera Lite.  I've integrated it with my Caddx NX-8E.  With HS I was able to monitor when a door was opened or closed no matter the armed state.

I set up a scene to watch for the door sensor to be tripped, and I have a custom Luup script to send an email.  The issue is that I get repeated emails for as long as the door is open.

Is there a way to test for a status change from not-tripped to tripped as a condition to sending the notification.

Thanks.

Offline garrettwp

  • Master Member
  • *******
  • Posts: 6371
  • Karma: +227/-128
  • Vera 3, Lite, ISY994
Re: Repeated notifications on Trigger
« Reply #1 on: September 03, 2013, 12:51:51 am »
This would require some luup / lua code in the scene. You might want to have a look at the PLEG Plugin as it might be an easier route than to add code into the scene.

- Garrett

Offline futzle

  • Moderator
  • Master Member
  • *****
  • Posts: 3260
  • Karma: +192/-9
Re: Repeated notifications on Trigger
« Reply #2 on: September 03, 2013, 07:52:32 am »
Is there a way to test for a status change from not-tripped to tripped as a condition to sending the notification.

Sure there is. How about you post your existing code so that we can show you the smallest possible change to get what you want? Also how you've integrated it; it sounds like you are running the scene every n minutes.

But first... I would do this by making a scene that is triggered on the sensor becoming tripped, using the built-in Vera scene trigger mechanism. This will fire only when the sensor changes state from Not Tripped to Tripped. The scene's Luup code then performs the notification each time it fires.

I admit being a mite confused: why you've avoided the standard mechanism for acting on a state change (a scene with a trigger) and rolled your own isn't clear to me. Have you tried it and found it didn't do what you wanted? Or are you missing some basic Vera configuration knowledge?  Not trying to be disrespectful, I just want you to get what you need the easiest way possible.

Offline agold

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Re: Repeated notifications on Trigger
« Reply #3 on: September 03, 2013, 12:09:57 pm »
I believe I am using the built-in scene trigger mechanism.  I just wanted to add loup code to send a custom email via my own email server instead of via MIOS.

I set up a scene. under 'Devices' I did not select anything. Then 'Trigger' I selected "Device is Tripped"  with nothing under 'Luup Event'. Nothing under 'Schedule'.  Under 'Luup' I added code that just generates an fixed email.  Under 'Advanced' I did not select anything.

Offline futzle

  • Moderator
  • Master Member
  • *****
  • Posts: 3260
  • Karma: +192/-9
Re: Repeated notifications on Trigger
« Reply #4 on: September 03, 2013, 06:29:51 pm »
I believe I am using the built-in scene trigger mechanism.

I take it back, yes you are.

I don't have any door sensors connected to my NX-4, but I faked it by sending a repeated luup.variable_set() to trip a motion sensor, without letting it untrip in between.  And yes, it does repeat.  I didn't know that.

So I went and investigated the standard SecuritySensor1.xml service file (which the Caddx plugin uses).

Code: [Select]
<stateVariable allowRepeats="yes">
  <name>Tripped</name>
  <sendEventsAttribute>yes</sendEventsAttribute>
  <dataType>boolean</dataType>
  <shortCode>tripped</shortCode>
  <defaultValue>false</defaultValue>
</stateVariable>

It's that "allowRepeats" that's causing the additional trips each time the alarm panel decides to send an update to the plugin (which it does every so often).

So, I learned something.

Now, to solve your problem.  Two ready-to-roll options are to use the Program Login plugins as Garrett pointed out, or to use a Combination Switch.  Both will flatten out the Tripped value into a simple true/false without any of those pesky repeats.

If you want to continue to use your Luup code, you can use a global variable (here called DoorTripped, but you can choose anything) to track the previous state.  Change it to something like this:
Code: [Select]
if (not DoorTripped) then
  -- your existing notification code here.
end
DoorTripped = true

Then make a corresponding scene for the door becoming untripped, and put its Luup code as:
Code: [Select]
DoorTripped = false

Offline agold

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Re: Repeated notifications on Trigger
« Reply #5 on: September 04, 2013, 02:06:23 pm »
Thank you.  I'll try what you suggested since I am not sure how to use PLEG yet.

In your XML, what is the difference between having "AllowRepeats" yes vs no.  Is this a change that would also fix the issue?

Again, thank you.

Offline futzle

  • Moderator
  • Master Member
  • *****
  • Posts: 3260
  • Karma: +192/-9
Re: Repeated notifications on Trigger
« Reply #6 on: September 04, 2013, 05:45:06 pm »
In your XML, what is the difference between having "AllowRepeats" yes vs no.  Is this a change that would also fix the issue?

Probably it would produce the behaviour you expect if allowRepeats were set to "no".  But that isn't my file, it comes with the Vera, and I have to assume that MCV wanted it that way for a reason.