Delay before automation starts again?

Hello from Paris,

Newbie here is pretty happy of all he did with HA in one year, almost everything works great now
I do have a simple issue since the beginning with my automations.

i have in bathroom, hallway and kitchen an automation that detects someone and lights on for 5 min. The problem is sometimes you want to trigger it again on purpose, but you do need to wait because it doesn’t work for a long minute or so. And I don’t get why.

My rpi is connect to the 2 Philips Hue hub that control the zigbee devices : in wall switches, bulbs and hue motion detectors.

I’d like that after an automation ends (light is off after 5 min), any movement can trigger the automation again (instead of waiting a minute or so).

Thanks a lot!

alias: Détection Salle Eau
description: « »
trigger:

* type: motion
platform: device
device_id: 1fd4061cc29f2debd5be3b1994
entity_id: binary_sensor.hue_motion_sensor_salle_deau_motion
domain: binary_sensor
condition:
* condition: and
conditions:
  * condition: device
type: is_off
device_id: 530a395cc326023e812c407d972
entity_id: light.salle_deau
domain: light
  * condition: sun
before: sunrise
after: sunset
action:
* service: scene.turn_on
target:
entity_id: scene.salle_deau_starlight
metadata: {}
* delay:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
* type: turn_off
device_id: 530a395cc326023e812c407d972
entity_id: light.salle_deau
domain: light
mode: single

Most motion sensors have a “cooldown” period during which they are unresponsive. Combine that with an extended delay as you have, and you will occasionally have periods where the light turns off but the sensor is unresponsive. In some cases you can prevent this happening by simply changing the mode of the automation to restart instead of single. However, you will probably have a better experience if you use separate triggers for turning the light on and off:

alias: Détection Salle Eau
description: ""
trigger:
  - platform: state
    entity_id: binary_sensor.hue_motion_sensor_salle_deau_motion
    to:  'on'
    id: Motion
  - platform: state
    entity_id: binary_sensor.hue_motion_sensor_salle_deau_motion
    to:  'off'
    id: Clear
    for: "00:05:00"
condition:
  - condition: sun
    before: sunrise
    after: sunset
action:
  - choose:
      - conditions:
          - condition: trigger
            id: Motion
        sequence:
          - service: scene.turn_on
            target:
            entity_id: scene.salle_deau_starlight
      - conditions:
          - condition: trigger
            id: Clear
        sequence:
          - service: light.turn_off
            entity_id: light.salle_deau
mode: restart
1 Like

Wow!! Thank you so much!
I need to try this asap!

Hi @expresscisco, welcome to the forum!

Please consider formatting your code properly.

Hello Nick,

Sorry for this.

E.

1 Like

Hello,

I tried to adapt your recommendation and it seems to work thank you so much but there’s a but : I need, before the automation goes on, to check if the light is already on.

This is why : I have hue wall switches anywhere.

For example : If I switch on the light of the bathroom because I want to shave, I’ll have full lights for all the time I need so I don’t want the automation to trigger.

This automation is just supposed to work at night when I go to the bathroom a couple of minutes, quietly with low lights, which will go off automatically.

In the yaml below I have set the condition that the light must be off but in facts it prevents the automation to shut down the light after the initial 5 minutes.

For the moment i disabled this condition. Also all my Hue devices must remain handled by the Hue Hub.

Any idea?

Thanks a lot

E.


alias: Détection Salle Eau Bis
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.hue_motion_sensor_salle_deau_motion
    to: "on"
    id: Motion
  - platform: state
    entity_id:
      - binary_sensor.hue_motion_sensor_salle_deau_motion
    id: Clear
    for:
      hours: 0
      minutes: 5
      seconds: 0
    to: "off"
condition:
  - condition: and
    conditions:
      - condition: device
        type: is_off
        device_id: 7b72bfee749b1c1966d696571
        entity_id: dc9e4d7ef9811cf96f4da71f4
        domain: light
        enabled: false
      - condition: sun
        before: sunrise
        after: sunset
action:
  - choose:
      - conditions:
          - condition: trigger
            id: Motion
        sequence:
          - service: scene.turn_on
            target:
              entity_id: scene.salle_deau_starlight
            metadata: {}
      - conditions:
          - condition: trigger
            id: Clear
        sequence:
          - service: light.turn_off
            entity_id: light.salle_deau
mode: restart

You just need to rearrange your condition so that it only applies to the “on” action sequence.

alias: Détection Salle Eau Bis
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.hue_motion_sensor_salle_deau_motion
    to: "on"
    id: Motion
  - platform: state
    entity_id:
      - binary_sensor.hue_motion_sensor_salle_deau_motion
    id: Clear
    for:
      hours: 0
      minutes: 5
      seconds: 0
    to: "off"
condition:
    - condition: sun
      before: sunrise 
      after: sunset
action:
  - choose:
      - conditions:
          - condition: trigger
            id: Motion
          - condition: state
            state: 'off'
            entity_id: light.salle_deau
        sequence:
          - service: scene.turn_on
            target:
              entity_id: scene.salle_deau_starlight
            metadata: {}
      - conditions:
          - condition: trigger
            id: Clear
        sequence:
          - service: light.turn_off
            entity_id: light.salle_deau
mode: restart

I love that !
Thank you so much, will test this tonight ! (it’s now 10:30 am in Paris, France)

Hello,

Problem solved. Thank you so much!
I made some adaptations and everything works as expected.

Bye!

Good that your issue is solved!

Please take the time to mark the answer as solution, you do that by selecting the three dots under the post:

image

Then select the check box:

image

This can be useful to other users as well and prevents that someone else steps in to try to help you.