I will update and try this weekend
It seemed to work for me, no errors in the log. I updated the main file and the device tracker file, I saw commits to both. I added add_zones:true and an interval of 60.
All my zones showed up. The all have the same icon, and when you click them you donāt get anything, anyway to show a label or something so you know what the area is?
Iām thinking I will disable make automations now to have Home Assistant alert when at an area instead of Life360 then all my notifications come from one place.
Not sure how to make that automation, but sure itās a standard zone thing somewhere in HA I just havenāt looked up yet.
Awesome work!
I see this page, so I assume you copied the name?
Where in HA can you list all your zones? You can see icons and circles on a map, but they are not entities, so you donāt know their names.
Iām not 100% sure Iām following you.
The zone (friendly) names in HA should be the same as the Place names in Life360. When viewed on the map you should be seeing these names. The entity_idās come from an algorithm in HA, but basically if all the Place names are unique, then the corresponding zone entity_idās should be the Place name changed to all lower case, with spaces replaced by underscores, parentheses removed, etc. There are a few other possible transformations, but thatās the basic idea. So a Place name of āMy Workā should create a zone entity_id of zone.my_work. You can see all the entity_idās on the States page in the frontend.
For automations, you have two choices. You can use a zone trigger, or you can use device_tracker states, because when a device_tracker is in a zone, the device_trackerās state is set to the (friendly) name of the zone. So, e.g., letās say you had a Life360 Place named āMy Workā, which creates a zone entity_id of zone.my_work, you could trigger when device_tracker.me enters that zone either of these ways:
trigger:
platform: zone
entity_id: device_tracker.me
zone: zone.my_work
event: enter
or
trigger:
platform: state
entity_id: device_tracker.me
to: 'My Work'
Just remember for the latter, when a device_tracker is in the Home zone its state is āhomeā, not āHomeā.
Go it, see all the zones in the entities list now. My map for some reason has no text, just icons, wonder if thatās something I need to turn on somewhere?
Hmm, interesting. When I tested this feature I was focusing on whether or not the zones showed up on the map and if they were the right size (i.e., did I get the units correct - meters vs feet.) I also saw the icon, which I chose to look like the same icon Life360 uses. But now that you mention it I canāt say for sure whether or not the names appeared on the map. (I know zones defined in HAās config show the names on the map.) Iāll have to test again to see.
Well, just checked the zone doc page, and it says this for icon:
The icon to show instead of name.
Hmm, maybe I should nix the icon.
I think home icon is obvious, for others, maybe no icon so we see the text
I tried to make one automation to cover everything, but it randomly goes off even when the state doesnāt change. I assume some other value of the state is changing? it will just say Iām home every few minutes over and over, any ideas?
- id: zone_change
alias: Zone Change
trigger:
platform: state
entity_id: device_tracker.phone1, device_tracker.phone2
action:- service: notify.notify
data_template:
message: ā{{ trigger.to_state.name }} has arrived at {{ trigger.to_state.state }}ā
- service: notify.notify
You should format your YAML code using the instructions at the top of the page to make it readable.
But, yes, a state trigger without to
or from
will trigger for any state change, including only changes to attributes. And GPS-based device_trackers like Life360 will definitely update many times while the actual state string does not change.
You can add a condition that only lets the action run if the actual state string changed. I donāt have time right now, but Iāll edit this response in a while to show how you might do thatā¦
EDIT: Try this:
- id: zone_change
alias: Zone Change
trigger:
platform: state
entity_id: device_tracker.phone1, device_tracker.phone2
condition:
condition: template
value_template: >
{{ trigger.to_state and trigger.from_state and
trigger.to_state.state != trigger.from_state.state and
trigger.to_state != 'not_home' }}
action:
service: notify.notify
data_template:
message: "{{ trigger.to_state.name }} has arrived at {{ trigger.to_state.state }}"
This will only notify if the state string changes, and it doesnāt change to ānot_homeā (aka Away.)
I just tried it without an icon and sure enough now the name shows up on the map.
One interesting result I noticed while testing. So as not to bother the members in my usual Circle, I created a temporary circle so I could add Places to it. What I realized is, Places from all circles will be added as zones in HA. So whereas in Life360 Places are unique to circles, in HA youāll see all Places from all circles. I donāt think thatās an issue, but something to consider. If this becomes a problem I suppose I could add another option to specify which circle or circles from which to use Places.
Anyway, Iāll be checking in 2.0.0b3 soon, and before long releasing 2.0.0.
Released 2.0.0 (& library 1.1.0.)
Add option to create HA zones from Life360 Places. Add optional config variables add_zones and zone_interval. If add_zones is true or zone_interval is defined, create zones at startup. If zone_interval is defined update zones periodically. Do not use Life360 Places named Home (case insensitive.)
I updated and the names showed up, so it worked! Also, thanks for the automation, I added tonight and its not going crazy, so we will see how it works moving around tomorrow.
This platform has been reporting the deviceās charging status in an attribute named āchargingā. However, it appears ābattery_chargingā is more common. To be more consistent with other platforms, Iām going to change the attribute from āchargingā to ābattery_chargingā. Obviously this is a breaking change.
See issue #61 (and somewhat related issue #60.)
Iām willing to be convinced to leave it the way it is, though. If you feel strongly either way, please comment in my github issue #61, or here if you canāt use github.
Released 2.1.0 ā BREAKING CHANGE
Change charging
attribute to the more common battery_charging
attribute. Instead of a float, make battery
attribute an int like it should have been originally.
getting: ERROR (MainThread) [homeassistant.bootstrap] Error loading /config/configuration.yaml: mapping values are not allowed here
Any ideas?
device_tracker:
- platform: life360
username: !secret life360_username
password: !secret life360_password
interval_seconds: 10
filename: life360.conf
show_as_state: places, driving, moving
max_update_wait:
minutes: 30
How did you add Life360 into the custom tracker? Iāve just installed the customer tracker and am not sure what to do next, Iāve forgotten how I added stuff into before I had to rebuild from scratch.
Must be something basic in your configuration file(s), because I donāt see anything wrong with that snippet. If youād like to share more details via private message Iād be happy to try and help further. Also, is there more to that error message? It usually will tell what file and give a line and column number, which can sometimes help narrow down where the problem is.
Have you seen these:
My Life360 doc
My installation doc
Custom Updater installation doc
Donāt forget my Life360 implementation consists of two custom components: life360 and device_tracker.life360. You need to make sure you install both.
Yes all sorted now!
Sorry was being an idiot. Iād done this before is Lovelace but never in standard UI so was looking at my old config files wondering how it ever worked! Then I realised I needed to add the additional bits under custom_updater: