IFTTT Notifications and Data Templates Help

Hi all -

I’ve created a IFTTT notification. This notification is triggered when a person enters the house. I was able to accomplish this by the following code under “automation”:

  - alias: "Presence Detection arrival notification"
    trigger:  
      - platform: state
        entity_id:
          - device_tracker.iphonejustinbt
          - device_tracker.iphonejoelbt
          - device_tracker.iphonemombt
        from: "not_home"
        to: "home"
    action:
      service: ifttt.trigger
      data_template: {"event":"presence_arrival", "value1":"{{ trigger.entity_id.split('.')[1] }}", "value2":"{{ trigger.to_state.state }}"}

and I have an IFTTT recipe configured where “If Maker Event receives “presence_arrival”, then send an arrival notification.” It works fine and I receive the following notification back:

iphonejustinbt {{value1}} has arrived home {{value2}}

This works great, but is it possible to use the friendly_name (e.g. Justin) instead of it’s entity name (iphonejustinbt)? Is there something that I would need to tweak within my “data_template”?

Sorry if this is a dumb question. Any help is appreciated! Thanks all!

Hi,

if you want you can delete the from statement. So it fires not only if your state ist not_home, for example, you have set another zone (supermarket) next to your home zone, your statement won’t work because the device tracker has status supermarket and not not_home. For my case i added value3 for the previous zone.

I think it should be also possible to realise our case platform: zone

automation:
trigger:
platform: zone
entity_id: device_tracker.paulus
zone: zone.home
# Event is either enter or leave
event: enter

did you solved the friendly_name part? Or any other…
I stucked at the same part :slight_smile:

Is trigger.friendly_name available in that context?

Tip: You can experiment with the templates tab in the dev tools. It won’t help exactly with this situation since it can’t see “trigger”, but you can experiment to try to find the right syntax. Like, this’ll give the friendly name of a light:

{{ states.light.livingroom_track.attributes.friendly_name }}

Ok i will give it a try.

I have to correct my statement of deleting the from field. I tested it with my iPhone (tracking).
If im not defining the from field it will fire every time the status of the zone will be updated (no zone changing, only get the current location information). In my case it will appear every 8 minutes.
Its the same if i use an automation for my hue lamps and just changing the colour or brightness.

- alias: Test
  hide_entity: false
  trigger:
    platform: state
    entity_id: light.bulb_1, light.lightstrip_bedroom
  action:
    service: ifttt.trigger
    data_template: {"event":"Test", "value1":"{{ trigger.entity_id.split('.')[1] }}", "value2":"{{ trigger.from_state.state }}", "value3":"{{ trigger.to_state.state }}"}

I just want to get a notification of the change, so for example
light.bulb_1 off on
or
iPhone home not_home (another config, but similar to that light setting)
and vice versa

If i configure it like above i get a notification light.bulb_1 off on (thats fine) but if im changing the colour or brightness i get light.bulb_1 on on.
To set the status from: off isn’t an option for me, because i don’t want to create an automaton for every condition.

Any ideas how to change my configuration?

I’m not 100% sure I understand. But you can specify a “to” state without a “from” if that helps. Otherwise, you get a trigger every time the state changes.

yes thats right.
My test case to understand the automation itself:
Every time the status of an entity changes i want to get a notification (old status and new)
For example im (entity id of my phone) leaving home (from state) and entered supermarket (to state). -> Notification: Phone Home Supermarket
After shopping im (phone) leaving supermarket (from) and went to undefined zone (to). -> Notification: Phone Supermarket not_home
After having coffee at undefined zone (from) im (phone) arriving home (to) again. -> Notification: Phone not_home Home

I don’t want to create different automations for every special case and tried it by not defining one or both states (from and to) at trigger settings. But if im doing that, i always get, every time the device sends (only updates) his state (in that case the phone location) to the HA, a notification -> Notification Home Home
For my phone (via iCloud device_tracker) it appears every 8 minutes.
For my hue lamps it appears every time the status of the lamp changes: brightness, color and of course on/off.

I hope i could clarify my “problem” :slight_smile:

where you able to get it working with the friendly names?

i wasn’t but i haven’t tried it since my last post.

@just1ncase17

Question, your IFTTT maker event is setup something like:
event name: presence_arrival
SMS-message: some name… {{value1}} has arrived home {{value2}}

for some reason, Im not receiving any notiications, I copy and pasted the code above into my config.yaml and then changed the “device_tracker” devices with my own, and created the IFTTT event from maker: web requests…maybe IFTTT SMS message needs to be configured different?

ie:
SMS-message: {{value1}} is {{value2}}
to get something like “somebody is home” somebody is not home"