Notification when motion detected

Hello,

I’m trying to configure automation to raise push notification when motion is detected and it seems that it’s not being triggered when binary sensor change its state. Could you please advise me where I am making mistake?

My automation:

- id: 'some id'
  alias: Notify me if motion detected and I am not at home
  description: Motion in empty flat?!
  trigger:
  - platform: template
    value_template: '{{ is_state(''binary_sensor.living_room_living_room_5'', ''on'')
      }}'
  - entity_id: binary_sensor.living_room_living_room_5
    for: 00:00:01
    from: 'off'
    platform: state
    to: 'on'
  condition:
  - condition: device
    device_id: some_id
    domain: device_tracker
    entity_id: device_tracker.vog_l29
    type: is_not_home
  action:
  - data:
      message: Motion detected!
    service: notify.mobile_app_vog_l29

My motion sensor:

Logbook events:


Missing automation trigger

No errors in the logs and when I trigger automation manually I receive notification as desired. Only triggering is not working…

Thanks for help!

Why not just use the state trigger instead of template?

Triggers like that:

trigger:
  - entity_id: binary_sensor.living_room_living_room_5
    platform: state
  - entity_id: binary_sensor.living_room_living_room_5
    for: 00:00:01
    from: 'off'
    platform: state
    to: 'on'

are not working either

Seems like first trigger is missing a “to:” directive.

Maybe the problem is in your condition?
If you remove it, does it change anything?
By the way, I can see no device condition here.

Condition is fine. I set up automation via web interface, I was not writing the scrip by hand
Removing the condition doesn’t change a thing as automation is not triggered. When I trigger manually I receive popup. Problem is with the trigger

It’s not mandatory to have, but will try

Point is it is not necessary and since you asking and current not working, try the suggestion you ask for

Also why only trigger for 1second change.
Remove that also.

I often leave the “from:” and only put “to”.
I think “unknown” may occur in some circumstances for zwave so off/on transition may not occur to trigger

Your trigger should simple be this:

trigger:
  - platform: state
    entity_id: binary_sensor.living_room_living_room_5
    to: 'on'
1 Like

well, the only problem is OP’s original triggers should cover this one and still he insists it does not trigger.
maybe the automation is disabled? :wink:

Also… the time in for: needs to be in quotes

 for: "00:00:01"

When you trigger an automation manually the conditions are skipped.

Please try the following code to see if the trigger is the problem:

- id: 'some id'
  alias: Trigger test just to make sure
  description: Test Trigger
  trigger:
    platform: state
    entity_id: binary_sensor.living_room_living_room_5
    to: 'on'
  action:
    service: persistent_notification.create
    data:
      message: "Trigger is working!"

Trigger worked in real case.

I was testing it by changing the values of the motion sensors manually. And that didn’t triggered the automation. When I steped into my house I got popup.

Thanks for help

And that’s the solution? 8()