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

sorry for the huge unload but hope that helps pinpoint the issue

Hey you can actually format your long yaml dump into a code block.
See this link for more information on how to do that.

Also, if it’s so long, you might wanna wrap it in a “Hide Details” block after making it a code block.
You can find this option in the editor → :gear: → Hide Details.
That will allow your extremely long yaml dump to be collapsed. :+1:t2:

This is how you can do it:

[details=“Example”]
```yaml
Your Code Here
```
[/details]

This is how it will look like.
myVeryLongCode:
  - it is very long
  - scrollfest
1 Like

@midnightsnacker41

Welcome to the community :+1:

I agree, a few people have asked the same question. We will add another FAQ so others with the same problem can get started ASAP. Thanks for your suggestion :wink:

Blacky :smiley:

@triplezeros

Thanks for the info, could you advise what you are using to control your lights example:Zigbee2MQTT, wifi, shelly, zigbee, etc. I am running through testing of the next release so I will have a look at it.

Thanks for the feedback :+1:

Sorry my fault, a trace line looks like this. See the red arrow, this is were I think your problem is.

if you track you orange line to the point where it stops then click on it and provide a close up screen shot of that point so I can see what is happening.

FAQ - My Trigger Is Not Triggering The Automation

This is normally caused by selecting Areas and or Devices in " Lights - Switches – Scenes". The blueprint only supports entities not Areas an or Devices. You will need click the expand button “<>” as shown below. This will expand out your area or device down to entities. You selection should be all green and only have entities. This also apply to “Night Lights”. Once you have done this you will probably find that you trigger now triggers the automation and it works.

Areas :x:

Devices :x:

Entities :white_check_mark: :+1:

Enjoy

Blacky :smiley:

Back to FAQ: Click Here

1 Like

@Blacky , i am using zigbee2mqtt (smartthings motion), zwave (aeotec multi 7) and binary (envisalink), lights are TPLink Kasa wifi.
tried with only 1 motion, 2 motions (not grouped) in automations, same results. another interesting thing is i dont have the dimmer value set so I expect the automation to just turn on at existing dimmer brightness, however the first couple times, the brightness is at 1%, havent narrowed down this issue yet. example, leave to work in morning, 1st motion is at 1%, i go to work and snoop on my dog, when dog walks around I see the lights are at the original motion of 40%. hope that makes sense.

Sort of a simple foolish question, I’m not quite understanding the bypass.

I’m using a smart ZHA switch (Real physical wired switch in a box) to turn on the dumb lights and keep them on so long as one of my two motion sensors in the group detect movement, and turn off 5 minutes after.

But when family visits, I have a Murphy bed in the office, and we use the room as a bedroom. So other than disabling the automation, which is a simple enough solution, is there another way I can stop the lights from turning on once turned off with the switch?

Thank you

choose:
  - alias: Check if the night lights are enabled and within the time
    conditions:
      - condition: time
        after: '22:30:00'
        before: '08:00:00'
      - '{{ include_night_lights == ''night_lights_enabled'' }}'
    sequence:
      - choose:
          - alias: By-pass is turned on  & check by-pass option - turn lights off
            conditions:
              - condition: trigger
                id: t6
              - condition: template
                value_template: '{{ include_bypass == ''bypass_enabled'' }}'
            sequence:
              - alias: Wait the number of minutes set in the by-pass time delay
                delay:
                  minutes: 0
              - alias: Turn off the lights
                service: light.turn_off
                target:
                  entity_id: '{{ night_light_entities }}'
                data:
                  transition: '{{ night_transition_off_value }}'
              - alias: Turn off the switches
                service: switch.turn_off
                target:
                  entity_id: '{{ night_switch_entities }}'
              - alias: Turn off the scenes
                service: scene.turn_on
                entity_id: []
                data:
                  transition: '{{ night_transition_off_value }}'
              - stop: Stop the automation
          - alias: By-pass is turned on  & check by-pass option - leave lights on
            conditions:
              - condition: trigger
                id: t6
              - condition: template
                value_template: '{{ include_bypass == ''bypass_enabled_stop'' }}'
            sequence:
              - stop: Stop the automation
          - alias: By-pass is turned off  & check if the motion trigger is off
            conditions:
              - condition: trigger
                id: t7
              - condition: state
                entity_id:
                  - binary_sensor.dinning_room_sensor_occupancy
                match: all
                state: 'off'
            sequence:
              - alias: Wait the number of minutes set in the by-pass time delay
                delay:
                  minutes: 0
              - alias: Turn off the lights
                service: light.turn_off
                target:
                  entity_id: '{{ night_light_entities }}'
                data:
                  transition: '{{ night_transition_off_value }}'
              - alias: Turn off the switches
                service: switch.turn_off
                target:
                  entity_id: '{{ night_switch_entities }}'
              - alias: Turn off the scenes
                service: scene.turn_on
                entity_id: []
                data:
                  transition: '{{ night_transition_off_value }}'
              - stop: Stop the automation
          - alias: Reset the lights when trigger by night start time
            conditions:
              - condition: trigger
                id: t5
            sequence:
              - alias: Turn off the lights
                service: light.turn_off
                target:
                  entity_id: '{{ crossover_lights_light }}'
                data:
                  transition: '{{ transition_off_value }}'
              - alias: Turn off the switches
                service: switch.turn_off
                target:
                  entity_id: '{{ crossover_lights_switch }}'
              - alias: Turn off the scenes
                service: scene.turn_on
                entity_id: []
                data:
                  transition: '{{ transition_off_value }}'
          - alias: Sun, Ambient Light Sensor & time above setting to turn off
            conditions:
              - condition: trigger
                id:
                  - t8
                  - t9
                  - t10
            sequence:
              - alias: Wait the number of minutes set in the by-pass time delay
                delay:
                  minutes: 0
              - alias: Turn off the lights
                service: light.turn_off
                target:
                  entity_id: '{{ night_light_entities }}'
                data:
                  transition: '{{ night_transition_off_value }}'
              - alias: Turn off the switches
                service: switch.turn_off
                target:
                  entity_id: '{{ night_switch_entities }}'
              - alias: Turn off the scenes
                service: scene.turn_on
                entity_id: []
                data:
                  transition: '{{ night_transition_off_value }}'
              - stop: Stop the automation
          - alias: Safe Guard when HA restarts
            conditions:
              - condition: trigger
                id: t12
            sequence:
              - alias: Check automation and preform the correct action
                if:
                  - alias: Check if the motion trigger is on
                    condition: state
                    entity_id:
                      - binary_sensor.dinning_room_sensor_occupancy
                    state: 'on'
                    match: any
                then:
                  - alias: We need something here for the IF to continue
                    delay:
                      seconds: 1
                else:
                  - alias: >-
                      Wait the number of minutes set in the night lights time
                      delay
                    delay:
                      minutes: 5
                  - alias: Turn off the lights
                    service: light.turn_off
                    target:
                      entity_id: '{{ night_light_entities }}'
                    data:
                      transition: '{{ night_transition_off_value }}'
                  - alias: Turn off the switches
                    service: switch.turn_off
                    target:
                      entity_id: '{{ night_switch_entities }}'
                  - alias: Turn off the scenes
                    service: scene.turn_on
                    entity_id: []
                    data:
                      transition: '{{ night_transition_off_value }}'
                  - stop: Stop the automation
      - choose:
          - alias: Set the brightness and transition for the night lights switch
            conditions:
              - condition: template
                value_template: >-
                  {{ ('use_brightness' in include_night_light_control) and not
                  ('use_colour_temperature' in include_night_light_control) }}
            sequence:
              - service: light.turn_on
                target:
                  entity_id: '{{ night_light_entities_off }}'
                data:
                  brightness_pct: '{{ night_brightness_value }}'
                  transition: '{{ night_transition_on_value }}'
      - choose:
          - alias: Set the brightness and transition for the night lights switch
            conditions:
              - condition: template
                value_template: >-
                  {{ ('use_brightness' in include_night_light_control) and
                  ('use_colour_temperature' in include_night_light_control) }}
            sequence:
              - service: light.turn_on
                target:
                  entity_id: '{{ night_light_entities_off }}'
                data:
                  brightness_pct: '{{ night_brightness_value }}'
                  kelvin: '{{night_temperature_value}}'
                  transition: '{{ night_transition_on_value }}'
      - choose:
          - alias: Set the brightness and transition for the night lights switch
            conditions:
              - condition: template
                value_template: >-
                  {{ ('use_colour_temperature' in include_night_light_control)
                  and not ('use_brightness' in include_night_light_control) }}
            sequence:
              - service: light.turn_on
                target:
                  entity_id: '{{ night_light_entities_off }}'
                data:
                  kelvin: '{{night_temperature_value}}'
                  transition: '{{ night_transition_on_value }}'
      - choose:
          - alias: Set the transition for the night lights switch - Default
            conditions:
              - condition: template
                value_template: >-
                  {{ ('use_brightness' not in include_night_light_control) and
                  ('use_colour_temperature' not in include_night_light_control)
                  }}
            sequence:
              - service: light.turn_on
                target:
                  entity_id: '{{ night_light_entities_off }}'
                data:
                  transition: '{{ night_transition_on_value }}'
      - alias: Turn on the switches
        service: switch.turn_on
        target:
          entity_id: '{{ night_switch_entities_off }}'
      - alias: Turn on the scenes
        service: scene.turn_on
        target:
          entity_id: '{{ night_scene_entities }}'
        data:
          transition: '{{ night_transition_on_value }}'
      - choose:
          - alias: By-pass is enabled & check by-pass option - turn lights on
            conditions:
              - condition: trigger
                id: t6
              - condition: template
                value_template: '{{ include_bypass == ''bypass_enabled_turn_on'' }}'
            sequence:
              - stop: Stop the automation
          - alias: Check if the trigger is on and wait for it to go off
            conditions:
              - condition: state
                entity_id:
                  - binary_sensor.dinning_room_sensor_occupancy
                state: 'on'
                match: any
            sequence:
              - alias: Wait until motion sensor is off
                wait_for_trigger:
                  platform: state
                  entity_id:
                    - binary_sensor.dinning_room_sensor_occupancy
                  from: 'on'
                  to: 'off'
      - alias: Wait the number of minutes set in the night lights time delay
        delay:
          minutes: 5
      - alias: Turn off the lights
        service: light.turn_off
        target:
          entity_id: '{{ night_light_entities }}'
        data:
          transition: '{{ night_transition_off_value }}'
      - alias: Turn off the switches
        service: switch.turn_off
        target:
          entity_id: '{{ night_switch_entities }}'
      - alias: Turn off the scenes
        service: scene.turn_on
        entity_id: []
        data:
          transition: '{{ night_transition_off_value }}'
default:
  - choose:
      - alias: By-pass is turned on  & check by-pass option - turn lights off
        conditions:
          - condition: trigger
            id: t6
          - condition: template
            value_template: '{{ include_bypass == ''bypass_enabled'' }}'
        sequence:
          - alias: Wait the number of minutes set in the by-pass time delay
            delay:
              minutes: 0
          - alias: Turn off the lights
            service: light.turn_off
            target:
              entity_id: '{{ light_entities }}'
            data:
              transition: '{{ transition_off_value }}'
          - alias: Turn off the switches
            service: switch.turn_off
            target:
              entity_id: '{{ switch_entities }}'
          - alias: Turn off the scenes
            service: scene.turn_on
            entity_id: []
            data:
              transition: '{{ transition_off_value }}'
          - stop: Stop the automation
      - alias: By-pass is turned on  & check by-pass option - leave lights on
        conditions:
          - condition: trigger
            id: t6
          - condition: template
            value_template: '{{ include_bypass == ''bypass_enabled_stop'' }}'
        sequence:
          - stop: Stop the automation
      - alias: By-pass is turned off  & check if the motion trigger is off
        conditions:
          - condition: trigger
            id: t7
          - condition: state
            entity_id:
              - binary_sensor.dinning_room_sensor_occupancy
            match: all
            state: 'off'
        sequence:
          - alias: Wait the number of minutes set in the by-pass time delay
            delay:
              minutes: 0
          - alias: Turn off the lights
            service: light.turn_off
            target:
              entity_id: '{{ light_entities }}'
            data:
              transition: '{{ transition_off_value }}'
          - alias: Turn off the switches
            service: switch.turn_off
            target:
              entity_id: '{{ switch_entities }}'
          - alias: Turn off the scenes
            service: scene.turn_on
            entity_id: []
            data:
              transition: '{{ transition_off_value }}'
          - stop: Stop the automation
      - alias: Sun, Ambient Light Sensor & time above setting to turn off
        conditions:
          - condition: trigger
            id:
              - t8
              - t9
              - t10
        sequence:
          - alias: Wait the number of minutes set in the normal lights time delay
            delay:
              minutes: 5
          - alias: Turn off the lights
            service: light.turn_off
            target:
              entity_id: '{{ light_entities }}'
            data:
              transition: '{{ transition_off_value }}'
          - alias: Turn off the switches
            service: switch.turn_off
            target:
              entity_id: '{{ switch_entities }}'
          - alias: Turn off the scenes
            service: scene.turn_on
            entity_id: []
            data:
              transition: '{{ transition_off_value }}'
          - stop: Stop the automation
      - alias: Reset lights when trigger by night end time
        conditions:
          - condition: trigger
            id: t11
          - '{{ include_night_lights == ''night_lights_enabled'' }}'
        sequence:
          - alias: Turn off the lights
            service: light.turn_off
            target:
              entity_id: '{{ crossover_night_lights_light }}'
            data:
              transition: '{{ night_transition_off_value }}'
          - alias: Turn off the switches
            service: switch.turn_off
            target:
              entity_id: '{{ crossover_night_lights_switch }}'
          - alias: Turn off the scenes
            service: scene.turn_on
            entity_id: []
            data:
              transition: '{{ night_transition_off_value }}'
      - alias: Safe Guard when HA restarts
        conditions:
          - condition: trigger
            id: t12
        sequence:
          - alias: Check automation and preform the correct action
            if:
              - alias: Check if the motion trigger is on
                condition: state
                entity_id:
                  - binary_sensor.dinning_room_sensor_occupancy
                state: 'on'
                match: any
            then:
              - alias: We need something here for the IF to continue
                delay:
                  seconds: 1
            else:
              - alias: Wait the number of minutes set in the normal lights time delay
                delay:
                  minutes: 5
              - alias: Turn off the lights
                service: light.turn_off
                target:
                  entity_id: '{{ light_entities }}'
                data:
                  transition: '{{ transition_off_value }}'
              - alias: Turn off the switches
                service: switch.turn_off
                target:
                  entity_id: '{{ switch_entities }}'
              - alias: Turn off the scenes
                service: scene.turn_on
                entity_id: []
                data:
                  transition: '{{ transition_off_value }}'
              - stop: Stop the automation
  - choose:
      - alias: Set the brightness and transition for the normal lights switch
        conditions:
          - condition: template
            value_template: >-
              {{ ('use_brightness' in include_light_control) and not
              ('use_colour_temperature' in include_light_control) }}
        sequence:
          - service: light.turn_on
            target:
              entity_id: '{{ light_entities_off }}'
            data:
              brightness_pct: '{{ brightness_value }}'
              transition: '{{ transition_on_value }}'
  - choose:
      - alias: Set the brightness and transition for the normal lights switch
        conditions:
          - condition: template
            value_template: >-
              {{ ('use_brightness' in include_light_control) and
              ('use_colour_temperature' in include_light_control) }}
        sequence:
          - service: light.turn_on
            target:
              entity_id: '{{ light_entities_off }}'
            data:
              brightness_pct: '{{ brightness_value }}'
              kelvin: '{{temperature_value}}'
              transition: '{{ transition_on_value }}'
  - choose:
      - alias: Set the brightness and transition for the normal lights switch
        conditions:
          - condition: template
            value_template: >-
              {{ ('use_colour_temperature' in include_light_control) and not
              ('use_brightness' in include_light_control) }}
        sequence:
          - service: light.turn_on
            target:
              entity_id: '{{ light_entities_off }}'
            data:
              kelvin: '{{temperature_value}}'
              transition: '{{ transition_on_value }}'
  - choose:
      - alias: Set the transition for the normal lights switch - Default
        conditions:
          - condition: template
            value_template: >-
              {{ ('use_brightness' not in include_light_control) and
              ('use_colour_temperature' not in include_light_control) }}
        sequence:
          - service: light.turn_on
            target:
              entity_id: '{{ light_entities_off }}'
            data:
              transition: '{{ transition_on_value }}'
  - alias: Turn on the switches
    service: switch.turn_on
    target:
      entity_id: '{{ switch_entities_off }}'
  - alias: Turn on the scenes
    service: scene.turn_on
    target:
      entity_id: '{{ scene_entities }}'
    data:
      transition: '{{ transition_on_value }}'
  - choose:
      - alias: By-pass is enabled & check by-pass option - turn lights on
        conditions:
          - condition: trigger
            id: t6
          - condition: template
            value_template: '{{ include_bypass == ''bypass_enabled_turn_on'' }}'
        sequence:
          - stop: Stop the automation
      - alias: Check if the trigger is on and wait for it to go off
        conditions:
          - condition: state
            entity_id:
              - binary_sensor.dinning_room_sensor_occupancy
            state: 'on'
            match: any
        sequence:
          - alias: Wait until motion sensor is off
            wait_for_trigger:
              platform: state
              entity_id:
                - binary_sensor.dinning_room_sensor_occupancy
              from: 'on'
              to: 'off'
  - alias: Wait the number of minutes set in the normal lights time delay
    delay:
      minutes: 5
  - alias: Turn off the lights
    service: light.turn_off
    target:
      entity_id: '{{ light_entities }}'
    data:
      transition: '{{ transition_off_value }}'
  - alias: Turn off the switches
    service: switch.turn_off
    target:
      entity_id: '{{ switch_entities }}'
  - alias: Turn off the scenes
    service: scene.turn_on
    entity_id: []
    data:
      transition: '{{ transition_off_value }}'

this is what is shown when the point of where the orange line last goes

Again sorry for the trouble this is obviously showing a problem with me and not ur blueprint but any help is apreciated

I have the same kind of switch, this is switching my light in the hallway. I have another automation which sets the switch to ON based on sunset. Another automation switches the light off at midnight.

So I first set the Sensor Light blueprint to run only after midnight. But in summer, we switch off the lights manually to avoid insects flying inside towards the light if door is open.

So I changed the blueprint to run after sunset. So far so good…

But now the lights will go off too if somebody enters the hallway, even if the light was ON before motion was detected.

Is it possible to bypass the Sensor Light script, if the light was already ON behore motion was detected? I can’t use bypass because the specific light is on the switch itself. And my Wife does not want to push buttons each time she walks by… :wink:

So Long story short: Is a bypass function if light was already ON, a feature to be expected?

I cannot disable automation based on light status; it would kill itself too if the automation would set the light to ON :smile:

Thanks for all the information. I do have an idea that could fix this… I just need to develop it and test it. Hopefully it will be out in the next release.

Stay turned

Blacky :smiley:

The by-pass is like a pause button. You have 3 options to chose from on what should happen when you turn the by-pass ON. Unlike just disabling the automation when you turn OFF the by-pass it looks to see what is happening and reacts to the correct way the automation should run.

If you would like to go over the top, when family visits and if they are also included in HA as a local only access you could use their mobile phone and when the phone is in the zone you could have it turn ON the by-pass automaticity, thus disabling the automation and they just use the switch as a normal light switch.

@Peoples204

We need the screen shot of your automation like shown below. I click on the orange where it stopped and had to take 2 screen shots so you can read it. This way I can look at it and advise you.

Love the Blueprint! My only suggestion is to allow a ‘sun’ option for the night time schedule instead of fixed times.

2 Likes

@DuckDuck25

Thanks for your kind words :smiling_face_with_three_hearts:

This is on the road map to be added. Thanks for your suggestion :+1:

1 Like

New update 3.9

Do you keep forgetting to turn the by-pass OFF and your lights either say ON or don’t come ON at all when they should, to then realise you left the by-pass ON? :unamused:

New Features :new:

  • Added the ability to use a “By-pass Auto OFF Option”. This is used when you turn the by-pass ON and you would like the by-pass to automatically turn OFF in a set time delay. It can also be used as a timer to turn the lights ON and then OFF if you have chosen to use “Enable the By-pass - Turn lights ON”.

Bugs Fixes :bug:

  • Add default value to transition.

If you like this blueprint? Consider hitting the :heart: button in the top post :+1:

Enjoy

Blacky :grinning:

2 Likes

New update 4.0

Sorry for the this next update so close to Version 3.9 but I thought I would push it out ASAP. If you haven’t updated from Version 3.8 yet please see the above post on Version 3.9 release notes.

Bugs Fixes :bug:

  • HA Restart - By-pass Auto OFF
  • HA Restart - Trigger is ON Lights OFF

If you like this blueprint? Consider hitting the :heart: button in the top post :+1:

Enjoy

Blacky :grinning:

2 Likes

image
Received an error using Home Assistant 2023.1.7
HA doesn’t seem to like the smiley face in the YAML.

Hi @Blacky great blueprint, and as an HA beginner I am overwhelmed by all the options. Just a quick question: I would love to use the night light option to have the lights not so bright during nighttime. I have to enter the Night Light start time and end time during creating the automation. But I would prefer to use sunset and sunrise time, not the fixed time values. There is already a “sun” option in the blueprint, but it does not seem to be related to the Night Light feature? Is it possible to have a flexible (sunset and sunrise) time set for the Night Light option?

Edit: found in this thread it is on your roadmap already… hope to see it implemented soon :wink:

Blacky, does it make sense to have more than one light-turn-off duration setting if we have more than one entity or device turned on by the trigger? For instance, once my motion sensor in the bathroom is triggered the lights turn on and so does the fan. It’ll be nice to set the lights to turn off 30 seconds after the last motion but the fan to turn off maybe 5 minutes later to exhaust the humid air.