pnbruckner / ha-life360

A Home Assistant integration for Life360.
45 stars 6 forks source link

Sometimes it works #12

Closed erucxz closed 6 months ago

erucxz commented 10 months ago

My HA-Life360 Integration is working sometimes. Every time I restart HomeAssistant it's broken again. But maybe it is good to know for you that it works sometimes. It doesn't work again after restarts but sometimes it just starts to work. I don't know if this helps but maybe it does.

pnbruckner commented 10 months ago

I'm not totally surprised, but it's just become clear it isn't worth trying to keep up with the changes, especially since they seem to have actively started trying to block us. From what I've heard, it's not surprising that it still can work from time to time, but not consistently.

riddik14 commented 8 months ago

My HA-Life360 Integration is working now

naxey commented 8 months ago

Same here, it seems to be back to normal

pnbruckner commented 8 months ago

@riddik14 @naxey what HA Core version are you using? And what version of this custom integration are you using?

I know this integration is broken with very recent HA versions, but I'd like to give it (yet another) try. Last time I did, even though it seemed to work for some, it didn't for me (and I'd assume, for most people.)

naxey commented 8 months ago

Core 2024.3.0 Supervisor 2024.03.0 Operating System 12.1 Frontend 20240306.0

Life360 0.3.10 via HACS

pnbruckner commented 8 months ago

I just tried those same versions (I'm running a test system in a docker container), and I get:

This error originated from a custom integration.

Logger: custom_components.life360
Source: helpers/update_coordinator.py:350
integration: Life360 (documentation, issues)
First occurred: 9:12:01 AM (2 occurrences)
Last logged: 9:12:01 AM

Error fetching TEST_EMAIL data: ClientResponseError: 429, message='Too Many Requests', url=URL('https://api-cloudfront.life360.com/v4/circles')
Error fetching life360 data: ClientResponseError: 429, message='Too Many Requests', url=URL('https://api-cloudfront.life360.com/v4/circles')
kaaspad commented 8 months ago

I just tried those same versions (I'm running a test system in a docker container), and I get:

This error originated from a custom integration.

Logger: custom_components.life360
Source: helpers/update_coordinator.py:350
integration: Life360 (documentation, issues)
First occurred: 9:12:01 AM (2 occurrences)
Last logged: 9:12:01 AM

Error fetching TEST_EMAIL data: ClientResponseError: 429, message='Too Many Requests', url=URL('https://api-cloudfront.life360.com/v4/circles')
Error fetching life360 data: ClientResponseError: 429, message='Too Many Requests', url=URL('https://api-cloudfront.life360.com/v4/circles')

@pnbruckner im using the latest versions of HA (hassos, not beta). With this custom integration, today it started working again. With new an old accounts.

riddik14 commented 8 months ago

I confirm

riddik14 commented 8 months ago

@riddik14 @naxey what HA Core version are you using? And what version of this custom integration are you using?

I know this integration is broken with very recent HA versions, but I'd like to give it (yet another) try. Last time I did, even though it seemed to work for some, it didn't for me (and I'd assume, for most people.)

It work with latest core, probably life360 policy is to be removed from server

pnbruckner commented 8 months ago

I tried the life360 pypi.org package by itself. It does seem to work again. So, I'll have to spend some time on this custom HA integration. It may not be "broken" with currently available HA releases, but I'm pretty sure it is with the dev branch, so probably will be broken with the next minor HA release (2024.4.)

If I do get it working again, there's no telling if/when Life360 will lock us out again.

naxey commented 8 months ago

I checked the integration and the last update happened on March 23, 2024 at 6:02:10. The Life360 integration seems to have only updated between March 21, 2024 at 7:33:14 and March 23, 2024 at 6:02:10, at least on my end. Now the entities are stuck with the value from March 23, 2024 at 6:02:10 but not unavailable.

This might explain why reproducing the functionality of the addon failed.

@riddik14 did the integration also stop sending data on your end?

EDIT: I've updated to Core 2024.3.3 after posting this and the Life360 integration has updated the position of all entities once right after restarting HA and stopped updating after. I ditto the idea of rate-limiting being the issue at hand.

pnbruckner commented 8 months ago

I'm working on adding handling for the HTTP error 429, too many requests. It seems it is now doing some rate limiting, which explains why I saw those errors. It happens sometimes, but not other times. It is returning a "retry-after" value, so I'm going to try and work that in.

pnbruckner commented 8 months ago

After some limited testing, where I'm pulling data for 1 Circle with 2 Members every 10 seconds, it seems to work for several cycles, then I'll get an error 429 with a retry-after of 600 seconds (i.e., 10 minutes.) I haven't run it long enough to draw any reasonable conclusions, but it does seem like it won't be very usable for HA. Updating every 10 seconds for maybe a minute or 2, and then having to wait 10 minutes before getting more updates, doesn't seem very useful. We'll see...

pnbruckner commented 8 months ago

There's something more to it than that. If I run my test script, it often has to wait for the first request, but then after that it runs for a while. If I quit it while it's running ok, then restart it, it has to wait again. So maybe there's something about opening a new session. Maybe I need to save and restore cookies. Still working on it...

pnbruckner commented 8 months ago

Some more progress to report.

First, in my test program (together with some changes in the life360 package), I've implemented saving & restoring both the authorization token & session cookies. (The former was done in the integration, but not the latter.)

Next, I changed the test program to not ask for a list of circles and places every cycle. For now, I'm using a static circle ID, and only requesting data for members in that circle each iteration (i.e., every 10 seconds.)

I also implemented some caching, since I noticed the server was sending an "l360-etag" header.

So far, the test has been running for over 20 minutes and no errors.

I'll have to experiment to see how often the request for circle & place IDs can be made without making the server angry. Maybe every 15 minutes, every hour, once a day, ...???

Still some work and more testing to do...

pnbruckner commented 6 months ago

Closing since the PR mentioned should hopefully get the integration working again. I hope to release a beta soon.