Turn on light, switch, scene, script or group based on motion, illuminance, sun (+ more conditions)

I just imported the blueprint. But I have the problem that the light is switched off after the defined time, even if movement has been detected again in the meantime.

I have tried to get this to work using a Unifi G3 Camera that has a binary motion sensor built-in and a Hue Lamp but can not get it to work. I have tried debugging and simplifying it down to the essential lines only and still it wont work so I need help.

The automation should be:
If light is turned on:

  • if there is no motion in the room for 30 seconds
  • turn off light

It seems however that the wait time completely skipped as the light is turned off by my automation instantly when it is turned on.

alias: Turn off kids Lights if no one is there
description: ""
trigger:
  - platform: device
    type: turned_on
    device_id: f7e3af9c3f74741698ab4741964a69b9
    entity_id: light.kids_room_light
    domain: light
    for:
      hours: 0
      minutes: 0
      seconds: 0
condition:
  - type: is_no_motion
    condition: device
    device_id: 035ae6c61d373957af64d25e96e88130
    entity_id: binary_sensor.kids_bedroom_camera_g3_motion
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 30
action:
  - type: turn_off
    device_id: f7e3af9c3f74741698ab4741964a69b9
    entity_id: light.kids_room_light
    domain: light
mode: single

What am I doing wrong?

Thanks. It works perfectly. :+1:

I saw this behavior as well, when using a scene as the target entity.
Are you using a scene as well ?
The issue is that we need to skip the illuminance check if the target entity is already on during the time that motion is detected for a second time within the wait period.
The detection hereof was not supported for scene’s or scripts.
I have now however added support for the detection of motion for a second time for scenes that control just 1 entity. Detection for scene’s that control multiple entities is not possible, and also not for scripts. So I guess this solved the issue for a limited set of usecases, but probably most of them.
It seems to work correctly now.
If you are also using a scene which controls a singular entity, could you retest with the latest version of the blueprint?
If it does not work yet, please post your automation YAML so I can see what’s going wrong.

Understandable question that I got more than once, so I added it to the FAQ.

1 Like

indeed it is exactly so. I have created 2 daytime scenes that control 3 lights (entities). Also, of course, a scene to turn off the lights.

Is there another way to control 3 lamps with the blueprint with different light levels throughout the day?

an- und ausschalten einer Gruppe reicht ja nicht, da man nicht die Helligkeit mitgeben kann.

wrong thread, sorry :worried:

no more ideas?

Hello i have several automátions working Perfectly with this blueprint but The Ones that have scenes/scripts are not turning OFF. I have the Turn off entity actívated.

This is how it looks on Yaml is there something missing or wrong?

alias: Sensor Quincho
description: “”
use_blueprint:
path: freakshock88/motion_illuminance_activated_entity.yaml
input:
motion_sensor: binary_sensor.sensor_quincho_motion
target_entity: scene.quincho_mix_on
target_off_entity: script.quincho_mix_off
no_motion_wait: input_number.tiempo_espera

The target_off_entity cannot be a script, since a script cannot be turned off. It has to be something like a light, switch or group of these.

Can it be a scene?!

1 Like

I created a group but it doesn’t turn off

alias: Sensor Quincho
description: “”
use_blueprint:
path: freakshock88/motion_illuminance_activated_entity.yaml
input:
motion_sensor: binary_sensor.sensor_quincho_motion
target_entity: script.quincho_mix_on
no_motion_wait: input_number.tiempo_espera
target_off_entity: switch.quincho_mix_test

1 Like

I use HiLook cameras for motion detection. They use pixel based motion detection. When someone walks into a room the camera detects motion and turns on the lights. Then I use a timer to turn the lights off when there is not motion detected. Problem is, the camera detects the light turning off as motion and turns the light back on. Any idea how to stop this?

Not sure what you mean, in your automation I see a switch as the turn-off-entity. Does that switch turn off after the wait time? That is what should happen.

Not sure if you are using the blueprint in this thread but… I guess by default this blueprint is not suited very well to your usecase by default.
But what you could try is to set a turn_off_blocker_entity. Create a template binary sensor of which the value is set to ‘on’ when you want to block turning off the target entity. Then set that sensor as the turn_off_blocker_entity.
I’m not sure you can find a template value that will work for all scenario’s though, but it might be worth to try.

Yes the light turns off after the 2 minutes of no motion. But the camera detects the light turning off as motion and turns the light back on.

Hello Community. I have a question: I use this Blueprint for lighting control all day. Once bright from 8-20 o’clock, then medium bright from 20-0 o’clock and then little bright from 0-8 o’clock (per room each three automations). The problem I have are the transition times. Since the (for example) daytime automation by the helper runs only AFTER 8 o’clock and BEFORE 8 o’clock and the evening automation starts after 8 o’clock, I had the case yesterday that at exactly 20:00:00 the automation was not triggered by movement. Therefore, I have now set the start of evening automation to 19:59. Now the lamps become bright in the transition time between 19:59 and 20:00 and then medium bright, because two automations are in play at the same time. Do you have an idea how I can solve this better?

Hi

in the column below
(OPTIONAL) Turn off wait time (minutes)

Time in minutes to leave the target entity on after last motion is detected. If not used entity will not auto turn off.

I am not able to set the time as there is no entity available? My light switching off after 5 seconds. How to set this correctly?
Thanks

1 Like

hi, how did you create wait_time_off entity?

you create an input number helper entity. It is described in the start topic:

Defining optional entities in the UI

If you want to create the optional entities in the UI instead of in YAML, you can do so in the following way:

  • To to Configuration
  • Go to Helpers
  • Click the ‘Add helper’ button
  • Select the entity type (in this case, number, toggle or date/time)
  • Enter required fields
  • Click on create