Help needed merging to triggers into one

Hi,

Who can help?

I have have two triggers. One for arriving in the oofce and one for leaving. How to merge them into one.

Trigger 1:

id: conradwork
alias: 'Conrad is in the office'
trigger:
- platform: state
  entity_id: device_tracker.homeassistant_conrad_iphone6s_owntrack
  from: 'not_home'
  to: 'Work'
action:
  service: notify.pushover
  data:
    message: "Conrad is in the office!"

Trigger 2:

id: conradworkgo
alias: 'Conrad leaves office'
trigger:
- platform: state
  entity_id: device_tracker.homeassistant_conrad_iphone6s_owntrack
  from: 'Work'
  to: 'not_home'
action:
  service: notify.pushover
  data:
    message: "Conrad leaves office!"

This is typically two automations as you have two different state triggers and two different actions. why do you want to combine them?

I totally agree.
I wasn’t thinking right.

Thanks for the response anyway.

Conrad

You could use some automation templating to achieve what you want. The first example on that page is actually quite similar to what you want to do.

The grammar might be a little funny, but you could even just use the “enter” or “leave” events as described here, which I think would have the syntax of {{ trigger.event.state }}.

You might still want to have two separate triggers (same ones you have now), but it’s okay for an automation to have two triggers. But with templating you can pull the zone or event that caused the automation to trigger, and use that in your notification. :slight_smile:

If you want the language to be more natural, a better option might be to use an if statement in your notification as shown here.