pnbruckner / ha-life360

A Home Assistant integration for Life360.
32 stars 4 forks source link

Request location update for homeassistant.update_entity service call #4

Closed pnbruckner closed 1 month ago

pnbruckner commented 1 year ago

The homeassistant.update_entity service call would only cause the life360 integration to immediately query the server for new data it currently has. Basically, jump to the end of the current 10 second query period, and get any new data the server might have from member devices since the last query.

Note, though, that it is possible some member devices haven't provided new location data to the server for an extended period of time (e.g., when the devices aren't moving.) So, the effect of the homeassistant.update_entity service call is minimal (i.e., only getting any new data the member devices might have decided on their own to send to the Life360 server since the last time the life360 integration queried the server.)

This change sends a request to the server to have the member device update its location first before the life360 integration fetches data from the server. This can be used to get the most up-to-date location data from a member's device. E.g., when some other entity (such as a router-based tracker for the same device) indicates the device has come home, this can attempt to update the life360 tracker entity so it agrees as quickly as possible.

However, just because the device has been requested to update its location, it's still possible it won't (e.g., it has a bad network connection, has been turned off, etc.)

This change also adds a new attribute, namely circles, which lists the Life360 Circles the member is in, and its status in that Circle (e.g., not sharing location with circle, etc.)