Triggered Audio based on opened contact also plays on motion? Argh

motion
triggers
piston

#1

This piston is plays a message when a contact opens. Example: If the front door opens… speak “Someone opened the front door”

However after a message has been spoken the next time any of my motion detectors goes active the last ‘message’ is spoken again. Example. I get up… open the door I “someone opened the front door” is spoken. Shortly after I walk in to a room, the motion sensor for that room goes active and I hear “someone opened the front door”.

but… it only happens once… meaning if I wait and then walk in the room again and motion is triggered again nothing is spoken.

I’m using VLC Thing for the audio.


#2

I don’t see any reference to any motion sensors in your piston above…


#3

and that is the problem! :wink:


#4

What I mean is, you’ll have to look at any pistons that are triggered by the offending motion sensor to get to the bottom of this.


#5

I’ll have to dig thru them and see but Im almost certain I don’t have anything that that would change the state of a contact.


#6

I just thought of another possibility… With your current code, anytime any of the 5 contact sensors opens (or closes), the piston runs top to bottom. I believe the phrase “contact changes to open” remains true for 10 seconds after the event.

So, for example, if you open “Contact Sensor 7”, it should say, “Someone opened the front door”.
The trick is, if any of those 5 doors closes within the next ten seconds, the same speech would be repeated. Also, if location mode changes to anything except Sleeping (within those 10 seconds) the old phrase would be repeated, since that is the only block of code that is true at the time.

Your mileage may vary, but I try to keep only one device as a trigger per piston to keep stuff like this from happening.


#7

This is something to think about for sure. Perhaps adding a ‘wait 10’ would help. I just did some testing and I can tell you that if I open and close it 2 times in less than 5 seconds most of the time I get 2 spoken alerts. If wait 8 seconds I always get 2. If I open 2 different doors 1 second apart the second alert cuts off the first one. Something like
“someone opened the gara… someone opened the front door”
I’m totally ok with all of that.

BUT whats so weird is this thing with the motion doesn’t happen a few seconds later it can be HOURS later. Meaning I open the door at 1pm “someone opened…” and then at 4pm I can walk in a room, trigger motion, and get “someone opened…”. always whatever played last.


#8

Just for clarification, what I was trying to find the words to say before:

If you open front door, wait 5 seconds, and then CLOSE a door, then both phrases should announce the front door was opened.

I do not think the 10 seconds would help in this case, but feel free to experiment.
(my advice is still to keep one trigger per piston)


This baffles me too, and I am blind without seeing the code for the offending motion sensor.


#9

OK I hate to say it but I was being a dummy… I had “speaker companion” set to “play” whenever a light came on. I can’t believe I forgot I had been testing that! Argh.


#10

LOL, been there, done that, and got a box of Tshirts to prove it, hehe


#11

I think I will split it in to multiple pistons but I already ‘feel’ like I have too many. BTW… how many pistons do you have?


#12

I currently have 262 pistons…
(although, to be honest, about 150 of them are pistons that I made to help others, so are currently paused)

The best advice I could give is to structure your pistons around a trigger.

For example, one piston to monitor the front doors contact. All logic for that device (time, who is home, etc) can be conditions in that one piston.


#13

I thought I had a lot at 49… lol


#14

Not everyone takes this approach, but I go out of my way to make sure that only one piston runs top to bottom at any given event. So, even though I have many pistons, my network traffic is kept to a minimal, and my response times are super snappy.


#15

Do you you consider this 2 triggers?


#16

I guess technically it is, but it is only one device and only one parameter that it is subscribed to, so I often consider it one. (when the Switch20 flips in either direction, the code runs from top to bottom, but only one block will be executed) This is well written, in my opinion.


For clarification, I would consider the following example to be two triggers:

IF FrontDoor’s contact changes to open
Then do stuff
End IF

IF FrontDoor’s temperature changes
Then do stuff
End IF

This example will work 98% of the time, but occasionally the two will change within 10 seconds of each other, and you may get unexpected results.