I have created the following automation that works great. However I was looking for some tweaks to allow it to work for all the proximity sensors I have for all the people in my house. I am trying to avoid copying the automation 4-5 times. Bonus if I can setup the same automation for all those people for SEVERAL different proximity states (ie. 5 miles, 25 miles, 50 miles)
here is the automation:
- id: 'five_miles_away_david'
alias: David is 5 miles away and heading home
mode: single
trigger:
- platform: numeric_state
entity_id: proximity.david_home
below: 5
condition:
- condition: and
conditions:
- condition: template
value_template: '{{ states.proximity.david_home.attributes.dir_of_travel == "towards" }}'
action:
- service: script.sonos_announce
data_template:
message: "David is 5 miles away and heading home!"
I know I can add the other proximity sensors to the trigger, but how can I check the appropriate conditions and send an appropriate message for these other sensors? (Hope this makes sense) Thanks in advance!
Yes. I’ve made an assumption that all your proximity sensors follow the same naming format as david_home. It slices off the last 5 characters leaving behind just the person’s name. If the other proximity sensors don’t adhere to the same format, then the template for message needs modification.
Just a note about a housekeeping issue. You categorized this topic as ‘Share your projects’ but it’s a better fit for Configuration > Automation.
‘Share your projects’ is typically for sharing things you’ve designed and constructed (software and/or hardware projects) that serve as an example for others to use. In this case, it’s simply a request for technical assistance (for configuring an automation).
You directed your question to me but you should be directing it to orphan264. I have not configured any proximity sensors; I helped to fix the automation posted by orphan264.