Yeah, I misspoke. HA automatically installs required packages by looking at a module’s REQUIREMENTS attribute. Usually it’s a simple list of package names (and version numbers.) So in order to potentially use timezonefinderL it would be in the list, and that would cause it to get installed, even if it wasn’t used.
I tested a way to avoid having timezonefinderL (and numpy) installed if you’d rather prefer it wasn’t, but it’s not pretty. Unfortunately the standard mechanism only checks the REQUIREMENTS attribute when the platform is loaded, which is done before the config for the platform is processed. Therefore avoiding the install can’t be based on the config (unless I’m overlooking something.) The idea I came up with is: add a file named life360_no_tz to the directory containing configuration.yaml. I could then adjust the REQUIREMENTS list by whether or not that file exists (because this can be done when the platform is loaded, which happens just prior to the requirements processing.) Like I said, not pretty, but it would provide a way to avoid having these large packages installed if you don’t intend to use them, and you care about the space they take up.
Now having said that these two packages are “large”, and they are compared to other packages used by HA, in the grand scheme of things, we’re only talking about 40 MB, when most disks are in the GB’s. My current SD card is 32 GB, and only 3.7 GB is used – for everything. So 40 MB represents less than 1% of the used space, and only about 0.1% of the disk size. So I’m not sure implementing an unusual mechanism to avoid taking up that space is worth it.
But, I really do appreciate the feedback. I’m going to wait a while before releasing anything to see if a consensus forms.
Been reading this with much interest, and my feedback would be: as an accountholder of a family circle that has spread around the world in more than 2 timezones, that change more frequently than I would have ever imagined… I would give a big +1 for that extra timezone option most certainly.
Disksize is of no consequence, using 64Gb SD’s which are nowhere near any sort of capacity threshold, and I wouldn’t imagine this feature would add to that. what are we talking about…
As a user of your component, I have found myself using and comparing the Composite component also because, as you said, Life360 isn’t perfect. Well, they both are very fine, and tbh, I could live with Life360 alone, In my setup, which is not very simple, with 6 family members each having more than a couple of device_trackers, Life360 is always correct on its own
So, iow, to cut it short: please add that feature, and the standalone Life360 component will grow even stronger and more useful. No competition.
Thanks for this great component.
Cheers, and happy traveling!
Got this setup perfect thank you for your work.
I do have one slight issue, iv added a family member to my circle and they do show and track in home assistant but doesn’t grab their icon ?
Just wanted to point out that I am not at all concerned with the ~40MB extra impacting available space. And since your timing tests show negligible impact on performance, then I guess there is no issue here one way or the other.
Thanks for the clarification that there currently isn’t a config option to avoid loading the extra packages if they are not going to be used.
My platform code does pass the “avatar” URL it gets from the Life360 server to the device_tracker component-level code to use for the entity’s picture. However, the component-level code will only use that the very first time that device is seen, and will store it in a new entry in known_devices.yaml for that device. If you change that member’s picture via Life360 after that, it will not get used since the known_devices.yaml entry has already been created.
I think the only way to get it to be used is to delete (or comment out) the entry for that member in known_devices.yaml, and then restart HA.
You may have missed the part of the conversation related to this issue that described the fix. It’s a new optional config item I added for the Life360 platform. Specifically, you need to add this to your life360 config:
The jury is still out on this. It occurred to me that I might be able to leave timezonefinderL out of the REQUIREMENTS list, so that it won’t always get installed. But rather, while my platform is starting up, if the config needs it, then call the method to install it (that would have been called automatically earlier in the process.) I haven’t determined yet if this is possible. If so, then I’ll try it and see how that works. But, I also want to make sure that it’s not likely to break if the loading system is changed. (E.g., if I see other components/platforms doing something similar, then I would think it’s relatively safe to do.)
EDIT: The jury just came in. Never mind! Too messy, not worth it.
Add time_as option to control time zone in which time attributes are displayed, and possibly add new time_zone attribute with the name of the time zone in which the device is located.
BREAKING CHANGE from earlier beta releases: time_as option replaces times_as_local & times_as. Choices for time_as are now: utc, local, device_or_utc and device_or_local.
I found that if I login to the Life360 website I can just get the new URL for the updated picture by right clicking the circular image of the user I want to update and copying the image address. Then just find the URL which looks like the one in known_devices.yaml. Seems easier than having to recreate the known device in HA, especially since I have automatons set up that may break if I change the name.
Update: I’ve re-enabled show_as_state: and driving_speed: and we’ve been back to rock solid for the past few days. I noticed that when I had them disabled and the Life360 app didn’t know my location, it would show me as away in HA. After re-enabling all is well again. I don’t know if this makes sense with how your code is written or if its just coincidence.
I have to admit, that doesn’t make a lot of sense. It could just be coincidental. But, let’s take a few steps back and check some basics…
First, how is the Home zone in HA defined? Do you just have the GPS coordinates defined in configuration.yaml under homeassistant, or have you also defined a Home zone? Are the GPS coordinates correct? (I don’t need or want to know the coordinates, just that they’re correct.) What is the radius? (If you don’t specifically define a Home zone, then I believe the default radius is 100 m.)
Next, how is your “Home” Place defined in Life360? Specifically, do its GPS coordinates agree with HA’s Home zone? What is its radius? What, exactly, is its name? Or do you not have a Place defined in Life360 that coincides with your Home zone in HA?
In your HA life360 configuration, did you define home_place if you have a Place in Life360 that corresponds to HA’s Home zone and it is named something other than “Home”?
What do you mean by “the Life360 app didn’t know my location”? Did it not have GPS coordinates for you, or do you just mean that you weren’t in one of its defined Places?
I just have GPS coordinates defined in configuration.yaml. The lat and long were pulled from google maps and appear to be correct based on the map in HA. I have nothing else defined zone wise. I have nothing defined for the radius so it is defaulting to 100m.
Home is “Home” as defined in Life360. My wife added her work place to her account which is in my circle named “US Post Office”. I typed in my home address in Life 360, not lat and long but judging by the map, it is within a few meters (certainly within HA defined radius). The radius (or diameter?) in Life360 for “Home” is 3540 ft zone. We set the zone large in an effort to turn lights on sooner.
home_place is not in my configuration.yaml file. I know it can be added, but didn’t see any reason to at this point.
My wife and I are both running Iphones. When we go into the app switcher, it shows previews of all open apps. When HA was showing me as away (I was at home), the Life360 app preview showed something to the order of unknown location. When I selected the app from app switcher it paused a second then updated location to home. As soon as that happened HA changed my status to Home.
I agree with you that it does not make much sense. The only thing that I can think of is Life360 changes its state from home if its actual state is unknown and re-enabling show_as_state somehow buffers or omits that state until a legitimate state change occurs.
Thinking about this more, it makes more sense. If I were writing logic for these two conditions I would do the following…
show_as_state disabled
if Life360_state == “home”
“Home”
else
“Away”
this doesn’t care what the state is called unless it is “home”
show_as_state enabled
if Life360_state == “home”
“Home”
else if Life360_state == any state but unkown
“Away, Driving, Moving, Etc.”
this would not change the state from “Home” unless a valid away state was sent. An unknown state would not trigger a change. Just a guess. I’ve been wrong many times before and I’m sure that won’t stop any time soon. Thank you for looking into this!
So, I started to write a very long response, with lots of detail, but while doing so, I think it finally dawned on me what the problem is.
When you have show_as_state defined, and it contains the option places, then generally your HA device_tracker entity’s state will be set to 'home' (which displays as “Home”) when the Life360 server indicates you’re in a location (i.e., Life360 Place or Check-In) whose name matches home_place (which defaults to “Home”.) In your case, that is an area around your home with a radius of about 1,079 m. Also in this case, HA will generally agree with the Life360 app about you being “Home.”
When you do not define show_as_state, or it does not contain the option places, then your HA device_tracker entity’s state will be set to 'home' (aka “Home”) when your GPS coordinates & accuracy indicate you are inside HA’s zone.home, which in your case is an area around your home with a radius of 100 m. Also in this case, it’s possible HA will not agree with the Life360 app about you being “Home.” E.g., if you are located inside Life360’s Home Place, but still outside HA’szone.home, Life360 will say you’re “Home”, but HA will say you’re “Away” (i.e., the device_tracker entity’s state will be 'not_home'.)
So, my recommendation is to do one of the following, or both:
Override the default radius of HA’s zone.home by explicitly defining a HA zone named “Home” with a radius that is the same as the radius of Life360’s Home Place. See HA’s docs about defining zones.
Make sure you define show_as_state and have it contain at least the option places.
If you do one or both of these then Life360 and HA should always agree about you being “Home” or not.