Help creating notification with limitations


#1

I’d like the following to happen, and I’m not sure how to go about programming it:

I have a push notification come to my phone when my girlfriend arrives or leaves the house. However, there are certain times that this is not helpful information. Specifically, I don’t want it to go off when we both leave or arrive together. I’d like it to go off when I’m there and when I’m not there, but not go off if we are leaving or arriving at the same time.

I was thinking that setting some sort of delay before evaluating the presence condition might work, but there is some variability in how accurate/quickly smart things presence changes.

Thought?

Thanks


#2

So let me understand the scenarios you want to cover:

You’re already at home and GF arrives/departs > Send notification
You’re not at home and GF arrives/departs > Send notification
You both arrive/depart together > Don’t send notification

If that’s what you want…then the problem I see is what to do if her presence is detected before your presence is detected when you both arrive/depart together. One of you will be detected first…that’s a guarantee. There’s no such thing as “the same time” when you’re talking about milliseconds…which we are here.

So in order to account for that…I think you will have to get a bit fuzzy with the time when you do the checking.

Because it all falls apart if, for example, her presence is detected first, your presence is still away because you’ve not been detected yet…(but will be in another 10 seconds perhaps). So I do think that you need to bake in some sort of delay otherwise you’re not going to account for that.

However, if your presence is detected as having changed first…then you’re all good.

I think I might have this… Take a look. You might need to fuss with the numbers some…but give this a shot.


#3

thanks for your input. I’ll give this a try.

I edited this and doubled it. I set GFPresence to “change to” present or not present and then to send the message “GF has arrived” and another time for the message “GF has left”

is there a simpler way to to specify the correct message based on whether she arrives or leaves?

thanks again


#4

Yeah, instead of duplicating the whole thing…once you know you need to send the message just do a simple:

IF GFPresence is Present then
Arrived message
Else
Departed message

OR if you really want to get fancy you could create an Expression for the message that you want to send and use that for the text.

Something like:

[GFPresence : presence] == ‘present’ ? “GF has arrived” : “GF has left”

I’m not positive that expression is exactly the proper syntax…but that’s pretty close.


#5

Although now that I think about it… It might not be a bad idea to keep them split up…because then you could add some more code to say something like:

IF GF Presence changes to present
and
MyPhone presence is present
and
MyPhone has been home for quite some time (whatever…30 minutes let’s say…use the age command for this)
Then send the message immediately
ELSE
Wait 30 seconds
Then test again

That way you get the message right when she arrives instead of having to wait for 30 seconds to get it.

And…you’d just do the opposite for when she leaves…unless you don’t care about a 30 second delay then.


#6

This sort of works. I’ve got a couple of issues.

presence sensor 2 = GF
presence sensor 3 = me

first is that “age” doesn’t seem to have a positive or negative value with relation to presence. it’s only since the last event occurred. So I had to add the modifier add the modifier of whether or not I’m present, but this seems to work fine.

Second, I’m having trouble using “presence changes” as my trigger. by the time things are re-evaluated 30 seconds later “presence changes” is now false and it won’t send the message. I’ve not been able to come up with an elegant solution for this.

also, just ignore the lockCodes stuff… none of that works.


#7

Yeah, that can happen. The default behavior of a piston is to cancel the pending tasks if the Trigger that initiated the piston is no longer true…and when you add a Wait in there (which you really do need in this piston) it really makes that behavior stand out.

But there is a way to change the default behavior of the piston to make it Never Cancel the pending tasks. To do that you modify the statement block that needs to never cancel (sometimes you have to test this a few times to get it in the right spot). Just click on the cog icon and make the changes in there.

image


#8

Things have been working fairly well, but now she wants to get the same notifications about me. So far, I’ve just duplicated and changed the names, but there must be a more elegant way to accomplish the same thing.

anyone have thoughts on how to streamline this?

thanks