I’m trying to create a series of people-location sensor templates that only reflect a specific set of zones.
I have 8 templates (1 per person) that, as attributes, includes
- last_location
- new_location
This was easy.
Some of the locations (or HA zones) I track are:
- home
- near_home
- kids home 1
- kids home 2
- other city 1
- other city 2
- many others
On my dashboard I want to display interactions with “home”. Thus I want my templates to only update when either last_location or new_location become “home” or “near_home”
Here is an example of one of my existing templates: (yes, I know the now() trigger isn;t particularly efficient but I’m experimenting right now)
- trigger:
- platform: state
entity_id: person.john_smith
to:
sensor:
- name: person john smith location template
state: "{{ now() }}"
attributes:
display_name_for_table: "John Smith"
from_location {{state_attr('sensor.person_john_smith_location_template','new_location')}}"
new_location: "{{ states('person.john_smith').replace('not_home', 'Away')}}"
short_name: "John"
master_sort_value: 5
Is there an elegant way to get this to update just for the specific locations (zones) I want - or will I end of with lots of nested logic where I assign values to my attributes?
Some things I need to consider:
I was looking at triggering on a change in the state of the person (which should indicate a new_location). That could be anywhere (I can’t trust that it would be an existing zone as someone might turn on their cell phone while in the home so from_location could be unknown).
Also, someone could turn off their cell phone just before leaving the house, so I wouldn’t get a new location update when they leave.
Two of the visitors use apple phones, and these seem to always stop working in background after a while (even if back ground processing is turned on). I’m told this is a long standing apple problem so I just have to live with that.
The use case for all this:
I travel a lot, and often for many months at a time. In general HA does a wonderful job of keeping my house in order - but I’d still like the human touch of someone walking through once a week (as would my insurance company)
So, I ask friends and family members to check on my house. I give them all the HA companion app (or at the very least track them through my router via their phones mac address) I ask that my house be checked at least once a week. Because they have the HA app, when they arrive it’s easy for them to unlock doors from their phones. In addition, HA will adjust HVAC and lights as soon as they enter the near home zone. In exchange for HA getting the house ready for their visit - I get to know they are there.
The templates above serve as the data for a flex-table where I can see the last interaction each visitor had with my house. In general the visitors go to the house on a set schedule - and they all share a whatsapp group to share findings issues etc - but they would also like to be able to look at the table and see when someone was last at the house to help them plan accordingly. My visitors have their own lives (?) and may not always be able to visit when scheduled - so this table would be the best version of the truth.
Right now that table is only correct when a visitor is at the house. Once they leave and travel to multiple other zones, I will have no idea as to when they last interacted with the house (well I can look at the history but that isn’t end-user friendly)…
Thoughts??
thanks,
Ken