View unanswered posts | View active topics It is currently Thu Jun 20, 2013 3:30 am



Reply to topic  [ 328 posts ]  Go to page: 1, 2, 3, 4, 5 ... 22  Next
 Smartphone Radar - Smartphone presence detection (Updated) 
Author Message
User avatar

Joined: Sep 07, 2010
Posts: 242
Location: Toronto, Canada
Post Smartphone Radar - Smartphone presence detection (Updated)
What Smartphone Radar Does
Smartphone Radar allows you to keep track of when your family's smartphones were last seen on your network. Since our phones are generally always with us, it's a fairly reliable way of letting Indigo make some clever decisions. Some examples might be:

1. All the family members are not home yet, leave the porch lights on a little later tonight.
2. Nobody has been home for hours, might as well adjust the HVAC to save some cash.
3. It's really late and your daughter is still not back from her date, maybe Indigo should wake you up and let you know she broke curfew.
4. It's dark outside and nobody is home, maybe Indigo should play with the lights to help ward off potential burglars.

How It Works
The plugin works by scanning your router's logs or SNMP output for network activity of your smartphones.

What It Needs
To use Smartphone Radar you'll need an Apple Airport router, or a router with remote logging capabilities (this is sometimes called syslog). Your phones will also need to be set to access the network on a regular schedule. This can usually be accomplished by setting them to check for email on a regular schedule.

Download the Plugin
Smartphone_Radar_Plugin.zip - Version (1.1.3)
See Change History below for details on what's been changed in each version.

Installation
1. Download the plugin from the link above, unzip it if your browser doesn't do that automatically.
2. Double-click on the Smartphone Radar.indigoPlugin file.  Indigo will launch and ask if you'd like it to install the plugin.

3a. The plugin's configuration dialog box will popup. Select "Apple Airport / Time Capsule" if you have an Apple router, or select Generic if you have a standard router that can send it's log to a remote server (see 3b below).
- Enter the IP address of your Airport device. If you have multiple airport devices enter all the IP's separated by commas.
- Enter the SNMP community string for your Airport device, this is often the Airport's password. If it's not, check the SNMP settings of the Airport, it may let you specify a password for SNMP access.
Image


3b. Select "Generic" if your router will be sending it's log to Indigo.
To use this option your router must have remote syslog ability, and you must be able to specify a port. Routers running Tomato or DD-WRT firmware have this option, so do some higher-end consumer routers. Do NOT use this option for Apple routers. See Generic Router Setup below for more detailed router information.
Image

4. Go to your Device list and click New. Create a new Smartphone device for each of your phones.
Image

5. The Device Settings will open. Enter an IP or MAC Address depending on what your router log uses. Apple routers use MAC Address.
Image

6. Create some triggers if you're confident your router will work. Or maybe skip to the router setup below first to make sure ...

Setting up Triggers

Do something when a phone leaves the house:
Image

Do something when the house is empty:
Image

Use the optional variables as a condition to decide when to turn off lights. First enable Create Variables in the plugin's config. Useful variables will automatically be created:
Image

Then create a scheduled trigger using the variable as a condition:
Image

Generic Router Setup
Many routers already support logging to a remote server. If they don't, they can often be upgraded to have these features by installing DD-WRT or Tomato firmware on them. The best option is syslog support with the option to specify a non-standard port, this is GREAT for us. If they don't allow you to specify the port, they are likely locked on port 514.

DD-WRT Firmware: http://www.dd-wrt.com/site/index Supported Routers: http://www.dd-wrt.com/wiki/index.php/Supported_Devices
Tomato Firmware: http://www.polarcloud.com/firmware Supported Routers: http://www.polarcloud.com/tomatofaq#what_will_this_run_on

Please do not ask router-specific questions in this thread. Not that I don't want to help, but there are other forums dedicated to exactly this purpose with users much more knowledgable than I am on these subjects. If you've decided to go the DD-WRT route, their website has an extensive wiki and a very helpful forum.

The quick and dirty for the advanced users:

1. Setup a static IP for your Indigo server.
2. Set your router to remote syslog to your Indigo server's IP address at port 1514. Turn on outbound connection logging.
3. To confirm it's working check the "Show router log" checkbox in the Smartphone Radar config and watch your Indigo Event Log.
4. Use your phone, you should start seeing activity entries. If the entries all use MAC Addresses you can skip to step 6.
5. If your log entries all contain IP addresses you'll need to tell your router to assign static IPs to your phones.
6. Adjust your Smartphone Devices in Indigo to use MAC Addresses or IP Addresses based on what you saw in your logs.

OR with pictures for normal users. Shown using a Tomato router which logs with IP Addresses:

1. Open the Status -> Device List. Find your smartphones in the list, then click on the IP address.
Image

2. That will open the Static DHCP page with the MAC Address already filled out. Enter an IP address outside of the dynamic range. This is usually below 100, or over 200.
Image

3. Repeat steps 1 and 2 for all your phones and your Indigo server.

4. Setup syslog to log to your Indigo server's IP address on port 1514. Disable most of the logging options with the exception of connection logging. This must be enabled.
Image

5. Renew the DHCP leases on your phones and computer so they are all assigned the new address.
iPhone: Go to Settings/WiFi Networks, touch the blue arrow on your home network, tap Renew Lease on the bottom.
Mac: Go to System Preferences/Network, select your interface, select Advanced, then press Renew DHCP Lease.

Using port 514
Some routers do not let you specify a port for the syslog service. To work around this issue you'll need to make a few changes to the syslog service already running on your mac. We basically need to tell it to accept your router's logs on port 514, then forward everything to port 1514 for Smartphone Radar to sift through.

Thanks to lharris9 for this tip. Various users have reported success using this.

First tell syslog to accept logs from other devices:
http://superuser.com/questions/131578/how-do-you-enable-syslogd-to-accept-incoming-connections-on-snow-leopard-from-rem

Now tell it to forward the logs to itself at port 1514. See the link below. But use the following line in step 4:
Code: Select all
*.*                                       @127.0.0.1:1514

http://www.splunk.com/wiki/Community:HowTo_Configure_Mac_OS_X_Syslog_To_Forward_Data


Version Changes
1.1.3 - May 19, 2013
- Quick fix for compatibility with Indigo 6 beta 8

1.1.2 - Nov 17, 2012
- A minimum of 2 minutes is now forced for the MinutesTillAway config setting.
- Fixed a possible bug when using SNMP.

1.1.0 - Nov 14, 2012
- Fix for Indigo 6 compatibility.
- Fixed a bug where spaces after commas when using multiple IP address in the Airport setup would cause problems.

1.0.0 - Dec 5, 2011
- Changes to phone devices are now correctly updated in the plugin without having to restart it.
- A bug that would cause errors on the very first run has been fixed.
- A few other cosmetic changes.

0.9.2 - June 28, 2011
- Phone home/away states now show up correctly in Indigo's Device List. Unfortunately the device has to be deleted and recreated for this fix to take effect.

0.9.1 - June 11, 2011
- Fixed issue where phone variables were not automatically created if the plugin was running.
- Fixed issue where if all phones went on vacation, the AllPhonesHome variable would be set to True.
- Adjusted the device config text to help users of Apple routers.

0.9.0 - June 10, 2011
- First release of Smartphone Radar that uses devices to specify phones.
- Smartphones are now devices so there is no limit to how many you can monitor.
- Each device has Home, Away, and On Vacation states that can be used to trigger events.
- There are global events that trigger when ALL the phones are Home, Away, or On Vacation.
- Variables can be automatically created and used as conditions for other triggers or schedules.


Last edited by travisc on Sun May 19, 2013 7:52 pm, edited 19 times in total.



Sun May 29, 2011 10:31 pm
Profile WWW
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6859
Location: Austin, Texas
Post Re: Smartphone Radar - Smartphone presence detection
Sweet - I'll have to check my router. A couple of thoughts:

1) To make the user do a bit less work on install, why not just ask for the variable name and create it yourself (if it doesn't exist) rather than make them create it and show the variable list?
2) In fact, if you made each phone a custom device with just a single state (atHome or something) then you wouldn't need variables at all and you could have unlimited phones.

Just some thoughts. I'd rather not muck with my router firmware but perhaps it already does syslog.

_________________
Jay (Indigo Support)
Image


Mon May 30, 2011 6:28 am
Profile WWW
User avatar

Joined: Jun 04, 2008
Posts: 129
Post Re: Smartphone Radar - Smartphone presence detection
travisc wrote:NOTE: This is a beta release. It's not going to wreak havoc on your computer, but it may still have a quirk or two.

What It Needs
To use Smartphone Radar you'll need a router with remote logging capabilities (sometimes called syslog). As well as some settings in the router so it gives out the same IP address to the phones every time it connects to the network (static DHCP). The phones will also need to be set to check email on a regular schedule. Many higher end routers already support these features, and many less expensive routers do too. If they don't, they can often be upgraded to have these features by installing DD-WRT or Tomato firmware on them.

DD-WRT Firmware: http://www.dd-wrt.com/site/index Supported Routers: http://www.dd-wrt.com/wiki/index.php/Supported_Devices
Tomato Firmware: http://www.polarcloud.com/firmware Supported Routers: http://www.polarcloud.com/tomatofaq#what_will_this_run_on



Excellent! I have been running Tomato for years, I'll give this a go when I get back home.


Thanks Travis!!


Mon May 30, 2011 6:43 am
Profile
User avatar

Joined: Sep 07, 2010
Posts: 242
Location: Toronto, Canada
Post Re: Smartphone Radar - Smartphone presence detection
1) To make the user do a bit less work on install, why not just ask for the variable name and create it yourself (if it doesn't exist) rather than make them create it and show the variable list?


That'll work. At first I didn't see the variable methods in the plugin documentation, I think it just said FixMe. But then I noticed them later, I'll check this out.

2) In fact, if you made each phone a custom device with just a single state (atHome or something) then you wouldn't need variables at all and you could have unlimited phones.


I originally wanted to do this to keep it simple. The reason I avoided using devices or triggers is because I think a lot of people will create conditions based on the value of the variable. For example, if the phone has been away for 4 hours reduce the heat, or if it's been away for 24 hours then put the house in vacation mode, or turn off the lights at 10pm only if phonelastseen is less than 30. Then I thought of creating triggers for different timeout periods, but then the times would have to be adjustable because some people might want to use it for different things. I figured I'd get this out first and see how people use it, if everyone just wants triggers for home and away then I can certainly change it. :)

Thanks for the feedback!


Mon May 30, 2011 7:49 am
Profile WWW
User avatar

Joined: Sep 07, 2010
Posts: 242
Location: Toronto, Canada
Post Re: Smartphone Radar - Smartphone presence detection
Excellent! I have been running Tomato for years, I'll give this a go when I get back home.


Great! Let me know how it works out. I'll post my Tomato setup for reference. If you downloaded it already download it again. I moved a function last night just before I uploaded it and something broke, it's all fixed.


Mon May 30, 2011 9:27 am
Profile WWW
User avatar

Joined: Sep 07, 2010
Posts: 242
Location: Toronto, Canada
Post Re: Smartphone Radar - Smartphone presence detection
Jay,

I've been thinking a little bit more about what you said with making each phone a Device. How does this sound?

- Each phone is a device. On the device config page user specifies the IP address and optionally types in a variable name to store the minutes since last seen.
- Each device then has triggers for: This Phone is Home, This Phone is Away, This Phone on Vacation
- There would also be global plugin triggers for: A Phone is Home, All Phones Home, All Phones Away, All Phones on Vacation, etc
- The pluginConfig screen could then have two settings where the user could specify how many minutes need to pass before a phone is declared away, and how many hours (or days) have to pass before it's declared on vacation.

I'm still considering if the vacation trigger is necessary or if it complicates things. I like to differentiate between Away for a few hours, and Away for days. If all the phones are just away for a few hours I'll adjust the HVAC a few degrees. But if they are all gone for a long time I'll adjust it much more, and also put the house in a mode to play with the lights to make it look like people are still home.

Thanks for your help.

Travis


Tue May 31, 2011 5:29 pm
Profile WWW
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6859
Location: Austin, Texas
Post Re: Smartphone Radar - Smartphone presence detection
Why not have # of minutes away a device state - that way people can trigger on when minutes away becomes greater than 60 (1 hour), minutes away becomes greater than 1440 (1 day), etc? Then you wouldn't have to preconfigure Away and Vacation (although maybe those are nice shortcuts). States, IMO, are just much nicer than having variables floating around cluttering up the variable list.

Global events sound interesting.

_________________
Jay (Indigo Support)
Image


Tue May 31, 2011 5:47 pm
Profile WWW
User avatar

Joined: Sep 07, 2010
Posts: 242
Location: Toronto, Canada
Post Re: Smartphone Radar - Smartphone presence detection
Why not have # of minutes away a device state - that way people can trigger on when minutes away becomes greater than 60 (1 hour), minutes away becomes greater than 1440 (1 day), etc?


My only concern with this was that device states can't be used as conditions. So for example if 10pm rolls around and triggers an event to turn off the outside lights, you can't put a condition saying "Only If phone state < 30 minutes". Which would prevent them from turning off if the phone wasn't home yet. Or am I wrong? This limitation is the reason I went with variables in the first place. I agree that variables are messy.


Tue May 31, 2011 6:10 pm
Profile WWW
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6859
Location: Austin, Texas
Post Re: Smartphone Radar - Smartphone presence detection
I think both use-cases are valid. The use in conditions is a valid point, and while we intend to implement device states in the condition editor eventually - working around using a variable is a reasonable alternative. No reason not to implement both IMO - updating states is a single line of code just like updating a variable... ;)

BTW, the next beta release will have a new plugin - one of the actions in it will more easily allow users to insert a device state into a variable (so it'll work with any device type that has states). It'll help with that condition editor limitation until we can decide when we can get device states in natively.

_________________
Jay (Indigo Support)
Image


Tue May 31, 2011 6:56 pm
Profile WWW

Joined: Apr 25, 2011
Posts: 18
Location: Running Springs, CA
Post Re: Smartphone Radar - Smartphone presence detection
I'm running into some trouble with this. As soon as I start up the plugin, I see this in the log:

Jun 3, 2011 7:12:13 PM
Smartphone Radar Phone 1 at IP Address 10.0.1.52 will use variable leda_logged.
Smartphone Radar Phone 2 at IP Address 10.0.1.53 will use variable elara_logged.

Jun 3, 2011 7:12:40 PM
Smartphone Radar Error Error in plugin execution runConcurrentThread:

Traceback (most recent call last):
File "plugin.py", line 54, in runConcurrentThread
File "/Library/Application Support/Perceptive Automation/Indigo 5/Plugins/Smartphone Radar.indigoPlugin/Contents/Server Plugin/iPresence.py", line 122, in startComm
<type 'exceptions.ValueError'>: invalid literal for int() with base 10: ''

Smartphone Radar Error plugin runConcurrentThread function returned or failed; will attempt again in 10 seconds


Quite possibly user error on my part. :)
Any ideas?

I'm running Indigo 5.0.0 b5 and the plugin I just downloaded today (v0.5.0)

-travis


Fri Jun 03, 2011 8:21 pm
Profile ICQ YIM
User avatar

Joined: Sep 07, 2010
Posts: 242
Location: Toronto, Canada
Post Re: Smartphone Radar - Smartphone presence detection
Quite possibly user error on my part. :)
Any ideas?


Actually I bet it's my fault. It's assuming there's a number stored in that variable at first. Try changing the value of both of your variables to a number. Any number, it doesn't matter. Then start the plugin again.

I'll adjust the code so it will check for this and initialize the variable if it's not a valid number.

Let me know if that works.

Travis


Fri Jun 03, 2011 9:20 pm
Profile WWW

Joined: Apr 25, 2011
Posts: 18
Location: Running Springs, CA
Post Re: Smartphone Radar - Smartphone presence detection
Ah, that did the trick, thanks.

I may be out of luck in the router department though. I'm using an AirPort Extreme, which probably won't work with Tomato or DD-WRT. It does support syslog, but you can't specify a TCP port. It always goes to 514 via UDP.


Fri Jun 03, 2011 10:01 pm
Profile ICQ YIM
User avatar

Joined: Sep 07, 2010
Posts: 242
Location: Toronto, Canada
Post Re: Smartphone Radar - Smartphone presence detection
I may be out of luck in the router department though. I'm using an AirPort Extreme, which probably won't work with Tomato or DD-WRT. It does support syslog, but you can't specify a TCP port. It always goes to 514 via UDP.


I was looking into this the other day. Port 514 is the standard syslog port, but we can't use that port because ports below 1024 require administrator privileges. Indigo plugins don't have administrator privileges (which is good) so I decided on using port 1514. Some routers allow syslog to use a non-standard port, some don't. Apple's Airport extreme and Airport Express are examples of the latter.

From the research I've done, it seems the easiest work-around for this is to internally forward port 514 to 1514. The best tool to do this seems to be WaterRoof http://www.hanynet.com/waterroof/. It's not a program that has to run in the background, it's a simple GUI to OS X's powerful network layer. You use it to setup a simple network routing rule and that's it.

If you want to give this a shot, from what I've read you'd follow these steps to forward the port:

    1. Click on “Rules”.
    2. Click the “+” icon to add a new rule.
    3. Enter the following information in the “Add new rule” window that appears:

      Protocol: udp
      Rule Action: Forward
      In the “x.x.x.x, port” field enter 127.0.0.1 for the IP and 1514 for the port
      Source address, subnet or network: any
      Port or range: (leave blank)
      Destination address, subnet, or network: me
      Port or range: 514 (Port number to which you would like WaterRoof to redirect traffic from)
      Options: Select the In/Out radio button
    4. Click on Add new rule

You will have to experiment with different syslog levels to see which one will output the log information you need. Use the debug and Show router log checkboxes in the plugin's config. You want to see router log entries that contain your iPhone's IP address when it accesses the network.

Let me know how you make out.

The WaterRoof steps above were based on the following pdf file.
http://support.grouplogic.com/wp-content/uploads/2008/11/port-redirection-with-waterroof.pdf


Fri Jun 03, 2011 10:53 pm
Profile WWW

Joined: Apr 25, 2011
Posts: 18
Location: Running Springs, CA
Post Re: Smartphone Radar - Smartphone presence detection
Ah, I was messing around with forwarding the port with netcat, but WaterRoof is much easier, thanks.

With this router, syslog isn't logging the phone connection by IP, but rather by MAC address (syslog level 5, btw). Your configuration panel is validating for IP, so I wasn't able to just enter the MAC address in there.


Fri Jun 03, 2011 11:26 pm
Profile ICQ YIM
User avatar

Joined: Sep 07, 2010
Posts: 242
Location: Toronto, Canada
Post Re: Smartphone Radar - Smartphone presence detection
Try this one. I just whipped up a special blend that doesn't do IP validation. Enter the MAC address as it's shown in the log into the IP Address box and it should work. If it does I'll modify the plugin to accept either or.
http://frightideas.com/hobbies/smartphoneradar/SmartphoneRadar_noValidation.zip


Fri Jun 03, 2011 11:52 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 328 posts ]  Go to page: 1, 2, 3, 4, 5 ... 22  Next

Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.   Template designed by STSoftware.