Page 1 of 1

Not New but I am Stumped

PostPosted: Wed Dec 20, 2023 12:09 am
by 300BlkPlinker
Trying to do some DIY geofencing. I have Ubiquiti UDM Pro and supported UI network gear (including APs). I simply want to know if my and the wife's IP have gotten close enough to the WiFi network to connect and then trigger against that knowledge. I have looked at Life360 and GeoFence Plug-ins. Also played around with simple shell script pinging the IP of my iPhone but doesn't seem consistent enough to Trigger against. Have static IP on phone. There are many things I want Idigo to do when I am home or away. What is everyone else doing for this Use case?

Re: Not New but I am Stumped

PostPosted: Wed Dec 20, 2023 6:01 am
by DaveL17
Apple Shortcuts has geofencing capability; however, it requires intervention by the device user to allow the trigger to fire each time (this is considered a safety feature which I totally understand). I don't presently use geofencing for automation, but I have set up fences with the Home Remote app for iPhone and it has been very solid.

Re: Not New but I am Stumped

PostPosted: Wed Dec 20, 2023 3:14 pm
by Londonmark
I do this using virtual devices published to HomeKit with HomekitLink Siri. That way you can run automations from the Home app without needing to authorise each time. Means outside lights come on when my wife or I get home etc. very easy to configure. You set triggers in indigo for when the virtual devices switch on and off.

Re: Not New but I am Stumped

PostPosted: Wed Dec 20, 2023 7:00 pm
by Different Computers
please make sure you are NOT using a private IP address option on any iOS device you might be using for presence detection. When connecting to your home network, that is.

Re: Not New but I am Stumped

PostPosted: Wed Dec 20, 2023 10:21 pm
by 300BlkPlinker
Will look at the HomeKit idea but I feel that I'm so close with some ping action. I have a shell script doing the heavy lifting of the ping, writing either True or False in /tmp/pingresults. How do I read that file so I can stick it into a variable?

Also tried doing a ping right inside the Condition of a new Schedule by using Python to run the ping. Leveraged ChatGPT and got a working python script I could run on my Mac but that script won't work inside the Schedule (Condition area). Is there a collection of generic Python scripts somewhere in the Forums for me to just get my head around how Python works inside Indigo. I have read through a bunch of the area called Indigo Object Model Reference.....but just looking for some practical scripts from top to bottom to do some interesting things. Any links in the Forum or just some raw (redacted if necessary) python from within Indigo Triggers or Schedules would be appreciated.

Re: Not New but I am Stumped

PostPosted: Thu Dec 21, 2023 8:08 am
by DaveL17
300BlkPlinker wrote:
How do I read that file so I can stick it into a variable?

You didn't specify in your post what the contents of the file looks like literally; is it a file that contains a single word:

Code: Select all
True
or is the latest result appended to the end of a list of results:

Code: Select all
True
False
True
...
I'll assume the former.

Code: Select all
file_name = "/tmp/pingresults"
with open(file_name, 'r', encoding='utf-8') as infile:
    output = infile.read()

indigo.variable.updateValue(12345678, output)  # Save the value as text to your variable
result = True if output == "True" else False  # Output is a string, so if you want the boolean value True/False, you need to convert it.
Scripts inside Conditions are expected to *return* something.

Code: Select all
file_name = "/tmp/pingresults"
with open(file_name, 'r', encoding='utf-8') as infile:
    output = infile.read()
return True if output == "True" else False  # if you don't return anything, the result is presumed to be False.
There's very little that's special about running Python scripts in Indigo. One example is that "print" statements don't work in Indigo script fields; you have to use "indigo.server.log()" instead.

Code: Select all
# Do this:
indigo.server.log("My text.")

# Not this:
print("My text.")
I would encourage you to head to YouTube and watch a series of videos by a cat called The Net Ninja -- they will really give you a leg up on basic Python. He is a superb teacher. Then you can apply that knowledge using the Indigo Object Model (IOM).

Re: Not New but I am Stumped

PostPosted: Thu Dec 21, 2023 3:03 pm
by 300BlkPlinker
Really appreciate the coaching DaveL17. I am retiring at EOY and Python scripting knowledge is on my To-Do list. I will check out the YoutTube channel you mentioned.

Re: Not New but I am Stumped

PostPosted: Thu Dec 21, 2023 3:59 pm
by DaveL17
Congratulations on the retirement.

Come on in--the water's fine.

Re: Not New but I am Stumped

PostPosted: Fri Dec 22, 2023 6:44 am
by kw123
There are fingscan and unifiap plugins

They both do “present” and away

But no wifi solutions is a 100 % as the phone go to sleep

The only 100% solution I am using is pibeacon. I have not found a false negative / positive in 8 years. Only when the plugin has a hickup

.that requires rpi -at least 2- and beacons.

Karl


Sent from my iPhone using Tapatalk

Re: Not New but I am Stumped

PostPosted: Mon Dec 25, 2023 4:25 pm
by ryanbuckner
I wrote the Life360 plugin to solve this problem while we wait for Indigo Touch to support location communication. Unfortunately the Life360 API is unsupported so it's currently not working. I hope to have a new version sometimes this week.

Re: Not New but I am Stumped

PostPosted: Tue Dec 26, 2023 12:26 pm
by ryanbuckner
I have fixed the plugin. Try it here: https://forums.indigodomo.com/viewtopic.php?f=363&t=27682

Re: Not New but I am Stumped

PostPosted: Thu Dec 28, 2023 2:58 pm
by cjp767
Here's a copy of a post I made in the Life360 thread-- I tried to find a different way to geofence when Life360 service chose to be difficult. I'm currently running both the new and improved Life360 plugin and this method. Each method changes the same variable, so whichever gets there first accomplishes the trigger.


I've moved to the new-ish Geofence plugin and run an app on my phone called Locative. Instead of polling a service like the Life360 plugin does, the Locative app automatically sends a message through the Indigo Reflector to the Indigo app on your computer. Locative sends a message when you enter or leave a geofenced area. The message changes a device state and I set triggers using that information.

Plugin Store Link: https://www.indigodomo.com/pluginstore/121/

Forum Post: viewtopic.php?f=216&t=26416

Locative in Apple's App Store: https://apps.apple.com/us/app/locative- ... d725198453

The setup was reasonable, but it took a while. Since I've never seen either of these apps/plugins before, there is a learning curve.