Tracker home/not home

Hi!
Right now i have Unifi tracker (For not family) and iCloud for Family.
And i use Pushover for notify.

Today i have 1 rule for every Family/not family when home/ not home.
Could I in any way make 1 rule, for who ever enter/ leave home?

I think you need to be a bit more specific with your problem. I fail to grasp what you are trying to achieve / want to happen.

~Cheers

Are you asking if you can do an all encompassing automation for different trackers? if so, then yes.

Just use an OR condition

Allright, what i mean is that today i have one automation for every person in the home.

like this:
- alias: ā€˜Rule 014 - Notify me Away Sussā€™
hide_entity: True
trigger:
platform: state
entity_id:
- device_tracker.susanne
from: ā€˜homeā€™
to: ā€˜not_homeā€™
action:
service: notify.iphone7
data:
message: ā€˜Suss left homeā€™

But what I would like to have is 1 automation for everyone.

Iā€™m interested in how to implement this too.
Iā€™m having welcome sound automations (17 at the moment) for certain people which play over my Chromecasts when they connect to my wifi network. I have 17 seperate automations for this and everytime I want to add someone I have to create a new automation. I know there must be a way to combine them all in 1 automation but havenā€™t succeeded yet.

This is what I have now (17 automations like this):

- alias: 'Welcome xxxxxx'
  trigger:
    platform: state
    entity_id: device_tracker.xxxxxx
    from: 'not_home'
    to: 'home'
  action:   
    - service: media_player.volume_set
      data:
        entity_id: media_player.home_group
        volume_level: '0.65'
    - service: media_player.play_media
      data:
        entity_id: media_player.home_group
        media_content_id: <<DIRECT MP3 LINK>>
        media_content_type: 'audio/mp3' 

Iā€™m just spitballing here because Iā€™m barely 2 weeks into my HA build but is it possible to use a group as the entity id?

Multiple ways actually to handle this. Easiest would be to donā€™t do full blown automations just add multiple trigger to your automation like so:

- alias: 'Welcome People'
  trigger:
    - platform: state
      entity_id: device_tracker.xxx
      from: 'not_home'
      to: 'home'
    - platform: state
      entity_id: device_tracker.yyy
      from: 'not_home'
      to: 'home'
  action:   
    - service: media_player.volume_set
      data:
        entity_id: media_player.home_group
        volume_level: '0.65'
    - service: media_player.play_media
      data:
        entity_id: media_player.home_group
        media_content_id: <<DIRECT MP3 LINK>>
        media_content_type: 'audio/mp3'

Other solutions include using template conditions and you declaring a array of people that should be notified. Itā€™s a little less work to add someone new but would require more tinkering than just multiple triggers :slight_smile:

~Cheers

You would use the same thing I explained one post above but additionally you would use a ā€œdata_templateā€ for your notify service like this:

action:
  service: notify.iphone7
  data_template: 
    message: '{{ trigger.to_state.attributes.friendly_name}} just left home'

~Cheers

@PhyberApex thanks for your reply, I understand the multiple trigger part. But for the play mp3 part I probably need to use an If/Else template. My problem is that I donā€™t know where to compare the device tracker IDā€™s with.

This is what I have came up with, missing some crucial parts.

- alias: 'Welcome People'
  trigger:
    - platform: state
      entity_id: device_tracker.xxx
      from: 'not_home'
      to: 'home'
    - platform: state
      entity_id: device_tracker.yyy
      from: 'not_home'
      to: 'home'
  action:   
    - service: media_player.volume_set
      data:
        entity_id: media_player.home_group
        volume_level: '0.65'
    - service: media_player.play_media
      data_template:
        entity_id: media_player.home_group
        media_content_id: >
            {% if is_state("what do I need to put here?", "device_tracker.xxx") %} <DIRECT LINK TO MP3 1>
            {% elif is_state("what do I need to put here?", "device_tracker.yyy") %} <DIRECT LINK TO MP3 2>
            {% endif %}
        media_content_type: 'audio/mp3'

You are nearly there. If you look here you can see what is available to you from the triggered entity that triggered this automation: https://home-assistant.io/docs/automation/templating/#available-trigger-data

So maybe this is what you want?

media_content_id: >
            {% if trigger.entity_id == "device_tracker.xxx" %} <DIRECT LINK TO MP3 1>
            {% elif trigger.entity_id == "device_tracker.yyy" %} <DIRECT LINK TO MP3 2>
            {% endif %}

~Cheers

Wow, did not find that page earlier. This is the key to a lot of new ideas. Thanks man!

1 Like