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

Another update to the blueprint today, I made the illumination cutoff value optional. In some cases you might always want to turn on the entity, no matter the illuminance level.

1 Like

Ah, what I noticed is that when you don’t configure this number it doesn’t turn off. Is this as intended? Would suggest to either document that or fix it :).

Also is it only possible to have dropdowns for input fields?

Awesome work, all in all.

Yes having the entities turn off being optional is indeed like intended. I have now edited the docs to make this more clear.

The input fields should all be dropdowns. It’s working in the UI on my side, when I click on the Entity field:

Let me know if this is different for you.

Actually it is from my perspective better to have this as a inputfield. This is more self explaining then an input field.

Thanks for updating the documentation :).

I think I might have misunderstood you.

Do you mean that instead of a entity (like input_number.illumination_bedroom_low_cutoff) you want to enter a manual value (perhaps with a slider in the UI) for the illumination cutoff point, like 50 lx?

Yes, but that is actually a choice from your perspective with a helper :). So nevermind.

I just updated the blueprint again, since I noticed the entity turn off timer was not working as I wanted.

The automation mode was set to single (default). This mean that the ‘turn-off-timer’ could not restart if motion was again detected in the delay interval.

I now changed the mode to restart, and disabled the condition to check if the triggering entity’s state is on.

This way the entity stays on if motion is again detected before the wait timer is over :slight_smile:

My use case. I have a kitchen light sensor. I only want to turn on the kitchen lights when it gets dark, and if someone sits at the kitchen table. I find motion sensors incredibly unreliable.

But, honestly, I think just having the motion sensor be a requirement isn’t too bad. I can just add a motion sensor, and not actually use it. I’m more interested in the once a day portion and adding other triggers to the automation. I do see it is getting complex though, so no worries if you don’t want to implement it.

If someone sits at the kitchen table should be the trigger of the automation then.
What kind of sensor/entity do you have for this? If it is a binary sensor, you could easily remove the

device_class: motion

part from my blueprint and have it selectable in the blueprint.

Well that won’t work, because the motion sensor is the entity (input) that triggers the automation.

That could be handled by creating a new input_boolean or binary_sensor as a blocking entity.
You would have to create logic that sets the state to ‘off’ in the beginning of the day, and ‘on’ once this automation has triggered once. If you need help there let me know.

I have not found a nice solution for this yet… if anyone knows one please let me know.

It’s not a Blueprint but I have code that does what you are looking for as well as continuing the keep the light on during extended motion despite that fact that by that time the light level in the room has actually gone above the automation threshold (due to the light now being on).

In a week or so I’ll try to convert it to a Blueprint and post it on the forum in a new thread.

You triggered me there… indeed this blueprint did not handle that situation well.
I just modified it so the illuminance check is skipped if the target entity is already on.
This way when the motion sensor is triggered within the wait time, the wait time is always restarted, no matter the illuminance level.

1 Like

That’s the way :+1:


First of all, thank you for your hard work. I am very enthusiastic.

However, I have a few concerns:

For example, if motion is detected and no motion is detected until that predefined phase of time, the light will turn off.

However, I have noticed that if there is motion during this phase, the light is still turned off. Could you correct this?

Also, it would be desirable if the light is not switched off immediately after the predefined phase of time, but is first dimmed down to, for example, 50%.

Could also a mechanism be built in that if in the phase of triggering the automation, by pressing any switch to “turn on”, this automation is interrupted and set to zero until this switch is set to “turn off” again.

Hello and thank you for Blueprints.
I noticed that if you enter the room in the last phase when the light turns off, the sensor does not activate the light again.
I have to wait until the sensor status resets

The latest version of the blueprint was intended to fix this. Have you imported the latest version?

Unfortunately I cannot test or make changes the next few days due to being out of the house for Christmas.

I’ll pick it up after if there are changes required🙂

Thank you very much for the quick reply.

I will update the version now.

I wait anxiously for the further development and wish us all contemplative days.

I made a small change which seems to solve this:


  - wait_for_trigger:
      platform: state
      entity_id: !input motion_sensor
      from: "on"
      to: "off"
  - delay: 
      minutes: '{{ states[no_motion_wait].state | int }}'


  - wait_for_trigger:
      platform: state
      entity_id: !input motion_sensor
      from: "on"
      to: "off"
        minutes: '{{ states[no_motion_wait].state | int }}'

This is a very small change but I believe the difference is the for in the wait_for_trigger is handled differently then a delay when this script is restarted.

Hope you all have enjoyed your christmas!

I have just retested the blueprint, but I cannot reproduce the described errors of the light turning off after the automation has been retriggered. For me the automation restarts just fine with the lastest version of the blueprint (with the delay in it).

I am able to keep postponing the turning off of the entity by retriggering the motion sensor.
A possible reason for this not happening, is that some motion sensors stay in the ‘on’ state for a long time.
When you try to trigger it when it is still in the ‘on’ state, the automation will not restart and the light will turn off at the originally determined time.

You can only restart the automation by triggering the motion sensor so it’s state goes from ‘off’ to ‘on’. Then again the light should only turn of after a delay that is set when the motion sensor turns to the ‘off’ state again. I have tested retriggering the automation 3-4 times and every time it turns off at exactly x minutes after the motion sensor was last marked as ‘off’.

So in short, the blueprint works exactly as intended for me.
But if you still have problems with the latest version do let me know :slight_smile:

I will test it now. Thanks.

I have one more request:

Can be set so that after some time the lights are dimmed for a predefined time until they are then switched off completely.

However, it should be possible during this dimming phase that the lights are dimmed up again when movement is detected.

1 Like

Also a suggestion:

For example, if the automation is triggered and the blocker entity is pressed in the middle of this phase, the automation will still completed. It would be nicer if the automation would actually reset to zero.

Similar like this: Motion-activated lights with switch override in just eight Node-RED nodes | BonaniTech