Assistance with logic (presence, contact, motion, speak)

Trying to get my head wrapped around this but the ideal is…

When presence 1 or 2 shows up… then if door 1 or 2 opens… then if motion sensor goes active… speak.

Using various standalone conditions and triggers work just fine in their component parts. I can’t seem to be able to string it together. A side shoot is I’m also trying to understand under what circumstances a piston waits for the next event.

For example, if I used Followed By, does it wait indefinitely for that trigger or if something else happens like a switch is thrown does the piston reset? Same thing about the Then-If…

My ap[quote=“8BitNinja, post:1, topic:73998”]
When presence 1 or 2 shows up… then if door 1 or 2 opens… then if motion sensor goes active… speak.
[/quote]

My approach, though probably not the most efficient due to my limited experience, would be:

Basic Piston

IF motion sensor changes to active AND contact sensor changed in the last {expected time between opening door and passing sensor} AND presence changed in the last {expected time between arrival and passing sensor} THEN speak. .

Hmmmm thanks for that. So thinking about it in reverse where the actual last trigger is motion…

Right. Since it’s easier for us to look back and see what happened.

Oh, also, you’ll have to use group conditions for your 1 or 2 conditions.

So, it would look something like:

  • IF motion sensor changes to active
  • AND
  • Any of Presence1 or Presence2 changed in the last X minutes
  • AND
  • Any of Door1 or Door2 contact changed in the last X minutes
  • THEN
  • speak

Now all I have to figure out is how to strip the values out to speak such as which contact, which Motion Sensor, who’s presence device…

You could probably use an ELSE-IF for that. Just speculating, as it’s bed time, and I’m too sleepy to open Core:

ELSE-IF Piston

  • IF (motion AND Presence1 changed in the last X minutes) AND GROUP [Any of Door1 or Door2 contact changed in the last X minutes] THEN speak to Presence1
  • ELSE IF (motion AND Presence2 changed in the last X minutes) AND GROUP [Any of Door1 or Door2 contact changed in the last X minutes] THEN speak to Presence2

Theoretically, an OR-IF should work as well.

Thanks, I think I’ll handle the “who” presence separately by running a piston that evaluates between both, one or the other is present and sets a string variable with “sir”, “ma’am” or “everyone”. I think in concept that might work – then I just reference the variable in the “speak”.

Something like this maybe.
The 10 minute window for the variable is if I’m walking home and perhaps have a chat with the neighbour.
You can add a door sensor in as well.