Rule creation based off of location

Hello. I am new to the whole home automation thing, and very new to Sharptools. I have created several cool rules, utilizing the connection between my SmartThings hub and SharpTools. I am having trouble coming up with the right steps (maybe it’s not even possible) for a rule.

Both my phone and my wife’s phone are authorized within SmartThings, to be used for location. The location setting on both phones is such that SmartThings can use location “Always”. What I want to do is if I or my wife come home at the same time, or if one of us comes home while the other is still away , that certain lights will come on, but only if between 7:30pm & morning.

I tried a different “simple” rule using location, but it took almost 7 minutes for SharpTools to update my location as “Present”, which would be a problem for the rule I am trying to create above.

Thank you in advance for any help and time you can give.

Hi @Ridyn_2007, welcome to the community. The location (presence) updates slowly is somehow expected based on many SmartThings users’ experiences. Many SmartThings users choose to use Life360, which is a mobile app that you can download on your phone. Then you can use a community developed Life360 smartapp to bring Life360’s presence data to SmartThings. This particular way has been working very reliable and timely for me personally.

Here is the rule example based on your description, and please note that I changed the IF condition’s logic from ALL(AND) to ANY(OR) because once it passes the midnight, it is considered as the next day.

@James thank you. My wife and I do already have Life360 accounts. The integration was a bit more complicated than I was expecting, but I did find some code at GitHub, and integrated the smartapp code and device handler within IDE. Is that still the correct what to do it?

As far as the logic in SharpTools, I am trying to make it, where if my wife is already at home, the lights do nothing.

My goal would be to have the lights come on in the following situations:

  1. When just I come home, while wife is away.
  2. When we are gone together, and come home at the same time.
  3. Or when my wife comes home, while I am away.

The second one is the one that’s causing me trouble.

Thank you.

Yes, the link I included was the smartapp I use for my Life360 device in SmartThings.

This is a hard one due to the timing gap between your wife’s and your Life360 arrival events. You can check the event history in SmartThings IDE site or SmartThings mobile app to see the timing difference when both you arrive home at the same time. I think it can be several seconds to minutes apart because it has to rely on the phone (Life360 app) to report the status, and there can be many factors causing the slight timing difference.

You can always add a DELAY in the rule flow before an IF condition, then check if both of you are present, but I think it becomes pointless if it has to wait more than 10 seconds to decide whether it should turn the light on or not though.:confused:

@James hank you. Somehow I over looked the link you provided. Here is what I did. I created a few rules:

Rule 1. When wife leaves home, set variable ‘saraisgone’, to True.

Rule 2. When my wife comes home between sunrise and sunset and I am not home, turn on the lights, delay for a few minutes then set ‘saraisgone’ to False.

Rule 3. When I come home between sunset and sunrise and Sara is “not present” OR ‘wifeisgone’ is true, turn on lights.

There could be a case (though unlikely) That when we come home at the same time our status can change to “present” around the same time. Then the light would not turn on. I think I have the proper work around in step 3.

SO, if both of our statuses change to present at the same time, there is still the OR statement that will still see the ‘wifeisgone’ variable as True, because of the delay. Therefore lights should turn on. Step 3 should also work in the case of us not arriving home at the same time.

I am trying to explain this best that i can. haha I am still trying to wrap my head around that this will work.

1 Like