Adding delay to sensor How can I do this

Hello, I want the motion sensor to wait for 15 seconds before triggering in this scenario. I added a delay to the switch section, but it didn’t suit my needs.

The scenario here is to turn on the heater when motion is detected. However, I don’t want it to activate when there is a slight movement. For instance, I don’t want it to trigger when the door is opened and closed; I only want it to activate when someone is inside. In short, I need to add a 15-second delay to the motion sensor’s detection.

How can I do this?

alias: Yeni Otomasyon test
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.hareket_sensoru_hareket
condition:
  - type: is_temperature
    condition: device
    device_id: 3b50ea4a6e571a9a264e03c343e4db25
    entity_id: 1e3e0566293975824710a4b22a650279
    domain: sensor
    below: 20
action:
  - delay: "00:00:15"
  - type: turn_on
    device_id: e87fba56c2b9c7f5c692335c96ca89e2
    entity_id: 06bb91916e96d1ee45a233c287d22160
    domain: switch
mode: single

You’ll need to see how your motion sensor works in terms of the time it stays on after detecting movement.

If it only stays on for a short time, you should look at using wait_for_trigger in combination with continue_on_timeout: false to wait for a second motion detection.

If it stays on whilst motion is being detected, you could use a for: statement in the trigger:

trigger:
  - platform: state
    entity_id: binary_sensor.hareket_sensoru_hareket
    to: 'on'
    for: '00:00:15'

I understand; I will try this, and I believe it will work. I actually have one more issue. Currently, the heater turns off when the ambient temperature goes above 20 degrees and turns on automatically when it drops below 20 degrees. However, there is a problem here. If there is constant movement in the environment, it goes above 20 degrees, the system turns off, but when it drops below 20 degrees again, it does not turn on. So what is measured is that you will remain motionless, it will discharge from the sensor, it will fall, then you will move, then it triggers.The sensor does not trigger because it constantly detects movement. In other words, I need a command like ‘Run as long as there is movement in the environment’

So this is a heater control and you want:

  • Turn on if below 20°C and motion
  • Turn off if above 20°C

Correct? If so, try this (using state triggers instead of devices):

trigger:
  - platform: state
    entity_id: binary_sensor.hareket_sensoru_hareket
    to: 'on'
    for: '00:00:15'
    id: 'on'
  - platform: numeric_state
    entity_id: sensor.YOUR_TEMP_SENSOR
    below: 20
    id: 'on'
  - platform: numeric_state
    entity_id: sensor.YOUR_TEMP_SENSOR
    above: 20
    id: 'off'
condition:
  - or:
    - and:
      - condition: state
        entity_id: binary_sensor.hareket_sensoru_hareket
        state: 'on'
      - condition: numeric_state
        entity_id: sensor.YOUR_TEMP_SENSOR
        below: 20
    - condition: numeric_state
      entity_id: sensor.YOUR_TEMP_SENSOR
      above: 20
action:
  - service: switch.turn_{{ trigger.id }}
    entity_id: switch.YOUR_HEATER_SWITCH

Triggers when any of these happens:

  • there has been movement for 15 seconds;
  • the temperature drops below 20°C;
  • the temperature rises above 20°C.

Continues to the action only if:

  • it’s cold and there is motion;
  • it’s hot.

And the action switches the heater on or off appropriately.

Obviously, this depends on exactly how your motion sensor behaves, but it should give you some ideas.