Trouble with find-my-iphone-node

529 views
Skip to first unread message

Darren Humphrey

unread,
Dec 10, 2017, 2:54:19 PM12/10/17
to Node-RED
Before I get into the problem I am having, is there a place I should be looking for example flows and documentation?  Not just for find-my-iphone, but for useful real world examples to start from.  I feel like I am completely reinventing the wheel each time I start to do something.  I've had to resort to reading the JS source code to figure out how some of these flows work and I'm still scratching my head and struggling.  IN THEORY it's super cool to drag and drop nodes to connect my iphone position to my hue lights,  But IN REALITY there seems to be no documentation other than reading the source and I've literally spent hours reading code and haven't gotten anything to work.  I can only imagine that a non-programmer's head would explode and fly off into the next solar system.

Are there examples of simple things like 'do some simple thing when your iphone gets within a certain distance of a lat/lon'? Is there some repository of useful flows that people have made? Not just for find-my-iphone, but other useful real world scenarios?

My current problem is I am struggling right now to get  find-my-iphone to do anything useful.  What I can do is inject an event manually and get it to connect to icloud, which then tells me where all my devices are, but only after I click that it's OK (apple authentication popup).  I can see that the code stores a cookie when this happens, so I guess the idea is that it caches the credentials so that I don't get a popup every time.  However, that's not what happens.  I get a popup every time.

Problem #1.  Any interaction I do with the node results in a popup.  The caching doesn't seem to work and I have no idea how to debug it.  I can't even figure out how to put in my own print statements in the JS to dump stuff to the log so I can trace the execution.  I have no idea WHY the caching fails. (I see it makes a cookie so it should work)

Problem #2 How to get a position update either every few minutes or whenever my phone moves.  Do I need to schedule a timer to poll the position?  And if so, what message payload do I send to it?   I tried to make a getDeviceLocation message based on what I read in the source code, but all it did was generate an authentication popup and send me the same thing I got from sending init.

Problem #3.  Is there any code for managing the fact that I have numerous devices?  I have a total of 6 apple devices.  When I ask for position (manually with an authentication popup), I get a big dump of data for all 6 devices.  if I was doing this in C++ I'd store the info about all the devices in a ram structure or to a file and then later, I'd probably iterate over all of them and get their position and then run my logic to figure out what to do?

If I can get this to work, I will happily post an example flow and tutorial to wherever such things are normally kept.  I'm really excited about using node-red in my home automation adventures, but I seem to be hitting a wall.

Garry Hayne

unread,
Dec 10, 2017, 4:51:02 PM12/10/17
to Node-RED
Look at nodered.org for a lot of examples of real world solutions to concrete problems. If you formulate exactly what you are trying to achieve you will get some real help here.

Colin Law

unread,
Dec 10, 2017, 5:17:43 PM12/10/17
to node...@googlegroups.com
In particular, flows.nodered.org

Colin

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/e40fdbdb-a29f-4b32-9ef1-a2ba857729fb%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Darren Humphrey

unread,
Dec 10, 2017, 5:21:40 PM12/10/17
to node...@googlegroups.com
Thanks for the link.  I did not see that part of the node red website before.  I found two flows that use find my iphone, neither of which works. :)

Also, both of them exhibit the same behavior of wanting authentication every time they run.  Then both of them choke on the result of the query--it looks like both flows are only expecting there to be 1 iphone device, not 6, so they can't figure out the location because they're not built to handle that.

A far as what I want to accomplish, I will be satisfied with crawling before I walk.    I merely want to do something when my iphone is close to the house.  For beginner's sake I'll settle for changing the color of one of my hue bulbs.     I've already got hue lights working with a temperature sensor, so it's really the just the iphone part I'm struggling with.

I *think* the answer is nobody has done this before, but I'd like to be really sure of that before I embark on doing it myself.
  
How about this for a basic question:  someone give me the lines of code I can insert into the node source code so that it will just print stuff to node-red's log file.  If I can debug I can do anything.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/7-IEQoV_oq8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.

Dave C-J

unread,
Dec 10, 2017, 5:49:30 PM12/10/17
to node...@googlegroups.com
If you're looking at that node - then adding console.log(some variable or other); to various points should help you debug it... - If added to the .js file it will appear in the console where you start Node-RED from... and if in the javascript inside the .html file then it will be in the browser console log.

If you do get a "lump of data" for your 6 devices... what does the debug node then say that is ? an array ? and object ? text string ? either way I'm sure we can take it apart fairly easily once you have it.

Of course there may also be other ways to do the same task... several people have discussed using ping and or arp to detect if/when the phone connects to the local wifi (even if just outside the door etc, Others have used the Owntracks client on the phone to report location via a broker instead and then a geofence node to create actions.

Darren Humphrey

unread,
Dec 10, 2017, 11:06:54 PM12/10/17
to node...@googlegroups.com
Interesting.  Looking closer, it's not sending an array.  It's actually sending one json message for each device, which is a little easier to deal with.  I've used a switch node based on on the 'id' field to select the one device I'm interested in, and that works to choose just one of the six devices.  Hmmm.  Now, I'm not sure why the two example flows don't work.   

Now I just need to track down why it does an authentication popup every time.

Regarding owntracks, that can be a plan B is needed, but I'd like to stick with built-in services on the phone if I can.  And for me wifi is not reliable as an indicator because I often turn it off.

I'm now working through debugging the authentication.  The biggest annoyance I've noticed is I need to restart node-red every time I change the javascript, which is kinda slow.  Is there a faster way?
 

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/7-IEQoV_oq8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Darren Humphrey

unread,
Dec 10, 2017, 11:47:40 PM12/10/17
to node...@googlegroups.com
I'm pretty sure what's happening is a problem with 2 factor authentication.  When I sign in to icloud via node-red, I get prompted to allow the device via popup generated on my phone.  Then a 6 digit PIN is displayed on my phone.  I'm then supposed to send that code FROM THE NEW DEVICE (e.g. the Node-red server).  I'm guessing I need to add a text input field into the dashboard, enter the pin in there and then submit it to the appropriate icloud URL to approve the Node Red device.

Either that or turn off 2 factor authentication, which seems like a bad idea.


Julian Knight

unread,
Dec 11, 2017, 4:00:26 AM12/11/17
to Node-RED
You most likely need an application specific code - this is common with most 2FA schemes.

Darren Humphrey

unread,
Dec 11, 2017, 9:04:24 AM12/11/17
to node...@googlegroups.com
There is a way to generate app-specific password, and I have tried that, but it is not connecting. So I am still searching.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/7-IEQoV_oq8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Darren Humphrey

unread,
Dec 11, 2017, 12:27:12 PM12/11/17
to node...@googlegroups.com
After quite a bit of research I have found that none of the javascript (or python) packages for connecting to icloud support 2 factor authentication.  I was also unable to find support for application passwords.  I tried to modify the node code to use the application password, but was unable to get that to work.  In my searching, everyone else seemed to have the same conclusion, which is Apple should release some documentation on how it works.  

So for the meantime, I have just disabled 2 factor authentication for my account, and I have been able to get that to work.  I will put together a flow that shows how to make an event happen based on the presences of several iphones.   It will do one action when BOTH phones are not at the house, and a different action when either one of them comes back home.    


Reply all
Reply to author
Forward
0 new messages