💡 Sensor Light - Motion Sensor - Door Sensor - Sun Elevation - LUX Value - Scenes - Time - Light Control - Device Tracker - Night Lights

@Tropaion

Nice one glad you got it working.

Enjoy

Blacky :grinning:

1 Like

Thanks Blacky, you’re the best! I’ll investigate further.

1 Like

When I upgrade zigbee2mqtt from 1.42.0-2 to latest version 2.1.3-1, the blueprint stops working. In zigbee2mqtt I can see the motion sensors correctly detection motion but the blueprint doesn’t seem to detect it, the blueprint is not triggered. I did check if the entity for the binary sensor was still correct in the blueprint, it’s still there. Idea’s anyone?

@linuxfreak

There were issues with zigbee in their update. This post back earlier seem to help some people and you can search on the forum for more information on what happened when zigbee updated their version.

Blacky :grinning:

I’m trying to configure the following behavior:

  • A motion sensor activates a lamp, for some on-time. Repeated triggers will keep the light on.
  • The motion sensor only activates the sensor during night
  • A switch can be used to manually switch the lamp on (for some maximum time) and off again
    • Manual operation should always work (day and night)
    • When manually switching the lights off, the motion trigger behavior shall be enabled again automatically.
    • When a motion trigger has activated the lamp, the manual switch can be used to turn it off, even if the on-time hasn’t elapsed yet.

Not sure if it’s relevant, but I’m using an Ikea Rodret switch for manual operation, where the on/off presses are turned into a single switch helper by IKEA RODRET + SOMRIG + TRADFRI Remotes - ZHA/Z2M - Control anything.

I’m struggiling to configure the sensor light blueprint for the bypass behavior:

  • If I enable “1 - Enable the Bypass - Turn lights ON” and select the switch helper, then manual operation works but I’m not able to switch the lamp off when it was activated by motion
  • If I enable both 1 and “2 - Enable the Bypass - Turn lights OFF” and select the switch helper for both 1 & 2 (is this even allowed?), then manual operation works and I’m able to switch the lamp off, but I first have to turn it on again manually even when it was already activated by motion → bad WAF…

@Blacky I’m sure this must be possible with your awesome blueprint somehow, but I just don’t get it…

@Yveaux

You’re asking the Ikea Rodret switch to perform two different actions based on your preferences. :thinking:

Solution: Use Two Helpers

To achieve this, create two toggle helpers:

  1. Helper 1 – Turns the light ON (bypass 1).
  2. Helper 2 – Turns the light OFF (bypass 2).

Setting Up the Blueprint

  • Enable the time condition (e.g., 10 PM to 7 AM).
  • Use normal lighting (not night light) to turn your light ON during those hours and adjust your light control options.
  • This will handle your motion-based triggers.
  • Assign Helper 1 for turning the light ON and Helper 2 for turning the light OFF.

Decide How You Want It to Work

When you turn ON the Ikea Rodret switch, what should happen?

  • Should the light turn OFF when motion triggers it between 10 PM and 7 AM?
  • Or should it turn OFF if the light is already ON?

Make a Custom Automation for Ikea Rodret Switch

When the Ikea Rodret switch is turned ON:

  1. Option 1 (Time-Based OFF):
  • If it’s between 10 PM and 7 AM, turn ON Helper 2 (turning the light OFF).
  • Otherwise, turn ON Helper 1 (turning the light ON).
  1. Option 2 (State-Based OFF):
  • If the light is already ON, turn ON Helper 2 (turning the light OFF).
  • Otherwise, turn ON Helper 1 (turning the light ON).

Example of custom automation. You will need to delete one option and keep the other one. Also update the entity id’s

description: ""
mode: single
triggers:
  - trigger: state
    entity_id:
      - switch.ikea_rodret_switch
    to: "on"
    id: switch_on
  - trigger: state
    entity_id:
      - switch.ikea_rodret_switch
    to: "off"
    id: switch_off
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - switch_on
          - condition: time
            after: "22:00:00"
            before: "07:00:00"
        sequence:
          - target:
              entity_id: input_boolean.helper_2
            action: input_boolean.turn_on
            data: {}
        alias: Option 1 (Time-Based OFF)
      - conditions:
          - condition: trigger
            id:
              - switch_on
          - condition: state
            entity_id: light.your_light
            state: "on"
            alias: Your Light is ON
        sequence:
          - target:
              entity_id: input_boolean.helper_2
            action: input_boolean.turn_on
            data: {}
        alias: "Option 2 (State-Based OFF):"
      - conditions:
          - condition: trigger
            id:
              - switch_off
        sequence:
          - action: input_boolean.turn_off
            metadata: {}
            data: {}
            target:
              entity_id:
                - input_boolean.helper_2
                - input_boolean.helper_1
    default:
      - action: input_boolean.turn_on
        metadata: {}
        data: {}
        target:
          entity_id: input_boolean.helper_1

Auto-OFF Handling

  • If you need different auto-OFF times for Helper 1 and Helper 2, you can:
    • Add a wait action before turning OFF Helper 2 after a set time.
    • Use the blueprint’s auto-OFF feature for Helper 1.
  • If the same auto-OFF time works for both helpers, just use the blueprint’s auto-OFF for both Helper 1 and Helper 2.

Hope this helps you

Blacky :grinning:

Thanks for the insanely fast and extensive response!

I’m basically looking for manual control of the lamp, but when it’s off the motion trigger should take over. So when manually switched on the motion/night triggers shall be ignored. When off, a motion trigger will turn on the lamp and after a some time it will turn off again. If during this on time somebody manually tries to switch the lamp off it should turn off and manually switching on can be ignored.

If it’s not clear I may need to draw a timeline or something (on mobile now…)

Overall I’m trying to mimic a regular light switch, that behaves ‘smart’ when off. IMO this is the easiest to adopt for non techies :wink:

Maybe, now I think of it, it’s just a matter of switching the lamp on and automation off, when Rodret on it pressed, and switching the lamp of and automation on again, when Rodret off is pressed.
I’ll give this a try an report back.

Edit: This is indeed working! I created and automation, triggered by the Rodret switch on-action, that switches the lamp on and at the same time disables the Sensor Light automation. The off-action does the opposite.

Thanks again for your help @Blacky!

1 Like

You are 100% correct! After updating zigbee2mqtt the illuminance sensor on the is disabled :frowning: If your automation cannot read lux value, wouldn’t it be better to always fire the lights when motion is detected?

D’oh, you’re right! I thought it wouldn’t work because HA form validation was red:
image

1 Like

Oooh that easy?
Awesome! Cheers!

1 Like

@Blacky thanks for your response.

I understand what you wrote, that it works off triggers. It would be nice though if it had an option to keep a scene alive if one of the lights went off.

Also, please take a look at this post, if you feel like chiming in: 💡 Sensor Light - Motion Sensor - Door Sensor - Sun Elevation - LUX Value - Scenes - Time - Light Control - Device Tracker - Night Lights - #3253 by gd510

Hi @Blacky ,

thanks for the great blueprint.

We have a manual switch in the living room which basically powers off the light and if you turn the switch on, the light will immediately go on as well. However, I noticed that the light never turns off again by the automation although there was motion in the meantime and I would expect that the automation takes care to turn it of after some time.
I’m using version 8.0 of the automation with a script to turn the light on and off and also a toggle helper. Could the toggle helper be the reason that the light state becomes somehow inconsistent?

@Yveaux

Your welcome, glad you up and running.

Blacky :grinning:

@linuxfreak

This way you will know when it is not working and you can fix it.

Blacky :grinning:

@gd510

Scenes have no state they just get executed when the action is called. You can try removing the Scenes & Scripts - Toggle Helper this way when it is triggered again it will call the scene. It may help you.

So you would like dynamic lighting when motion is detected and then once motion is clear to then go to 50% for 10 min and then to 10% 24/7.

  1. Set up your lights as entities and set up dynamic lighting.
  2. Set up a script to turn OFF and add it into Scenes - Scripts To Turn OFF. This script should go to 50% wait 10 min and then 10% as your requested (You may see a light flicker). Make sure the script has the same trigger as the blueprint (motion sensor) that will stop the script.
  3. Option use a scene in lights as well as entities to set the default starting point when motion is detected and then dynamic lighting will take over. Make sure you add the helper in Scenes & Scripts - Toggle Helper.

Hope this helps you.

Blacky :grinning:

@ZzetT

When you manually turn ON the light, and then the automation runs, it should trigger your script, turn ON the helper, and then turn OFF the light. The toggle helper prevents the script or scene from being called every time the automation triggers once the light (or toggle helper) is ON. It allows you to adjust the lights without repeatedly triggering them to turn ON, saving network traffic and preventing unnecessary interactions with the light. Regardless of the light’s state or whether the helper is ON, the automation should turn both the light and helper OFF.

The only thing that will prevent this from working is a global condition or the bypass.

Please double check that the motion sensor is indeed triggering the automation (you can run a test to confirm):

  1. Turn the light ON.
  2. Trigger the motion sensor and ensure you see the action happening in Home Assistant.
  3. After the motion sensor clears, the light should turn OFF after the time delay.

If you’re still experiencing issues, feel free to share your YAML settings, and I can help you troubleshoot.

To do this:

  1. Open your automation.
  2. Click the three dots (⋮) in the top right corner.
  3. Select Edit in YAML.
  4. Copy the entire YAML code.
  5. Return to the forum and, in your reply, click the </> button in the toolbar.
  6. Paste your YAML inside the code block.

This ensures the formatting stays correct and makes it easier to analyze.

Blacky :grinning:

@Blacky

I changed the automation the lux value is 16 but the light go on :smirk:

alias: Sensor Light
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.everything_presence_one_0436d4_pir
    light_switch:
      entity_id: light.hue_ambiance_lamp_1_2
    light_brightness: 55
    include_light_control:
      - use_brightness
    include_time: time_enabled
    before_time: "23:30:00"
    after_time: "16:00:00"
    include_dynamic_lighting: disable_dynamic_lighting
    include_ambient: ambient_enabled
    ambient_light_sensor: sensor.everything_presence_one_0436d4_illuminance
    ambient_light_value: 10
    ambient_light_high_value: 10
    light_colour_temperature: 4000
    ambient_light_options: ambient_light_option_enabled

@pele

In ambient you selected YES - My Ambient Light Sensor is affected by the Lights so once the light is ON it will ignore your lux sensor. If you would like it to turn OFF based on your lux sensor consider raising the Ambient Light - High Lux Value so when your light turns ON it will not go above this value (unless natural light raises it above) and then selecting NO - My Ambient Light Sensor is not affected by the Lights.

Blacky :grinning:

Hi, I like your blueprint very much. But I have a few questions.
We are using the blueprint with the sun elevation-option.

  • Is it possible to execute the night-light function even the elevation-option doesn’t fit? In our case the light of the nursery room is activated with a warm white at the normal time, but is red as a night light so the baby doesn’t get flashed in the night. But this doesn’t work if the sun is to high, but the shutters are still closed. If the night-light enity is activated it should work always.

  • How can I set up the blueprint if I want to activate the light depending on sun elevation or the lux? I recognized that the light in the hallway and other rooms should be turned on on a cloudy day when the sun is still high but it is very cloudy and so it is not bright enough in the hallway.

Sry for my english, if it is not understandable.