Garage door and motion sensor work together. Please help

Have a garage door and motion sensor. I want to notify me both of them when the door opening or closing or the motion sensor see something. But don’t want notification from the motion sensor when the door opening because the motion sensor see the door move.
So I want that the motion sensor work only after when the door opened about 20 second.

you’re going to have to at least try to come up with something first before we can help you any more.

- id: '1583487705828'
  alias: motion notify if the door open more than 30sec
  description: ''
  trigger:
  - entity_id: binary_sensor.kapu_mozgas
    platform: state
    to: 'on'
  condition:
  - condition: and
    conditions:
    - condition: state
      entity_id: binary_sensor.door_window_sensor_158d0003fa5728
      state: open more than 30sec
  action:
  - data:
      message: Motion detected
    service: notify.telegram

So don’t know how to tell that the gate open more than 30 sec? This is not working…

You can do it using a template:

- id: '1583487705828'
  alias: motion notify if the door open more than 30sec
  description: ''
  trigger:
  - entity_id: binary_sensor.kapu_mozgas
    platform: state
    to: 'on'
  condition:
  - condition: template
    value_template: "{{ is_state('binary_sensor.door_window_sensor_158d0003fa5728', 'on') and (as_timestamp(now()) - as_timestamp(states.binary_sensor.door_window_sensor_1_sensor.last_changed)) > 30 }}"
  action:
  - data:
      message: Motion detected
    service: notify.telegram
1 Like

Don’t know what is the problem but when I save this automatically change in the automations.yaml to this format and not working.

condition: template
value_template: >-
  {{ is_state('binary_sensor.door_window_sensor_158d0003fa5728', 'on') and
  (as_timestamp(now()) -
  as_timestamp(states.binary_sensor.door_window_sensor_1_sensor.last_changed)) >
  30 }}

Even in that format it should work the same.

What do you mean when you say it’s not working?

Becuse no message arrive after 30 sec when the door open and the motion sensor see motion.

Ok, I will try to clarify what you want to have happen…

let’s say you open the garage door. you don’t want the motion sensor to send you a notification based on the motion from the garage door opening.

then after the garage door has been open for at least 30 seconds the motion detector detects some other motion event, you want the message to be sent.

is that how you want things to work?

if that is the case then are you saying that the message isn’t being sent?

I would like you to paste the contents of the value template into the developers tools -> template page. With the garage door shut the result should be “false”. Then open the garage door. the result should still be “false”. Then after 30 seconds and you update the page the result should then be “true”.

Perhaps something like this:

  alias: motion notify if the door open more than 30sec
  description: ''
  trigger:
  - entity_id: binary_sensor.kapu_mozgas
    platform: state
    to: 'on'
  condition:
    condition: state
    entity_id: binary_sensor.door_window_sensor_158d0003fa5728
    state: 'open'
	for:
	  seconds: 30
  action:
  - data:
      message: Motion detected
    service: notify.telegram

Yes, that’s what I want. Will try the developers tools.

when it is closed: false
when opening: Error rendering template: UndefinedError: ‘None’ has no attribute ‘last_changed’

Tryed this but not work too. :frowning:

Edit:

Try again and now this is working what I want. Only changed the condition state ‘open’ to ‘on’. Don’t know why not worked first time with ‘open’.

- id: '1583529302190'
  alias: Motion at the gate
  description: ''
  trigger:
  - entity_id: binary_sensor.kapu_mozgas
    platform: state
    to: 'on'
  condition:
  - condition: state
    entity_id: binary_sensor.door_window_sensor_158d0003fa5728
    for:
      seconds: 30
    state: 'on'
  action:
  - data:
      message: Motion detection!
    service: notify.telegram

Does binary_sensor.kapu_mozgas report on when the garage door:

  1. Just starts to open.
  2. When it finishes opening.

In other words, does it report it is open when it starts to move or when it finishes moving?

It is a xiaomi door sensor. So it report when it start to move.