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

First of all, thanks for publishing this automation! It looks like it will do exactly what I want, if I can get it to work.

However, I am having problems just getting it to trigger in the simplest configuration (just adding a sensor and a switch). This is what I see when I edit it in yaml:

 alias: lights
 description: ""
 use_blueprint:
   path: Blackshome/sensor-light.yaml
   input:
     motion_trigger:
       - binary_sensor.garage_motion_sensor_occupancy
     light_switch:
       device_id: 24a111edd2c57f37d3ed2cdaa01cddfe

In my dashboard I can see the sensor goes from “clear” to “detected” when I move, and can get other simpler light automations (that don’t have as many features as this one) to trigger off of it. Seems like I am missing something basic, but can’t figure out what.

I set homeassistant up a few years ago, but didn’t do anything beyond connect my thermostat till now. I just updated everything with an update button, but maybe there is something stale somewhere?

You can ignore my question. I found the answer by reading this post a few posts up:

I just had exactly this happen. Couldn’t figure out why it wasn’t triggering. It was a device (blue) that I had chosen not the Entity (green). I wasn’t even thinking that could be a problem because to me the trigger was what mattered. Still learning.

I did look through the FAQ and didn’t find this answer, so may be worth adding a note there or something.

firstly, awesome automation @Blacky !
I just started using this blueprint with 3 automations (for now) and I think there may be a bug. Note, I have not used a previous version and recently started on HAss - former Smartthings users for many years including using Edge drivers…

Seems like the transition object is mandatory, it needs to be checked and anything < 0. I started debugging my automation with 1 second for both on and off transistions, graduated to 0.1 for both on and off and transition enabled. If I uncheck the transition, the automation doesnt fire.
Here is the trace timeline (not sure what else would help you).

Triggered by the state of binary_sensor.motion_living_room_3 at June 28, 2023 at 9:52:36 PM

Test if any of 12 conditions matches

Test if any of 6 conditions matches

Test if any of 3 conditions matches

Test if any of 6 conditions matches

Test if any of 3 conditions matches

Test if any of 3 conditions matches

Choose: Default action executed

Stopped because an error was encountered at June 28, 2023 at 9:52:36 PM (runtime: 0.07 seconds)

Transition value 0 is not valid.

For now, as a workaround I have transitions enabled and 0.1 for on and off values.
Hope to hear back from you. This community seems to be great!

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 }}’

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 issue is typically caused by selecting Areas or Devices in Lights - Switches - Scenes - Scripts. The blueprint only supports entities, not Areas, Devices, or Labels.

To fix this, click the expand button “<>” as shown below. This will break down your selected Areas, Devices, and Labels into individual entities. Ensure that all selections are green and consist only of entities. The same applies to “Night Lights.”

After making these changes, your trigger should activate the automation correctly.

Areas :x:

Devices :x:

Labels :x:

Entities :white_check_mark: :+1:

Enjoy

Blacky :smiley:

Back to FAQ: Click Here

2 Likes

@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