Notify based on presence, now or later


#1

I am wondering how I might go about sending a push or sms to a contact when a trigger occurs, and if a presence sensor is present, notify immediately.

But if presence sensor isn’t present when the trigger occurs, then wait but send notification after the next time presence sensor arrives.

Is there a way to do this? Thanks.


#2

I think it should be fairly straight forward within a single piston using a variable…

So you’d say…

  • When you depart, blank out the variable.
  • When some low priority event happens, add it to the variable.
  • When you arrive (or if you’re already present), sms / push the variable contents.

For example…

  • Cat uses the litter box at 2pm and you’re home, deliver the message.
  • You depart at 2:30pm
  • Cat uses the litter box at 3pm and you’re away, $message = ‘cat used the litter box.’
  • Dog opens the fridge at 3:30pm, $message = $message + 'fridge was open. ’
  • You arrive at 4:00pm, piston fires and delivers $message to you

The only problem would be that variable growing out of control if you monitor something that changes frequently while you’re away, so maybe using a fixed size array and delivering a preset number of events would be better.


#3

Hmm, ok. My understanding of all this stuff is very limited, so I appreciate your help.

Reading the wiki, I can sort of understand that some information can be stored in the variable.

So in this case, the variable is set to contain the message I want to send, as a string? I see that a variable can be local, global, or system. Should I define a local variable at the start of the piston?

To clarify further, what I’m hoping to accomplish is something like this:

If virtual switch turns on and presence sensor is present, send message immediately.

If virtual switch turns on and presence sensor isn’t present, send message when presence sensor arrives.

The virtual switch is a momentary switch that gets turned on by IFTTT when my wemo humidifier runs out of water.


#4

Yeah I think what you want to do is pretty clear… I was thinking of implementing something similar but more to use as a sort of framework to relay “reminders” or things that don’t need immediate attention, but that eventually I’d want to get to anyway… :slight_smile:

I think if you use something like this, with some tweaks, it should work…

Basically if the switch changes, then set the variable to hold the message (in your case “humidifier is out of water” or whatever).

Then you check the presence sensor… if the message is not blank and you arrive, or you’re already present, then send the message as a notification. That means every time the switch changes you would be notified if you’re home, or when you arrive.

When you leave, the variable is “reset” so that it would only have the message if the switch changed while you were away.

At least I think that would work, but there are probably 100 ways to do this better :slight_smile:


#5

That’s awesome, thanks!

So far it’s working fine with the presence sensor present.

I’ll see how it goes when the presence sensor leaves.