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

I’m not sure how the state of the philips hue motion sensor looks, but if it is an entity which has state ‘on’ when motion is detected, and ‘off’ when it is not anymore detected, it should be compatible with this blueprint.

I am having an issue. I am new to blueprints and scripts in general. I have a zooz zse11. I have the blue print setup and picked the home security motion sensor on the zse11 in drop down. Have to right entity. So my situation is this.
When motion is detected, the smart plug (controlling a lamp) turns on perfect. I have the setting (optional turn off wait time (minutes) set to 10 minutes. I have tried any time from 1 minute and up.

The light DOES turn on. But turns off after what seems like a minute no matter what I set the time too.

How do I get it to turn on the light… and if no motion for X minutes and NOT retriggered, then turn off light?

Thanks for a great blueprint.

I am having a problem with the “Turn off wait time (minutes)” option. I cannot get a delay after the motion sensor clears. I have tried integers between 1 and 10 but the target entity (not a script or scene) turns off as soon as the motion sensor clears.

Below is a trace of the wait step after execution, As you can see, “Delay:” is given as 0. So it seems the integer I entered for turn off wait time does not seem to make into the script during execution.

Executed: January 27, 2022, 4:00:49 PM
Result:
delay: 0 done: true

An ideas regarding what I need to do to get a turn ff wait time delay?

Regards

Looks like I have the same problem as you. Just saw your post.

Here is what you do … it was in the instructions. A little convoluted but it works. Basically create a helper and set the desired minutes to wait there. Then instead of directly entering the number of minutes in the blueprint like you have done in your screenshot, just press the drop down arrow to the right and select the helper you created for the minutes. Below are the actual instructions.

"If you want to create the optional entities in the UI instead of in YAML, you van 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

Setting the values for the helper entities

To set a value for your newly created helper, find it in the helper list as described in the section above, press the settings icon on the top right of the screen and set the value there. "

Is somebody using this blueprint together with a Hue Motion Sensor AND with an illuminance cutoff?

Maybe the problem even exist for other motion sensors, but it can happen that when the motion is detected (change state from ‘clear’ to ‘detected’), the illuminance value is still “old” (e.g. it is high because the light was on a few seconds ago). Then, one second later the illuminance gets updated but the automation is not triggered again, because it only reacts on the motion state change but not on illuminance change. In my opinion it is needed to also listen to an illuminance change AND if then the motion is in state ‘detected’, it should be treated as if motion was detected.

I already explained it a few years ago in that thread: Hue Motion sensor with illuminance condition

I am trying to use this blueprint and light triggering with PIR works fine, but I am not sure if I understand the Illuminance cutoff value right.

I defined an input_number in my configuration which gives a value between min and max but it always defaults to min when checking in the entitiy browser.

My current illuminance is around 250lx and even when I set the min to above 300, the light still triggers. Anyone can help me understand Illuminance cutoff value?

The Illuminance cutoff value is used to determine if it is dark enough for the light to need to be turned on. So if you set this at 250lx, when the motion sensor is triggered and the actual illuminance value is below that, the light will turn on. If it is above 250lx, the light will not turn on.

Yes I use it with the Hue Sensor and an illuminance cut off of 20 lux.

I find that when my chosen light goes off, i can’t get it to come back on straight away. I’ve gone as far as walking right up to the sensor and stll nothing. If I look at the Hue reported lux in HASS it does indeed seem to be still reporting the value that it was when the light was on, usually 40 lux in my house. Only when that drops back to the actual room lux value will the light turn back on, this can be over a minute.

I’ve been tearing my hair out with this for weeks.

I presume the automation logs would “show me” frantically waving my hands around to get the light to come back on with the logic then looking at illuminance and passing on running.

@Mogodon you have to go to Device info-Manage clusters-OccupancyCluster. Than in cluster attributes select

pir_o_to_u_delay

and select get zigbee attribute. In case there is number, not 0 you found a problem. Input 0 and press set zigbee attribute. I had the same problem, now it is working. Check and let me know.

1 Like

I’m undoubtedly being blind but where am I looking for manage clusters on the device info page?

hue-motion-device

Which integration do you use?

This one.

It would really good if it was possible to use Sunset or Sunrise in the start or finish times.
Otherwise an excellent Blueprint

Thank you

what i did was simple,
I wanted all lights that use this Automation to be identical, so i change the hard code of it

action:

  • service: homeassistant.turn_on
    entity_id: !input ‘target_entity’
    data:
    brightness: 255
    color_temp: 250

I have a couple questions:

  1. When I import the blueprint I get a different version than the code that is listed in the first post of this thread. It appears that the imported version is an older version. Correct?

  2. I am trying to resolve an issue that was reportedly corrected. I have a delay time set for 1 minute. After the motion sensor resets back to off, if I trip the motion sensor again the automation is NOT restarted. and the light turns off after the 1 minute delay. But the release notes say this was fixed.

I am currently using the version of the blueprint that I copied and pasted from the top of this thread. The blueprint includes the following lines:

condition:
# First condition: When entity was already on because the automation ran recently, do not check illuminance because it could have increased above threshold because of a light that was just turned on.
  - condition: template
    value_template: "{{ (states[target_entity].state == 'on') or (illuminance_currently == none) or (illuminance_cutoff == none) or (states[illuminance_currently].state | int(0) < states[illuminance_cutoff].state | int(0)) }}"
  - condition: template
    value_template: "{{ (blocker_entity == none) or (states[blocker_entity].state == 'off') }}"

The comment suggests that I do have the most recent version. Can anyone shed some light on how the “restart” is supposed to work? When the motion sensor is tripped again during the delay period, the automation is not restarted because it fails a condition test.

Note: I found the problem. The restart of the script does not seem to work when the target is a scene. I switched back to a light entity and it now works correctly.

I am trying to make some personal modifications to this blueprint and would appreciate any help with the correct syntax for the following condition statement which tests the current state and the current brightness of the target_entity:

  - condition: template
    value_template: "{{ (states[target_entity].state == 'off') or (state_attr[target_entity, 'brightness'] < 100) }}"

I have tried every format I can think of, but cannot get the syntax correct for the 2nd part of the condition which is trying to test the current brightness level of the target_entity.

Hi @Sentinel21 Thanks for posting the image of your solution - I’m trying to achieve something similar with a Hue Tap switch. I’m a real newbie to HomeAssistant and am capable of copy/paste but not much else at the moment :confused:

I currently have the switches integrated via eventsensor which turns button presses into events. Can you point me in the right direction for adapting your solution to turn them into an on/off stage please?

Great Blueprint!! Easy to set up and works great!! Thanks!!