Find My iPhone implementation in LUA script

Moderator: leecollings

User avatar
htilburgs
Posts: 464
Joined: Tuesday 03 November 2015 11:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Find My iPhone implementation in LUA script

Post by htilburgs »

Ok, I thought so. Thnx for the reply
Hardware:
RPi3 - Aeon Labs Z-Stick GEN5 - Fibaro Dimmer 2 - Fibaro Roller Shutter 2 - Fibaro Smoke Sensor - Yeelight RGBW Led bulb - Yeelight Smart LED Light Strip - Neo Coolcam PIR Motion Sensor - Neo Coolcam PowerPlug - Nest Thermostat v3
numanx
Posts: 11
Joined: Sunday 23 April 2017 3:51
Target OS: Linux
Domoticz version: 3.8153
Location: Romania
Contact:

Re: Find My iPhone implementation in LUA script

Post by numanx »

Hello I'm having some problems with the following error.
I am using Dummy Switch and Dummy Text and have two phones registered in the script, any ideas?


2017-04-23 04:31:02.277 Error: EventSystem: Warning!, lua script script_time_checkphones. has been running for more than 10 seconds
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Find My iPhone implementation in LUA script

Post by poudenes »

Does someone have changed the script so it work with APP specific passwords when you have 2way verification on in Apple ID?

App Specific passwords are created when the app or tool don't support 2way verification
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
lukev
Posts: 66
Joined: Friday 21 October 2016 10:42
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Find My iPhone implementation in LUA script

Post by lukev »

For people who are struggling with the 'nil value' as a response to this line:

Code: Select all

table.insert(commandArray,{['UpdateDevice'] = otherdevices_idx['Position ' .. user] .. '|0|' .. position_text})
My errors were all gone when I made a seperate hardware dummy for every device needed. So one hardware dummy named 'iPhone xxxx' with a virtual switch namede 'iPhone xxxx' and so on.

Eventually I added this line, to have a seperate sensor for the charging percentage. I use this to receive a prowl message on my iWatch when my phone is fully charged :-)

Code: Select all

table.insert(commandArray,{['UpdateDevice'] = otherdevices_idx['PowerState ' .. user] .. '|0|' .. powerstateval})
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Find My iPhone implementation in LUA script

Post by poudenes »

Does someone have changed the script so it work with APP specific passwords when you have 2way verification on in Apple ID?

App Specific passwords are created when the app or tool don't support 2way verification
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
DJBenson
Posts: 20
Joined: Wednesday 19 October 2016 19:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Find My iPhone implementation in LUA script

Post by DJBenson »

It appears the script stops working once 2FA is enabled, and 2FA will be mandatory soon - anybody who is testing the iOS 11 beta's will have already had 2FA enforced upon them.
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Find My iPhone implementation in LUA script

Post by ben53252642 »

DJBenson wrote:It appears the script stops working once 2FA is enabled, and 2FA will be mandatory soon - anybody who is testing the iOS 11 beta's will have already had 2FA enforced upon them.
This is correct, the script does not currently work with 2FA, I turned it off just so I could use Find My iPhone with Domoticz.

Hopefully someone finds a solution.
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Find My iPhone implementation in LUA script

Post by Nautilus »

Now that iOS 11 is out I wonder what is the status of this script, has anyone been able to verify it works (is 2FA mandatory in the official release)?
User avatar
htilburgs
Posts: 464
Joined: Tuesday 03 November 2015 11:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Find My iPhone implementation in LUA script

Post by htilburgs »

2FA is NOT mandatory (yet). IOS11 will ask for it after the upgrade, but you’re still able to say no.
Hardware:
RPi3 - Aeon Labs Z-Stick GEN5 - Fibaro Dimmer 2 - Fibaro Roller Shutter 2 - Fibaro Smoke Sensor - Yeelight RGBW Led bulb - Yeelight Smart LED Light Strip - Neo Coolcam PIR Motion Sensor - Neo Coolcam PowerPlug - Nest Thermostat v3
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Find My iPhone implementation in LUA script

Post by Nautilus »

htilburgs wrote: Friday 22 September 2017 6:22 2FA is NOT mandatory (yet). IOS11 will ask for it after the upgrade, but you’re still able to say no.
Thanks, good to hear. From earlier posts I thought it might be mandatory already on iOS 11 (maybe in the beta it was)...
User avatar
htilburgs
Posts: 464
Joined: Tuesday 03 November 2015 11:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Find My iPhone implementation in LUA script

Post by htilburgs »

Nautilus wrote: Friday 22 September 2017 14:33
htilburgs wrote: Friday 22 September 2017 6:22 2FA is NOT mandatory (yet). IOS11 will ask for it after the upgrade, but you’re still able to say no.
Thanks, good to hear. From earlier posts I thought it might be mandatory already on iOS 11 (maybe in the beta it was)...
This will not mean it stays that way. I'm currently using this script for:

- Presence
- Location
- Battery level

I'm hoping that there is found a solution to keep it using after 2FA.
As an alternative I use the full version of Pilot. Pilot also works for presence and can update Domoticz.
But Pilot does nog give me the current location and/or the battery level.
Hardware:
RPi3 - Aeon Labs Z-Stick GEN5 - Fibaro Dimmer 2 - Fibaro Roller Shutter 2 - Fibaro Smoke Sensor - Yeelight RGBW Led bulb - Yeelight Smart LED Light Strip - Neo Coolcam PIR Motion Sensor - Neo Coolcam PowerPlug - Nest Thermostat v3
landaisbenj
Posts: 147
Joined: Wednesday 02 August 2017 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: France
Contact:

Re: Find My iPhone implementation in LUA script

Post by landaisbenj »

Hello. Mine run great !!! thanks for that.

I just have this in log:
2017-12-04 21:21:04.174 LUA: iPhone Benjamin: 0.02 km from home, 17.000000178814% battery remaining. PowerState: NotCharging
.0000000000 on % bat lol not really disturbing but.... lol

I have 3 device and just one do this. The first.
Platforme: Rpbi3b
Domoticz: Last stable
Bridge: RFLINK last stable
Maartenkr
Posts: 15
Joined: Sunday 18 September 2016 23:56
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.7196
Location: Hellevoetsluis
Contact:

Re: Find My iPhone implementation in LUA script

Post by Maartenkr »

Hello i have the next fault:

EventSystem: in /home/pi/domoticz/scripts/lua/script_time_checkphones.lua: /usr/local/share/lua/5.2/json/init.lua:63: attempt to index global 'minetest' (a nil value)


What can I do about it?
numanx
Posts: 11
Joined: Sunday 23 April 2017 3:51
Target OS: Linux
Domoticz version: 3.8153
Location: Romania
Contact:

Re: Find My iPhone implementation in LUA script

Post by numanx »

Hello,
The script is working for me but I have the following inputs in error log and it's very annoying.
2018-02-19 15:45:20.128 Error: EventSystem: in iPhone: [string "-- Script to check the location of multiple i..."]:31: attempt to index global 'output' (a nil value)
2018-02-19 15:52:25.236 Error: EventSystem: in iPhone: [string "-- Script to check the location of multiple i..."]:31: attempt to index field '?' (a nil value)
On line 31 I have:
return output.results[1].formatted_address
landaisbenj
Posts: 147
Joined: Wednesday 02 August 2017 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: France
Contact:

Re: Find My iPhone implementation in LUA script

Post by landaisbenj »

Google need an apikey and make a cool down for request.
Platforme: Rpbi3b
Domoticz: Last stable
Bridge: RFLINK last stable
numanx
Posts: 11
Joined: Sunday 23 April 2017 3:51
Target OS: Linux
Domoticz version: 3.8153
Location: Romania
Contact:

Re: Find My iPhone implementation in LUA script

Post by numanx »

landaisbenj wrote: Monday 19 February 2018 14:58 Google need an apikey and make a cool down for request.
I've added a api key to the curl request.
I will reply back if I encounter any issue.
Thanks for your help!

UPDATE:
It seems that I have the same issue after the using of the apikey...
landaisbenj
Posts: 147
Joined: Wednesday 02 August 2017 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: France
Contact:

Re: Find My iPhone implementation in LUA script

Post by landaisbenj »

replace for this:

Code: Select all

  function address(longitude, latitude)
    command = "curl -s https://maps.googleapis.com/maps/api/geocode/json?latlng=" .. latitude .. "," .. longitude .. "&sensor=false"
    local handle = io.popen(command)
    local result = handle:read("*a")
    handle:close()
    output = json:decode(result)
    print(result)
    return output.results[1].formatted_address
  end
and post result
Platforme: Rpbi3b
Domoticz: Last stable
Bridge: RFLINK last stable
numanx
Posts: 11
Joined: Sunday 23 April 2017 3:51
Target OS: Linux
Domoticz version: 3.8153
Location: Romania
Contact:

Re: Find My iPhone implementation in LUA script

Post by numanx »

It seems that the problem is with the if statement for the repeat interval as it seems that I have more output prints.
How should I made the check for this if statement?

Code: Select all

interval = 5
local m = os.date('%M')
if (m % interval == 0) then
dens1975
Posts: 26
Joined: Monday 12 February 2018 17:03
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Find My iPhone implementation in LUA script

Post by dens1975 »

I also got the error:

Code: Select all

Error: EventSystem: in /usr/local/domoticz/var/scripts/lua/script_time_checkphones.lua: ...cal/domoticz/var/scripts/lua/script_time_checkphones.lua:30: attempt to index field '?' (a nil value) 
I have three iphones and somtimes it find 1, 2 or all 3 or none and almost always with the above error except if sometimes all three are found correct. If I put a print (result) before the 'output = json:decode(result)' line I do get some results which are looking good but I do also get a 'exceeded daily request' error. So now I did register for a api and key but how do I use this api key in the script?

Code: Select all

{
 "error_message" : "You have exceeded your daily request quota for this API. We recommend registering for a key at the Google Developers Console: https://console.developers.google.com/apis/credentials?project=_",
 "results" : [],
 "status" : "OVER_QUERY_LIMIT"
}
landaisbenj
Posts: 147
Joined: Wednesday 02 August 2017 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: France
Contact:

Re: Find My iPhone implementation in LUA script

Post by landaisbenj »

numanx wrote: Monday 19 February 2018 20:26 It seems that the problem is with the if statement for the repeat interval as it seems that I have more output prints.
How should I made the check for this if statement?

Code: Select all

interval = 5
local m = os.date('%M')
if (m % interval == 0) then
We all use this. I don't understand what you want.
dens1975 wrote: Tuesday 20 February 2018 16:01 I also got the error:

Code: Select all

Error: EventSystem: in /usr/local/domoticz/var/scripts/lua/script_time_checkphones.lua: ...cal/domoticz/var/scripts/lua/script_time_checkphones.lua:30: attempt to index field '?' (a nil value) 
I have three iphones and somtimes it find 1, 2 or all 3 or none and almost always with the above error except if sometimes all three are found correct. If I put a print (result) before the 'output = json:decode(result)' line I do get some results which are looking good but I do also get a 'exceeded daily request' error. So now I did register for a api and key but how do I use this api key in the script?

Code: Select all

{
 "error_message" : "You have exceeded your daily request quota for this API. We recommend registering for a key at the Google Developers Console: https://console.developers.google.com/apis/credentials?project=_",
 "results" : [],
 "status" : "OVER_QUERY_LIMIT"
}
In URL add &key=

And key don't resolve over query limit. You must add a condition to request address just one time on first no mouvement.
Platforme: Rpbi3b
Domoticz: Last stable
Bridge: RFLINK last stable
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest