Page 4 of 9
Re: Python Plugin: Life 360 Presence Detection
Posted: Sunday 15 April 2018 20:04
by capman
I get this error in my log
Is this a domoticz , python or life360 problem.
Running domoticz beta v 3.9208 on a synology.
- life360.JPG (111.15 KiB) Viewed 4210 times
Re: Python Plugin: Life 360 Presence Detection
Posted: Sunday 15 April 2018 22:13
by febalci
Could be an authentication problem with life360: (Because of the HTTPError detail)
1. Enable Debug
2. Leave Google api key empty (to make sure the problem is in life30, not google)
3. don't forget to write your email address as life360 username, not only the username itself but includes @somethingemail.com. you can check your credentails from life360 web page login.
Maybe debug option can give more details.
Re: Python Plugin: Life 360 Presence Detection
Posted: Monday 16 April 2018 10:03
by heggink
I noticed the same and it's gone now. I suspect it was an issue with L360 itself.
Re: Python Plugin: Life 360 Presence Detection
Posted: Tuesday 17 April 2018 20:09
by capman
Yes , it's gone. Like you suspect , it was a issue with Life360.
Thanks
Re: Python Plugin: Life 360 Presence Detection
Posted: Tuesday 05 June 2018 20:32
by l00pz
I'm really happy with this Plug-in as its way more stable then the Geofencing from the Domoticz App or Domofence
But is it possible to increase the poll period to something lower then 60 seconds? I don't want to make the Life360 Circle to big, but when I make the Circle like 500M the time from opening the door and the time that Domoticz Updates the Life360 plug-in sometimes gives me false alarms. Making the Circle bigger is one solution of course, but if it's possible the lower the poll period to like 30 seconds that would be great.
Re: Python Plugin: Life 360 Presence Detection
Posted: Tuesday 17 July 2018 17:11
by g00fy
Does anyone know what the usage of the Google api means concerning the new pricing policy Google anounced? I see in my case there were more than 44.000 cals on the geocoding api in the last 30 days (I was running an older version, so the cals on the distance api were not counted yet). This means that there will be about 88.000 cals a month when using these features, resulting in a bill of around $240 (not including the free $200 we get from Google).
As I look in the code it seems the api's are contacted every time life360 is contacted. Isn't it possible to limit this to only the times the location from life360 is updated? I supose this will result in a much lower count of api cals?
Re: Python Plugin: Life 360 Presence Detection
Posted: Wednesday 01 August 2018 20:42
by febalci
Unfortunately Google's new pricing policy on Maps API is causing errors on the plugin due to exceeding daily free query quota. I have to change the usage of Google's maps api to something else due to the continuation of free usage for this plugin. The current alternatives are Yandex and waze. If i can extract any information from life360, that will also be a solution. Thanks for your patience...
PS: The free version of Yandex is 25.000 calls per day.
PS2: Yandex doesnot have a traffic API
PS3: Google Directions API is still working without a key, but there's only duration info there (when there is no traffic), not duration_in_traffic...
PS4: Waze maps are still not sufficient for many countries.
PS5: I should give up adding PSs.
Re: Python Plugin: Life 360 Presence Detection
Posted: Thursday 02 August 2018 18:02
by g00fy
I did write a little change to your code that makes it possible to use Open Streetmaps as source, using Nominatum for the API.
At the moment Iam on holidays using it and it seems to work reasonably well for getting your location.
One thing to look into is the usage policies of Nominatim. It wants you to 'provide a valid HTTP Referer or User-Agent identifying the application'. For testing I used Domoticz-geofence for now, but I don't know if that will be right.
It looks like I can't upload the code via Tapatalk, so I will try to sent it to you in a message. Hopefully it will getting you forward in a solution replacing Google Maps.
PS I am not a software developer, so please feel free to change the code when you think it can be done better...
Verstuurd vanaf mijn TA-1012 met Tapatalk
Re: Python Plugin: Life 360 Presence Detection
Posted: Thursday 02 August 2018 22:27
by febalci
g00fy wrote: ↑Thursday 02 August 2018 18:02
I did write a little change to your code that makes it possible to use Open Streetmaps as source, using Nominatum for the API.
At the moment Iam on holidays using it and it seems to work reasonably well for getting your location.
One thing to look into is the usage policies of Nominatim. It wants you to 'provide a valid HTTP Referer or User-Agent identifying the application'. For testing I used Domoticz-geofence for now, but I don't know if that will be right.
It looks like I can't upload the code via Tapatalk, so I will try to sent it to you in a message. Hopefully it will getting you forward in a solution replacing Google Maps.
PS I am not a software developer, so please feel free to change the code when you think it can be done better...
Verstuurd vanaf mijn TA-1012 met Tapatalk
Actually getting the address from coordinates is easy, since google maps API doesnt need a key for that. I will change the code according to that next week. The problem is with the traffic data; i may completely take it out.
Re: Python Plugin: Life 360 Presence Detection
Posted: Monday 17 September 2018 22:36
by heggink
@febalci: I noticed in your plugin that, onHeartbeat, you call api = life360(), api.authenticate, api.get_circle_id and api.get_circle. I would expect that you would only need to update the circle details (api.get_circle()) rather than everything else. Any reason why the whole re-initialise?
Reason I am asking is that the urllib calls are all non asynchronous and may cause domoticz to indicate that the plugin may have ended unexpectedly. In that sense, I was hoping to only do the get_circle in onHeartbeat (and maybe even make that asynchronous through the plugin http mechanism) in order to speed things up.
Thoughts?
H
Re: Python Plugin: Life 360 Presence Detection
Posted: Tuesday 18 September 2018 9:13
by febalci
@heggink: Thanks for the details. I was not sure if the circle_id is a constant all throughout the time, or was changing from time to time. That's why i put get circle_id also in the onheartbeat. I am planning to do a do-over of the plugin soon. I will also take this into consideration.
Re: Python Plugin: Life 360 Presence Detection
Posted: Tuesday 18 September 2018 11:33
by heggink
@febalci: I changed my local plugin.py to test it and, for now, it seems to work OK but I am not sure for how long and whether, at some point, you need to reconnect.
On this subject, I was trying to see what's required to move to the plugin framework's async messaging. In that sense, trying to do all the connection setup asynchronously would be a mess (since the startup needs the circle home members in order to create devices) which is where I was wondering whether you can do the setup using urllib and then switch to the async calls for the heartbeats. Then again, if the connection expires then one would need to do a reconnect again so more complexity...
Difficult...
Re: Python Plugin: Life 360 Presence Detection
Posted: Tuesday 18 September 2018 12:23
by febalci
heggink wrote: ↑Monday 17 September 2018 22:36
@febalci: I noticed in your plugin that, onHeartbeat, you call
api = life360(),
api.authenticate,
api.get_circle_id and
api.get_circle. I would expect that you would only need to update the circle details (api.get_circle()) rather than everything else. Any reason why the whole re-initialise?
Just now issued v2.0.0 which includes those items:
v2.0.0
- Fixed:If the target is unreachable (Other side of ocean-@heggink) the distance is now 0 in order to prevent memory problems
- New:Removed get_circle_id from onheartbeat since it is a constant (@heggink) to reduce life360 api calls
- Fixed: If the addess is defined as a name other than 'Home' (Like School) in life360, distance was showing as 0 km.
- New: Reduced Google Maps API calls by incorporating address to getdistance function. getaddress is only called if getdistance returns None address.
This also solves (at least the memory problem) with overseas travels.
Re: Python Plugin: Life 360 Presence Detection
Posted: Tuesday 18 September 2018 15:24
by heggink
hey @febalic,
your heartbeat still has the following in it:
Code: Select all
api = life360(authorization_token=self.authorization_token, username=Parameters["Username"], password=Parameters["Password"])
if api.authenticate():
So you only took out the get_circle_id and not the api.authenticate(). I believe you can also take that out unless the token expires at some point, correct?
Re: Python Plugin: Life 360 Presence Detection
Posted: Tuesday 18 September 2018 15:54
by febalci
heggink wrote: ↑Tuesday 18 September 2018 15:24
hey @febalic,
your heartbeat still has the following in it:
Code: Select all
api = life360(authorization_token=self.authorization_token, username=Parameters["Username"], password=Parameters["Password"])
if api.authenticate():
So you only took out the get_circle_id and not the api.authenticate(). I believe you can also take that out unless the token expires at some point, correct?
Token is more likely to change. I feel it like it is a session token. If you are sure it doesn't change; then we can try it.
Re: Python Plugin: Life 360 Presence Detection
Posted: Tuesday 18 September 2018 18:08
by heggink
Let's see how my changes behave over a couple of days. Will let you know. Also trying to replace the synchronous calls but life360 complains about a bad request
Re: Python Plugin: Life 360 Presence Detection
Posted: Tuesday 18 September 2018 20:56
by febalci
Honestly i didnot get the logic behind changing sync calls. As far as i remember plugin framework was not allowing async calls. And yet i still do not know which is sync which is asynch call
So my motto is if it Aint break dont mess with it
Re: Python Plugin: Life 360 Presence Detection
Posted: Tuesday 18 September 2018 21:11
by heggink
Understood. It's just that I run quite a number of python plugins that use urllib to interface to iCloud, life360, weather systems and so on. Urllib is blocking and I have the feeling that it impacts responsiveness of my system more than if they were in an asynchronous way. Sometimes walking into the garage, it takes seconds for the light to turn on (dzvents script) where normally it is sub second.
Re: Python Plugin: Life 360 Presence Detection
Posted: Monday 01 October 2018 23:16
by aldodemi
With current version if I put my Google Maps API Key I receive this error:
2018-10-01 23:13:34.355 Error: (Life360) 'onHeartbeat' failed 'UnboundLocalError':'local variable 'jsonr' referenced before assignment'.
2018-10-01 23:13:34.356 Error: (Life360) ----> Line 254 in '/home/domoticz/domoticz/plugins/life360/plugin.py', function onHeartbeat
2018-10-01 23:13:34.356 Error: (Life360) ----> Line 199 in '/home/domoticz/domoticz/plugins/life360/plugin.py', function onHeartbeat
2018-10-01 23:13:34.356 Error: (Life360) ----> Line 58 in '/home/domoticz/domoticz/plugins/life360/googlemapsapi.py', function getdistance
2018-10-01 23:13:34.356 Error: (Life360) ----> Line 43 in '/home/domoticz/domoticz/plugins/life360/googlemapsapi.py', function make_request
without API key no errors but also no locations info.
The API key is correct.
Any help well accepted
Re: Python Plugin: Life 360 Presence Detection
Posted: Saturday 06 October 2018 20:14
by l00pz
heggink wrote: ↑Tuesday 18 September 2018 21:11
Understood. It's just that I run quite a number of python plugins that use urllib to interface to iCloud, life360, weather systems and so on. Urllib is blocking and I have the feeling that it impacts responsiveness of my system more than if they were in an asynchronous way. Sometimes walking into the garage, it takes seconds for the light to turn on (dzvents script) where normally it is sub second.
Is the Plug-in still working after you modified it? I have the same problem as you describe, and I am curious as this is a possible solution.