Distance Relationship Between 2 or More Webcore Presence Sensors


#1

1) Give a description of the problem
Looking for a piston that compares the distance between 2 or more webcore presence sensors.

2) What is the expected behavior?
For instance, at 3pm every weekday, send me a push notification if Presence A is not home, unless Presence A is within 250 feet of Presence B.

The goal is to get an alert if kids are not home from school by a certain time, unless Mom and/or Dad are with them.

I’m wondering if this is even possible given the existing capabilities of Webcore presence.

3) What is happening/not happening?
I can’t find an existing condition or trigger to accomplish this.

**4) N/A

**5) N/A


#2

There’s no built in function for that.

But WOW… finally found a use for those boring Pythagorean Theorem excersises I had to do in school lol!

A squared + B squared = C squared, where C is the hypotenuse of a right angle triangle.

So, distance between two sensors is:

sqrt((sqr(abs([device 1 name : longitude] - [device 2 name : longitude]))) + (sqr(abs([device 1 name : latitude] - [device 2 name : latitude]))))


#3

That’s…that’s… genius! Pythagoras, eat your heart out!


#4

Of course that’s assuming the earth is flat, there is curvature of the earth to consider?


#5

lat / long already allow for (most) of that… think we are close enough lol :sunglasses:

image

But if you happen to live in a tower block, altitude might need to be considered.


#6

Suppose if you wanted to measure the hypotenuse across a curve you could always use this:

Haversine formula: a = sin²(Δφ/2) + cos φ1 ⋅ cos φ2 ⋅ sin²(Δλ/2)
c = 2 ⋅ atan2( √a, √(1−a) )
d = R ⋅ c
where φ is latitude, λ is longitude, R is earth’s radius (mean radius = 6,371km);
note that angles need to be in radians to pass to trig functions!

I’ll leave it to @Gopack2 to write the webCoRE expression lol