Automation trigger entitity id in an action

I have an automation that fires when a PIR sensor picks up motion.

The triggers are set as 2 different sensors in 2 different rooms, and so have 2 different entity_ids.

When motion is detected, I fire a notification to my phone via pushbullet.

I would like the notification to stipulate where the motion was detected.

Looking through the docs I think its possible using templating, but I cant figure it out.
I create all my automations via the front end configuration panel, and my automations.yaml file doesn’t really seem to make much sense, or at least have a logical flow to it?

Could anyone help me out?
Do people generally use the front end to create and manage automations, or is it best to ‘manually’ create them in a .yaml file?

try that:

    service: notify.notification_service_you_use
    data_template:
      message: 'Motion detected on {{states.binary_sensor.pir_name.name}}'
1 Like

Thanks for taking the time to help.

That just returns Motion detected on
As in blank
My PIR snesors aren’t binary sensors, they are mqtt sensors

Few screen dumps of how I’ve set it up…




you’d then need to replace binary_sensor.pir_name with the name of your sensor…
I have no idea how you defined your MQTT Sensor, though I would expect them to be binary as they’ll either return a status showing motion (so on) or no motion (so off) and they should therefore be defined as binary_ssensors.
In addition you can define them with device_class: motion and they’ll behave as motion sensors in HA.
if you provide an extract if your config I can have a closer look

you’d need to have 2 sensors returned by MQTT of course for this to work…

Both sensors are defined as this, just the name and mqtt topic change

- platform: mqtt
  state_topic: "sensor-node/lounge"
  name: 'Lounge Sensor Node PIR'
  value_template: '{{ value_json.motion }}'

I want the notification to tell me which sensor has been triggered?

I would just put the trigger device in the message like the example and report trigger.entity_id

automation:
  trigger:
    platform: state
    entity_id: 
      - sensor.one
      - sensor.two
  action:
    service: notify.notify
    data_template:
      message: >
            Motion just occured at  {{ trigger.entity_id }}
1 Like

How does one use templating when using the front end to create automations?

Or can you not?

I am not sure if you can, I just edit my configuration.yaml when I add automations.

Ah ok.
So I can still edit automations.yaml as in the past before the GUI editor was introduced?

any update in this component and lack of function?