Automation / Presence Help

I’ve been busy creating my rules and such to help automate my house, I have the following rule:

- alias: People Arriving Home
  trigger:
    platform: state
    entity_id: device_tracker.name1, device_tracker.name2
    from: 'not_home'
    to: 'home'
  action:
    service: notify.fb
    data:
      message: 'Welcome home.'
      target:
        - +44xxxxxxxxxxxxxx

What I would like is to include in the fb notify the name of the device tracker that triggered the event. Is there a clever way to do it, or do I need multiple rules for each device_tracker?

You don’t need a separate automation at all. Just follow the first example at this link: https://home-assistant.io/docs/automation/templating/

You’ll need to use trigger.entity_id in your message (listed near the bottom of the page). And be sure to read the important rules section. :grinning:

What you want to do is exactly (well almost) what I was setting up today. I will try and help, just understand I too am still learning and by no means an expert.

- alias: People Arriving Home
  trigger:
    platform: state
    entity_id: device_tracker.name1, device_tracker.name2
    from: 'not_home'
    to: 'home'
  action:
    service: notify.fb
    data_template:
      message: "Welcome home {{ device_tracker.name }}"
      target:
        - +44xxxxxxxxxxxxxx

Now, how you extract the friendly name from that I am not sure of. It may need some tweaking, but the templating is what you are after I believe. I ‘think’ it will be something along the lines of {{ trigger.to_state.friendly_name }} but don’t hold me to that.

I think that what you need is {{ trigger.entity_id.attributes.friendly_name }}

Unfortunately it’s not terribly easy for me to test this myself to confirm- but I hope it helps!