What's My Home IP automated via Tasker

1,204 views
Skip to first unread message

DaWeav

unread,
Nov 6, 2010, 11:59:25 AM11/6/10
to Tasker
Needless to say, I can't use Dynamic DNS anymore at work due to some
sort of security restrictions <ARRRRGGG>. So, since I need to have my
home IP address with me, Tasker to the rescue!

This is the Tasker routine I have so far which is a work in progess...

First, I created a Task for a Task Widget called 'HomeIP'
Variable Set %RECNOONE to 1
Read Line file 'Tasker/ip.txt' line '%RECNOONE' to variable
'%MYHOMEIP'
Popup title 'My Home IP is' text '%MYHOMEIP'

Added the 'HomeIP' Task as a Widget to my homescreen and selected an
appropriate ICON of course.


Then I made a Tasker State Context for 'WiFi Connected' with the SSID
set to my home wireless SSID.
Tasks list
Variable Clear %MYHOMEIP
Variable Set %RECNOONE to 1
Read Line file 'Tasker/ip.txt' line '%RECNOONE' to variable
'%MYHOMEIP'
HTTP GET server:port 'www.whatismyip.org' mime type 'text/plain'
output file 'Tasker/ip.txt'
Variable Set %HOMEIP to %HTTPD
If %MYHOMEIP <doesn't match> %HOMEIP
Send SMS ... (I'm using my providers SMS to email gateway to send
an email to my work email)
Notify Title 'New Home IP Address is' and text '%HOMEIP'
Set Widget Label 'HomeIP' label '%HOMEIP' if %MYHOMEIP <doesn't
match> %HOMEIP
End If

I should only get notifications if it changes, or if the 'ip.txt'
doesn't exist and/or can't be read. Also, even though the widget
label won't display the entire IP address, I thought it was just cool
to change it anyway.

Any other ideas or options I didn't consider?

RogueSpear

unread,
Nov 8, 2010, 9:55:41 AM11/8/10
to Tasker
Nice work. I'll play around with this later today. I could see this
really being useful for SSH and/or IP cam situations.

fubaya

unread,
Nov 8, 2010, 4:17:17 PM11/8/10
to Tasker
Depending on what operating system you guys are on, this trick may be
useful. It's for Linux and is very similar and, funny enough, I even
use the same name - "HomeIP". But it's for the computer and sends an
SMS to the phone if the IP changes. It may be useless to both of you,
but here goes...

I use ssh in scripts a lot and I write them to get the ip address from
a file instead of hard-coding it in the script. E.g., instead of
putting "ssh user at IP" (spelling it out so the group doesn't obscure
it like an email address), I put "ssh user at $(tail -n1 /sdcard/ip)"
in the script. Any time my home IP changes, I just have to put it in
that file, which I use Tasker for.

But first, on the computer I have this script run every few minutes.
You'll have to figure out a method to get the IP, I use lynx --dump
http://www.whatismyip.com/automation/xxxxxxxxx.asp, but I think that
is a unique number or I would post it. This uses nail as a mail
client, but would work with anything else you have set up.

#! /bin/sh
ip=$(your method to get the ip address)
if
grep -q $ip ipfile
then
echo
else
echo "HomeIP:" > ipfile
echo "$ip" >> ipfile
nail [my ATT SMS address] < ipfile
fi

So when it gets the IP, it compares it with the .ip file. If it's the
same, it does nothing. If it's changed, it writes the new IP to the
file then emails the file to the ATT SMS gateway address, (which is
PhomeNumber at txt.att.net). It doesn't send as an attachment, it
sends the file contents as a body, so I get this SMS:

FRM: me at gmail.com
MSG: HomeIP
[new ip]

Using Tasker to act when it sees my address in the SMS, it writes the
text from the SMS in the file /sdcard/ip if the text contains
"**HomeIP**"

I can post the Tasker part later, but it should be straight forward.
Reply all
Reply to author
Forward
0 new messages