What I find happening is the state constantly changes between not_home and driving. I thought about it after I set it up and then verified it when I left work.
I’ll look at customising the platform and see how that goes.
I just tried adding that and although none of us are in transit right now, it’s working ok. I can update you when the in_transit status changes for one of us.
Actually, this seems like a really nice feature. I just ran some errands and looked back at the history, and sure enough it showed me moving while I was gone, except for the few stops I made.
I think I’ll add another config option to enable this. (Some people may prefer the state only being ‘home’ or ‘not_home’. Which makes me think, maybe I should add another config option for showing Places as states, too.) Given that states are usually all lower case (I think) I’ll probably show inTransit as ‘moving’. I should probably also show isDriving as ‘driving’, and it should probably take precedence over ‘moving’. Maybe I’ll temporarily enable “Drive Detection” in Life360 to see if/how that shows up.
@pnbruckner Do you have plans to put this on github? It would be great to expose loc_name as an attribute to trigger actions based on life360 defined locations/places
The code is at the top with instructions (although not with these latest changes yet) so you can copy and paste it for now. But, yes, I hope to get it into github before long.
loc_name actually becomes the device_tracker state so you can trigger automations based on places.
I tried enabling “Drive Detection” via the Life360 app, and although the Life360 app now showed when I was driving as Driving (as opposed to Moving), the raw data from the server still had a value of ‘0’ for isDriving. Hmm, maybe this parameter is associated with their extra cost “Drive Protection” service (which I don’t have.)
New update: Changed attribute in_transit to moving to be more consistent with how Life360 reports this status. Added new configuration option show_as_state to control which attributes will affect device_tracker entity’s state. (To be equivalent to previous behavior you must add show_as_state: places to your configuration.)
Oops, should have tested a little longer! State was still being set to moving (or driving) even when device entered a HA zone. Now being in a zone takes precedence over moving or driving, but Life360 Places (i.e., places) still takes precedence over everything.
Can you expand on what you mean by that? Do you mean the device_tracker entities aren’t updating anymore? Or they aren’t showing up at all anymore?
Are you seeing any errors on the Info page or in the log? If you have debug enabled for the log, are you seeing any Checking members or Updating messages for custom_components.device_tracker.life360?
If you do this: grep 'custom_components\.device_tracker\.life360' home-assistant.log
Ok. I’m on 0.67.1, and I know there were changes made since then regarding how custom components & platforms are loaded. I’ve seen others discuss how this caused problems. I wonder if this is part of the problem here. I was hoping to wait a while for that “dust to settle” before updating, but maybe I need to do that anyway. I’ll try to do that soon.
Did you happen to upgrade between the time this worked for you and now?
Can you share your corresponding configuration.yaml entries? You can private message me if you’d prefer.
Regarding the additional log messages, are you sure you have DEBUG messages enabled? Are you seeing any DEBUG messages in your log at all (from other components)? If you need help enabling DEBUG messages, let me know.
Kind of surprising that the entities aren’t updating, yet you’re apparently not seeing any errors either. Hmm.
Do the entities show up on the States page? And if so, what are the last_update and at_loc_since attributes showing?
Ok, that is the information that the recorder saves and restores when HA stops and restarts (apparently because those are basic device_tracker attributes.) So it would appear the entities are showing up only because they are getting restored by the recorder. That seems consistent with your other observations.
So then you didn’t just upgrade HA?
Also, can you share what you have for the following in your configuration.yaml (feel free to leave out anything sensitive)?
FWIW I’m on 0.69.1 and the latest version of this and everything’s working fine. If I had to guess, I’d say it’s probably a copy/paste error of the .py file(s). Copying the code in the embedded blocks is a bit cumbersome…