Help with Arrival routine

conditions
variables

#1

1) Give a description of the problem
Hi! I’ve recently migrated hubs and have (perhaps foolishly) committed to using the new ST app. As such I’m converting all of my previous Hello Home! routines to WC pistons. One thing I’m having particular issue with is my arrival routine.

In Hello Home, there was a condition that you could set to protect against presence false positives that essentially said, “Only if presence device has been gone for X number of minutes.”

I’m trying to recreate this in a WC piston using a variable as the presence device.

2) What is the expected behaviour?
I’m looking to determine who has arrived back at my home, put that into a variable, and run conditions off that. I think I have the first part but unclear how I construct the statement to say ”has this device’s presence been away for at least 7 minutes.”

I’ve shared a snapshot below. Wondering if one of the maestros here could help make this work. or am I thinking about it incorrectly.

3) What is happening/not happening?
Not able to construct the condition correctly.

4) Post a Green Snapshot of the pistonimage


#2

Hi Greg,

I might not be the maestro you are looking for :)) but here is a couple of things,

1 - I prefer 2 IFs and followed by another IF.
2 - I would ignore ELSE statement. I’m not a coder or a pro, but ELSE is somehow working different then regular coding (let’s call that lack of my knowledge)

IF any of sensors changes to PRESENT - single trigger
And
IF location mode is away - single condition
        then 
        IF {variablepresence} was not present in the last 7 minutes
        then
        Do this do that

        IF locaion is night or home
        Then 
        Do this do that

#3

Thanks @ike2018. I’ve rearranged the piston based on your feedback, but I’m still unclear how to write the above IF statement.

What comparison would I be using to construct this statement?

right now, this is the best I’ve got. but I’m not sure the “stays” comparison is it.


#4

Instead of EXPRESSION (you don’t need that), click on the blue box and you should be able to see DEVICE
scroll all the way down (until your actual devices are over) you’ll see your variable

Select that as a device,

In the picture I made a mistake,
I chose WAS NOT, NOT PRESENT…
instead you choose WAS, NOT PRESENT


#5

Oh! Yes. You are a maestro. Thank you.

I’ve got it now. Let me see if that does the trick on the false alarms.


#6

Piston is updated. I’ve attached the new version below.

This is probably more of a general WC question. But as you can see, now I have 3 IF statements within the same piston. Is it best practice to be setting the same variable from similar IF statements like this? Will this cause collisions?

Or should this be nested in a different way?

When 3 statements are in the same array (it think it’s an array), do they operate sequentially where the first statement has influence over the following statements? Or are they 3 distinct statements?

Thanks.


#7

I am not really in a position to comment on best practice as I really haven’t written an awful lot of pistons in the grand scheme of things. My particular focus is not so much what works, but why it works. So it was particularly welcome to see a piston where my initial reaction was “I didn’t think that would work, but it does” and so be able to improve my understanding (*).

I don’t see any issue with your grouping of the ‘if’ statements. It could perhaps be argued that it could be written more economically, but that is just one factor alongside ease of maintenance and ease of understanding. With your piston it is clear what is going on.

As for the conditions in your if block (array is probably not the best word but block is just a word I plucked out of the air in desperation, as when an if condition is made up of conditions that are conditions or triggers, you run out of unique terminology rather quickly), to the best of my knowledge they do get evaluated in sequence, so yes they can affect the next condition.

(*) It was the ‘was’ condition that had me pondering. If you wrote a piston including, but not being triggered because of, if sensor presence was not present for at least 7 minutes, it would return false if the current state was present. So I was wondering why it didn’t when looking at a list of devices that had all just changed to present. The ‘was’ comparison works by looking at the list of previous events from the device. It turns out it first checks if the current event involves the device attribute it is comparing, and if so it skips the first event. So the ‘was’ refers to how things were before the current run of the piston. Which is probably obvious to some.


#8

I bet there is a better way of writing this hence the disclaimer “I might not be the maestro you are looking for :))”

One of the reasons I love this forum so much is, we all share “opinions” some pro some amateur.
I test some of my postings beforehand but some, hell even I don’t know if it will work. I assume it will, but not 100% sure.

@WCmore & I work professionally outside of this forum. Some times he writes pistons for me and sometimes I write them and he oversees them.

when he looks at my pistons, I would expect that he would say

  • Good job grasshopper. You did well.

But he says,

  • Ok ike, your house, your piston BUT…
    :joy::joy::joy::joy:

If this forum were some sort of a customer service for webcore, I wouldn’t even dare to open my mouth:)))))))


#9

Did the last verison you posted work???

I normally stay away from “grouping” IFs. Don’t know why but I just feels better not to group.
I would do,

IF XYZ (trigger)
and 
IF abc (condition)
        Then 
        IF QWE (condition)

the last one is another IF within the first to IFs

Here is an example from my home:


#10

I admit, I try to teach during the process, but ultimately, the final decision is always up to the home owners… (a lot of my tips & guidance may be based on past issues I have encountered)


All that being said, Ike has definitely earned his “Top 5%” badge!! :+1:


#11

Yes! I think it’s working. No more false alarms as before. Keeping an eye on things this weekend.

Some hinkiness with the Push notification that gets fired. If my wife and I arrive at the same time, two notifications get pushed. Not the end of the world, but I’m going to try to finesse it in some way.

Thank you!