Find my iDevices!

Posted on
Sat Oct 29, 2011 11:33 am
ryanbuckner offline
Posts: 1074
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Find my iDevices!

- I defined a device called "iPhone" and set it to my FMiD iCloud iPhone called "Ryan.Buckner's iPhone". It shows up properly on the map

I created a trigger to tell me if the iPhone is close to home

Code: Select all
set distance to DistanceAway of device "iPhone"

if distance < 2.0 then

set value of variable "isHouseOccupied" to "true"

set value of variable "isRyansPhoneHome" to "true"

log "Ryan's iPhone was found closer than 2 miles away... it's home"

return true

else if distance > 2.0 then

set value of variable "isHouseOccupied" to "false"

set value of variable "isRyansPhoneHome" to "false"

log "Ryan's iPhone was found more than 2 miles away... it's not home"

return false

else

log "distance variable is blank"

set value of variable "isHouseOccupied" to "false"

set value of variable "isRyansPhoneHome" to "false"

end if


This code throws an error in the log:

Code: Select all
Error                           script error: around characters 891 to 903

Error                           script error: IndigoServer got an error: Can’t get DistanceAway of device "iPhone". (-1728)

Posted on
Sat Oct 29, 2011 12:24 pm
bschollnick2 offline
Posts: 1355
Joined: Oct 17, 2004
Location: Rochester, Ny

Re: Find my iDevices!

ryanbuckner wrote:
- I defined a device called "iPhone" and set it to my FMiD iCloud iPhone called "Ryan.Buckner's iPhone". It shows up properly on the map

I created a trigger to tell me if the iPhone is close to home

Code: Select all
set distance to DistanceAway of device "iPhone"


This code throws an error in the log:

Code: Select all
Error                           script error: around characters 891 to 903

Error                           script error: IndigoServer got an error: Can’t get DistanceAway of device "iPhone". (-1728)


I believe, Jay & Matt, correct me if I am wrong...

But I believe that Devices States are not accessible through Applescript? I can't find anything on the wiki that is definitive.... The IOM doesn't seem to state that anywhere I can find it...

------
My Plugins for Indigo (v4, v5, and v6) - http://bit.ly/U8XxPG

Security Script for v4 - http://bit.ly/QTgclf
for v5 - http://bit.ly/T6WBKu

Support Forum(s) - http://www.perceptiveautomation.com/userforum/viewforum.php?f=33

Posted on
Sat Oct 29, 2011 12:47 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Find my iDevices!

Correct, device states will only be available from python where they can be accessed like this:

Code: Select all
dev = indigo.devices[12356]   # right-click on device to get its ID number
dev.states["someStateName"]

Image

Posted on
Mon Oct 31, 2011 9:29 pm
ryanbuckner offline
Posts: 1074
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Find my iDevices!

Thanks, I'll try that. I guess I misinterpreted the way applescript could be used under Testing A Devices State here http://www.perceptiveautomation.com/wik ... _snippit&s[]=state&s[]=device

Posted on
Mon Oct 31, 2011 10:27 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Find my iDevices!

Yeah, AppleScript will give you access to brightness and the on/off state of the X10/INSTEON devices, but for the states defined by plugin devices you'll need to use python.

Image

Posted on
Tue Nov 01, 2011 4:21 am
bschollnick2 offline
Posts: 1355
Joined: Oct 17, 2004
Location: Rochester, Ny

Re: Find my iDevices!

ryanbuckner wrote:
Thanks, I'll try that. I guess I misinterpreted the way applescript could be used under Testing A Devices State here http://www.perceptiveautomation.com/wik ... _snippit&s[]=state&s[]=device


I can see how that misconception could be formed...

Matt & Jay, I would suggest changing the phrasing on that wiki page, or explaining that this doesn't give access to the Device States...

The issue here is that in previous versions of Indigo there were no device states. So Device State either meant that it was on/off or at a brightness level....

I think the proper way of looking at this might be:

Device State - On/Off/Brightness, available via applescript

Custom Device State - Plugin Developer created, not available via applescript

I hope that helps the discussion...

------
My Plugins for Indigo (v4, v5, and v6) - http://bit.ly/U8XxPG

Security Script for v4 - http://bit.ly/QTgclf
for v5 - http://bit.ly/T6WBKu

Support Forum(s) - http://www.perceptiveautomation.com/userforum/viewforum.php?f=33

Posted on
Tue Nov 01, 2011 5:09 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Find my iDevices!

User @berkinet maintains that page, but I'll add a little note on that one. It's inaccurate to describe device states in AppleScript as only being on/off/brightness since you can get other states from other built-in device types. In fact, there are very few built-in device states that you can't get using AppleScript.

@berkinet, it might be a good idea to add Python examples to that page that correspond to the AppleScript examples and rename it "Script Snippets". Just a thought... :D

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Nov 01, 2011 10:53 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Find my iDevices!

Caught asleep at the wheel of progress. The code snippets are out of date and I will get them updates, at least for AppleScript (while I am learning Python scripting). If anyone has any suggestions for Python snippets, please PM them to me.

Posted on
Sat Nov 12, 2011 9:05 pm
bluenoise offline
Posts: 143
Joined: Aug 23, 2008

Re: Find my iDevices!

What a fantastic plug-in! I was looking for a way to have Indigo know if we're home or not and this is exactly what I was hoping to find. I am having some problems, however, figuring out how to make use of the information it can provide. Ideally, I'd like to have the DistanceAway of each iDevice stuffed into Indigo variables so that I can do things with them within Applescripts. I have never messed with Python, but did manage to cobble together enough to get it to put the states into my log, but that's about it:

Code: Select all
states : States : (dict)
     Accuracy : 10 (real)
     Battery : 0.2286254 (real)
     DeviceClass : iPad (string)
     DeviceModel : SecondGen-3G-white (string)
     DeviceStatus : 203 (string)
     DistanceAway : 131.59 (string)
     FencedAreaName :  (string)
     LastUpdated : Sat Nov 12 18:40:21 2011 (string)
     Latitude : 39.123456789 (real)
     Longitude : -121.123456789 (real)
     MobileMeAccount : xxxxxxx@me.com (string)


All I could find for manipulating Indigo variables was to create, update, and delete them. I can't figure out how to address and update an existing variable. Aside from that, I could not set a variable I created on the fly to "DistanceAway" using this script:

Code: Select all
iPad = indigo.devices[xxxxxxxx]
indigo.server.log(iPad.name + ": \n" + str(iPad))

myVar = indigo.variable.create("distanceAway_iPad")
indigo.variable.updateValue(myVar, iPad.DistanceAway)


...gives me this error:

Code: Select all
  Script Error                    embedded script: 'Device' object has no attribute 'DistanceAway'
  Script Error                    Exception Traceback (most recent call shown last):

     embedded script, line 5, at top level
AttributeError: 'Device' object has no attribute 'DistanceAway'


What do I need to do differently?

Posted on
Sat Nov 12, 2011 9:31 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Find my iDevices!

Untested, but this should update an existing var with the right state.

Code: Select all
iPad = indigo.devices[xxxxxxxx]
indigo.server.log(iPad.name + ": \n" + str(iPad))

myVar = indigo.variables[VARIDHERE]
indigo.variable.updateValue(myVar, iPad.states["DistanceAway"])


Or something close to this...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Nov 12, 2011 9:37 pm
bluenoise offline
Posts: 143
Joined: Aug 23, 2008

Re: Find my iDevices!

That worked! Thanks, Jay, for the incredibly-quick response! :shock: :D

Posted on
Sat Nov 19, 2011 12:57 am
MrJeffreyGee offline
User avatar
Posts: 74
Joined: Apr 26, 2011
Location: United States

Re: Find my iDevices!

ryanbuckner wrote:
Yesterday I was having an issue adding another device to FMiD using the alternate login. Today the device showed attributes in Indigo (Long, Lat, Distance, etc...). When I investigated further I could tell that it was duplicating an already listed device by using my primary login and password, ignoring the alternate login. I hope this helps.



This plugin is awesome. It works very well with the exception of two problems. The first is the FencedAreaName doesn't seem to be updating and is always blank, so I can't use it for triggers. The second problem being the one quoted above. I've also tried changing my primary login and password to the alternate temporarily for adding in the second device on a different MobileMe/iCloud account, but it caused a lot of red coding errors to occur in the Event Log. I changed it back to my primary MobileMe/iCloud log in when I saw that and I don't know if that caused the issue or worsened it. I've also tried deleting the plugin, disabling/reloading, and forced iDevice updating with no change for both these problems.

Current Software In Use:
Find My iDevice 1.20
Indigo 5.0.0 (Non-Beta)

Posted on
Sat Nov 19, 2011 1:39 am
bluenoise offline
Posts: 143
Joined: Aug 23, 2008

Re: Find my iDevices!

I have found that polling location data every 15 minutes drastically reduces battery life on our iPhones, which is a bummer because I was using this to determine whether or not we are home. Is anyone else seeing a big hit to their battery life?

Posted on
Sat Nov 19, 2011 8:35 am
bschollnick2 offline
Posts: 1355
Joined: Oct 17, 2004
Location: Rochester, Ny

Re: Find my iDevices!

bluenoise wrote:
I have found that polling location data every 15 minutes drastically reduces battery life on our iPhones, which is a bummer because I was using this to determine whether or not we are home. Is anyone else seeing a big hit to their battery life?


I don't see a dramatic reduction, but I certainly do see a reduction in battery life when Find My iPhone services are used often. Keep in mind, even if you are talking a single computer doing these requests, that's 48 times a day that FMID is requesting your phone's location...

Are you running iOS v5.01? I saw a good increase in battery life after installing (& Rebooting the iPhone).

- Ben

------
My Plugins for Indigo (v4, v5, and v6) - http://bit.ly/U8XxPG

Security Script for v4 - http://bit.ly/QTgclf
for v5 - http://bit.ly/T6WBKu

Support Forum(s) - http://www.perceptiveautomation.com/userforum/viewforum.php?f=33

Posted on
Sat Nov 19, 2011 8:42 am
bschollnick2 offline
Posts: 1355
Joined: Oct 17, 2004
Location: Rochester, Ny

Re: Find my iDevices!

This plugin is awesome. It works very well with the exception of two problems. The first is the FencedAreaName doesn't seem to be updating and is always blank, so I can't use it for triggers. The second problem being the one quoted above. I've also tried changing my primary login and password to the alternate temporarily for adding in the second device on a different MobileMe/iCloud account, but it caused a lot of red coding errors to occur in the Event Log. I changed it back to my primary MobileMe/iCloud log in when I saw that and I don't know if that caused the issue or worsened it. I've also tried deleting the plugin, disabling/reloading, and forced iDevice updating with no change for both these problems.

Current Software In Use:
Find My iDevice 1.20
Indigo 5.0.0 (Non-Beta)


Thanks....

The alternative login issue is something that I am working on.

The fenced area issue, is something that I have looked at, but the code looks good. I need to come up with a repeatable test case, so that I can debug the issue.

- Ben

------
My Plugins for Indigo (v4, v5, and v6) - http://bit.ly/U8XxPG

Security Script for v4 - http://bit.ly/QTgclf
for v5 - http://bit.ly/T6WBKu

Support Forum(s) - http://www.perceptiveautomation.com/userforum/viewforum.php?f=33

Page 7 of 27 1 ... 4, 5, 6, 7, 8, 9, 10 ... 27

Who is online

Users browsing this forum: No registered users and 3 guests