šŸ’” Sensor Light - Motion Sensor - Door Sensor - Sun Elevation - LUX Value - Scenes - Time - Light Control - Device Tracker - Night Lights

Thanks!
I will definently look into splitting it up into folders and additional files, that would give a much better overview!

It seems like the Bee In The Hive sensor is working! Thank you!

I use your blueprint for all my motion-activated lights. Some of the lights also have a switch attached to them, so you can also manually turn on (and off) the lights. How does that affect the automation? If i manually turn on the lights and the motion sensor detects motion in the room (because i move around in the room) would the automation still turn off the lights? I ask because i have the impression that sometimes when the lights are turned on manually (usually because they have been turned off accidentally for some time) they stay on. Do you know why?

No problem,

Glad you got it working.

Have a look at this post click here

Blacky :smiley:

Thereā€™s still a problem with the sensor, but iā€™m not sure what. Maybe itā€™s the position of my motion sensor; i have it pointing not directly towards but along the wall where the door is. This means motion is detected before the door is closed. Could that be the problem? (After just reading your docs, it seems no, it should be using scenario 2.

There are 2 times that affect this automation, the motion sensor reset time in the ā€œBee In The hiveā€ template sensor, and the ā€œTime Delayā€ value in the blueprint.

The ā€œBee in the hiveā€ sensor should reflect the time it takes for the motion sensor to reset to ā€œno motion detectedā€ from ā€œmotion detectedā€. For my Aqara Motion sensor P1, i have 2 time vaules: ā€œDetection interval: Time interval between action detectionā€ and ā€œOccupancy timeout: Time in seconds after which occupancy is cleared after detecting it.ā€ i guess it is the latter, which by default is set to the value of ā€œdetection intervalā€+2s. Detection interval is 10s, which means the other sensor must be 12s. So i set the delay value in the ā€œBee in the hiveā€ sensor to 20s.

The ā€œTime delayā€ value in the blueprint is set to 2 minutes.

I open the door, go in, close the door, do motion for 20s, then stand totally still. The lights turn off after 2 minutes. Why?

template sensor:

- trigger:
    - trigger: state
      entity_id: binary_sensor.badevaerelse_sensor_dor_aqara_contact
      to: "on"
    - trigger: state
      entity_id: binary_sensor.badevaerelse_sensor_dor_aqara_contact
      to: "off"
      for:
        seconds: 20
    - trigger: state
      entity_id: binary_sensor.badevaerelse_sensor_bevaegelse_aqara_occupancy
      to: "on"
  binary_sensor:
    - name: "BadevƦrelse Optaget Sensor"
      device_class: occupancy
      icon: mdi:account-box-outline
      state: >
        {{ is_state('binary_sensor.badevaerelse_sensor_dor_aqara_contact', 'off') and is_state('binary_sensor.badevaerelse_sensor_bevaegelse_aqara_occupancy', 'on') }}

start section of blueprint: (iā€™m not going to insert 6000+ lines of code)

sensor group:

logbook:

@Strux

Sorry your having trouble :pensive:. I have just made a test sensor for this and it works perfectly.

NOTE: Every time you change/edit your template sensor YAML you have to reload it for it to take effect. Easiest way is to go into developer tools > YAML tab > scroll down to Template Entities and click itā€¦ you should see a green tick.

Let try a few things to make it clear. In a dashboard add an entities card. In the card enter your door contact sensor, your sensor group, your motion sensor and your bee In The Hive sensor like shown below.

145

Now you can see at what is happening. Test a few things.

  1. Trigger your motion sensor and time how long it takes to go from detected to clear. Then add a few seconds (+5) to your time (seconds). Use this time as a starting point replacing your 20 seconds. Make sure you reload your template senors every time you change it as described above.
  2. Close the door, stand still not to trigger your motion sensor and wait until it is clear. Everything must be clear, then make your motion sensor go detected. You should see the group and bee in the hive go to detected. It should stay that way until you open the door.
  3. Close the door, keep your motion sensor detected past your seconds. You should see the group and bee in the hive go to detected. It should stay that way until you open the door.

If you would like to show me your settings please dont copy 6000+ lines of code. What you do is go into your automation, top right 3 dots, Edit in YAML, copy all the code (will be a small amount of YAML just your settings), come back to the forum and in your reply at the top tool bar click on ā€œ</>ā€ and paste code in there.

Blacky :smiley:

Now it work thank you. :grinning:

And great job on the guide update, now itā€™s very clear.

1 Like

Your welcome, glad you got it working.

Enjoy

Blacky :smiley:

Thank you Blacky very much appreciated.

I have made the requested changes. But, I have one issue, and i had another with the automations not working after restarting ha but that seems to be working now.

The only issue and this can be by design and i have to redo other automations or scenes.

So when I run for example goodnight scene or manually change the lights, the automation stops working or at least seems that way until i manually run it, then it starts working again.

alias: Sensor Light - Bedroom
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.bedroom_mmwave_radar_target
    light_switch:
      entity_id:
        - light.bedroom_back_left
        - light.bedroom_back_right
        - light.bedroom_left
        - light.bedroom_right
    time_delay: 3
    light_colour_temperature: 8000
    include_ambient: ambient_enabled
    ambient_light_sensor: sensor.bedroom_mmwave_ltr390_light
    include_device_tracker: zone_people_enabled
    zone: zone.home
    people:
      - person.******
      - person.******
      - person.******
    night_lights:
      entity_id:
        - light.bedroom_left
        - light.bedroom_right
    night_time_delay: 3
    include_night_light_control:
      - use_brightness
      - use_transition
      - if_lights_are_on_adjust_when_crossing_over
    include_night_light_colour_control: use_rgb_colour
    night_light_rgb_colour:
      - 255
      - 0
      - 0
    include_night_lights: night_lights_enabled
    night_lights_conditions:
      - entity_state_enabled
    night_lights_entity_state:
      - input_boolean.bedroom_sonos_helper
    night_lights_after_time: "21:01:00"
    night_lights_before_time: "21:02:00"
    include_light_control:
      - use_transition
    include_light_colour_control: use_colour_temperature
    light_transition_on: 2
    light_transition_off: 2
    night_light_transition_off: 1
    include_dynamic_lighting: enable_lux_controled_brightness
    dynamic_lighting_lux_sensor: sensor.bedroom_mmwave_ltr390_light
    dynamic_lighting_max_lux: 900
    dynamic_lighting_min_lux: 50
    dynamic_lighting_max_colour_temp: 8000
    dynamic_lighting_min_colour_temp: 2000
    dynamic_lighting_heartbeat: 10
    night_light_brightness: 1
    ambient_light_value: 50
    ambient_light_high_value: 1000
    dynamic_lighting_boolean: input_boolean.bedroomlights_helper
    boolean_scenes_scripts: input_boolean.bedroom_light_helper

@wagnerks1990

Thanks for your YAML.

I have changed a one thing.

  1. Removed script in input_boolean.bedroomlights_helper from Lights > Scenes & Scripts - Toggle Helper. You had the same helper in lights and in Dynamic Lighting - Toggle Helper (Optional). You only need it in dynamic lighting.
alias: Sensor Light - Bedroom
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.bedroom_mmwave_radar_target
    light_switch:
      entity_id:
        - light.bedroom_back_left
        - light.bedroom_back_right
        - light.bedroom_left
        - light.bedroom_right
    time_delay: 3
    light_colour_temperature: 8000
    include_ambient: ambient_enabled
    ambient_light_sensor: sensor.bedroom_mmwave_ltr390_light
    include_device_tracker: zone_people_enabled
    zone: zone.home
    people:
      - person.******
      - person.******
      - person.******
    night_lights:
      entity_id:
        - light.bedroom_left
        - light.bedroom_right
    night_time_delay: 3
    include_night_light_control:
      - use_brightness
      - use_transition
      - if_lights_are_on_adjust_when_crossing_over
    include_night_light_colour_control: use_rgb_colour
    night_light_rgb_colour:
      - 255
      - 0
      - 0
    include_night_lights: night_lights_enabled
    night_lights_conditions:
      - entity_state_enabled
    night_lights_entity_state:
      - input_boolean.bedroom_sonos_helper
    include_light_control:
      - use_transition
    include_light_colour_control: use_colour_temperature
    light_transition_on: 2
    light_transition_off: 2
    night_light_transition_off: 1
    include_dynamic_lighting: enable_lux_controled_brightness
    dynamic_lighting_lux_sensor: sensor.bedroom_mmwave_ltr390_light
    dynamic_lighting_max_lux: 900
    dynamic_lighting_min_lux: 50
    dynamic_lighting_max_colour_temp: 8000
    dynamic_lighting_min_colour_temp: 2000
    dynamic_lighting_heartbeat: 10
    night_light_brightness: 1
    ambient_light_value: 50
    ambient_light_high_value: 1000
    dynamic_lighting_boolean: input_boolean.bedroomlights_helper

Hope this helps.

Blacky :smiley:

I am getting this error on 2024.10.2
Error while executing automation.yyyy home ZeroDivisionError: float division by zero

How can I troubleshoot it?

Blacky,

I am running into this problem and not sure how to solve?

Triggered by the numeric state of sensor.bedroom_mmwave_ltr390_light at November 9, 2024 at 11:55:56 PM

Test If any of 22 conditions matches

Stopped because a condition failed at November 9, 2024 at 11:55:56 PM (runtime: 0.01 seconds)

Not all shown logbook entries might be related to this automation.

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/0/conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: true

conditions/0/conditions/0/entity_id/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: true state: ā€˜onā€™ wanted_state: ā€˜onā€™

conditions/0/conditions/1

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/1

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/1/conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: true

conditions/1/conditions/0/entity_id/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: true state: ā€˜onā€™ wanted_state: ā€˜onā€™

conditions/1/conditions/1

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false entities:

conditions/2

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/2/conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: true

conditions/2/conditions/0/entity_id/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: true state: ā€˜onā€™ wanted_state: ā€˜onā€™

conditions/2/conditions/1

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false entities:

conditions/3

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/3/conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: true

conditions/3/conditions/0/entity_id/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: true state: ā€˜onā€™ wanted_state: ā€˜onā€™

conditions/3/conditions/1

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false entities:

conditions/4

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/4/conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/5

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/5/conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/6

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/6/conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/7

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/7/conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/8

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/8/conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/9

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/9/conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/10

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/10/conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/11

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/11/conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/12

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/12/conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/13

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/13/conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/14

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/14/conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/15

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/15/conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/16

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/16/conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/17

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/17/conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/18

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/18/conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/19

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/19/conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/20

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/20/conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: true

conditions/20/conditions/0/entity_id/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: true state: ā€˜onā€™ wanted_state: ā€˜onā€™

conditions/20/conditions/1

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/21

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false

conditions/21/conditions/0

Executed: November 9, 2024 at 11:55:56 PM
Result:

result: false entities:

Step ConfigChanged VariablesRelated logbook entries

condition: or
conditions:
  - condition: and
    conditions:
      - condition: state
        entity_id:
          - binary_sensor.bedroom_mmwave_radar_target
        match: any
        state: 'on'
      - condition: trigger
        id: t0
  - condition: and
    conditions:
      - condition: state
        entity_id:
          - binary_sensor.bedroom_mmwave_radar_target
        state: 'on'
        match: any
      - '{{ include_sun == ''sun_enabled'' }}'
      - condition: trigger
        id: t1
  - condition: and
    conditions:
      - condition: state
        entity_id:
          - binary_sensor.bedroom_mmwave_radar_target
        state: 'on'
        match: any
      - '{{ include_ambient == ''ambient_enabled'' }}'
      - condition: trigger
        id: t2
  - condition: and
    conditions:
      - condition: state
        entity_id:
          - binary_sensor.bedroom_mmwave_radar_target
        state: 'on'
        match: any
      - '{{ include_time == ''time_enabled'' }}'
      - condition: trigger
        id: t3
  - condition: and
    conditions:
      - condition: trigger
        id: t4
      - '{{ include_night_lights == ''night_lights_enabled'' }}'
      - '{{ ''entity_state_enabled'' in night_lights_conditions }}'
      - condition: state
        entity_id:
          - input_boolean.bedroom_sonos_helper
        match: any
        state: 'on'
      - condition: or
        conditions:
          - >-
            {{ (expand(light_switch.entity_id) | selectattr('state', '==', 'on')
            | list | count > 0) }}
          - >-
            {{ (include_night_lights == 'night_lights_enabled') and
            (expand(night_lights.entity_id) | selectattr('state', '==', 'on') |
            list | count > 0) }}
          - condition: template
            value_template: >-
              {{ 'manage_scripts_crossing_over' in include_night_light_control
              }}
          - condition: template
            value_template: |-
              {% if boolean_scenes_scripts != [] %}
                {{ is_state(boolean_scenes_scripts, 'on') }}
              {% endif %}
          - condition: template
            value_template: |-
              {% if night_boolean_scenes_scripts != [] %}
                {{ is_state(night_boolean_scenes_scripts, 'on') }}
              {% endif %}
  - condition: and
    conditions:
      - condition: trigger
        id: t5
      - '{{ include_night_lights == ''night_lights_enabled'' }}'
      - '{{ ''time_enabled'' in night_lights_conditions }}'
      - condition: or
        conditions:
          - >-
            {{ (expand(light_switch.entity_id) | selectattr('state', '==', 'on')
            | list | count > 0) }}
          - >-
            {{ (include_night_lights == 'night_lights_enabled') and
            (expand(night_lights.entity_id) | selectattr('state', '==', 'on') |
            list | count > 0) }}
          - condition: template
            value_template: >-
              {{ 'manage_scripts_crossing_over' in include_night_light_control
              }}
          - condition: template
            value_template: |-
              {% if boolean_scenes_scripts != [] %}
                {{ is_state(boolean_scenes_scripts, 'on') }}
              {% endif %}
          - condition: template
            value_template: |-
              {% if night_boolean_scenes_scripts != [] %}
                {{ is_state(night_boolean_scenes_scripts, 'on') }}
              {% endif %}
  - condition: and
    conditions:
      - condition: trigger
        id: t6
      - '{{ include_night_lights == ''night_lights_enabled'' }}'
      - '{{ ''sun_enabled'' in night_lights_conditions }}'
      - condition: or
        conditions:
          - >-
            {{ (expand(light_switch.entity_id) | selectattr('state', '==', 'on')
            | list | count > 0) }}
          - >-
            {{ (include_night_lights == 'night_lights_enabled') and
            (expand(night_lights.entity_id) | selectattr('state', '==', 'on') |
            list | count > 0) }}
          - condition: template
            value_template: >-
              {{ 'manage_scripts_crossing_over' in include_night_light_control
              }}
          - condition: template
            value_template: |-
              {% if boolean_scenes_scripts != [] %}
                {{ is_state(boolean_scenes_scripts, 'on') }}
              {% endif %}
          - condition: template
            value_template: |-
              {% if night_boolean_scenes_scripts != [] %}
                {{ is_state(night_boolean_scenes_scripts, 'on') }}
              {% endif %}
  - condition: and
    conditions:
      - condition: trigger
        id: t7_on
      - '{{ ''bypass_enabled_turn_on'' in include_bypass }}'
  - condition: and
    conditions:
      - condition: trigger
        id: t7_off
      - '{{ ''bypass_enabled_turn_off'' in include_bypass }}'
  - condition: and
    conditions:
      - condition: trigger
        id: t7_stop
      - '{{ ''bypass_enabled_stop'' in include_bypass }}'
  - condition: and
    conditions:
      - condition: trigger
        id: t8_on
      - '{{ ''bypass_enabled_turn_on'' in include_bypass }}'
  - condition: and
    conditions:
      - condition: trigger
        id: t8_off
      - '{{ ''bypass_enabled_turn_off'' in  include_bypass }}'
  - condition: and
    conditions:
      - condition: trigger
        id: t8_stop
      - '{{ ''bypass_enabled_stop'' in include_bypass }}'
  - condition: and
    conditions:
      - condition: trigger
        id: t9
      - '{{ include_sun == ''sun_enabled'' }}'
      - condition: or
        conditions:
          - >-
            {{ (expand(light_switch.entity_id) | selectattr('state', '==', 'on')
            | list | count > 0) }}
          - >-
            {{ (include_night_lights == 'night_lights_enabled') and
            (expand(night_lights.entity_id) | selectattr('state', '==', 'on') |
            list | count > 0) }}
          - condition: template
            value_template: |-
              {% if boolean_scenes_scripts != [] %}
                {{ is_state(boolean_scenes_scripts, 'on') }}
              {% endif %}
          - condition: template
            value_template: |-
              {% if night_boolean_scenes_scripts != [] %}
                {{ is_state(night_boolean_scenes_scripts, 'on') }}
              {% endif %}
  - condition: and
    conditions:
      - condition: trigger
        id: t10
      - '{{ include_ambient == ''ambient_enabled'' }}'
      - '{{ ambient_light_options == ''ambient_light_option_disabled'' }}'
      - condition: or
        conditions:
          - >-
            {{ (expand(light_switch.entity_id) | selectattr('state', '==', 'on')
            | list | count > 0) }}
          - >-
            {{ (include_night_lights == 'night_lights_enabled') and
            (expand(night_lights.entity_id) | selectattr('state', '==', 'on') |
            list | count > 0) }}
          - condition: template
            value_template: |-
              {% if boolean_scenes_scripts != [] %}
                {{ is_state(boolean_scenes_scripts, 'on') }}
              {% endif %}
          - condition: template
            value_template: |-
              {% if night_boolean_scenes_scripts != [] %}
                {{ is_state(night_boolean_scenes_scripts, 'on') }}
              {% endif %}
  - condition: and
    conditions:
      - condition: trigger
        id: t11
      - '{{ include_time == ''time_enabled'' }}'
      - condition: or
        conditions:
          - >-
            {{ (expand(light_switch.entity_id) | selectattr('state', '==', 'on')
            | list | count > 0) }}
          - >-
            {{ (include_night_lights == 'night_lights_enabled') and
            (expand(night_lights.entity_id) | selectattr('state', '==', 'on') |
            list | count > 0) }}
          - condition: template
            value_template: |-
              {% if boolean_scenes_scripts != [] %}
                {{ is_state(boolean_scenes_scripts, 'on') }}
              {% endif %}
          - condition: template
            value_template: |-
              {% if night_boolean_scenes_scripts != [] %}
                {{ is_state(night_boolean_scenes_scripts, 'on') }}
              {% endif %}
  - condition: and
    conditions:
      - condition: trigger
        id: t12
      - '{{ include_night_lights == ''night_lights_enabled'' }}'
      - '{{ ''entity_state_enabled'' in night_lights_conditions }}'
      - condition: state
        entity_id:
          - input_boolean.bedroom_sonos_helper
        state: 'off'
      - condition: or
        conditions:
          - >-
            {{ (expand(light_switch.entity_id) | selectattr('state', '==', 'on')
            | list | count > 0) }}
          - >-
            {{ (include_night_lights == 'night_lights_enabled') and
            (expand(night_lights.entity_id) | selectattr('state', '==', 'on') |
            list | count > 0) }}
          - condition: template
            value_template: >-
              {{ 'manage_scripts_crossing_over' in include_night_light_control
              }}
          - condition: template
            value_template: |-
              {% if boolean_scenes_scripts != [] %}
                {{ is_state(boolean_scenes_scripts, 'on') }}
              {% endif %}
          - condition: template
            value_template: |-
              {% if night_boolean_scenes_scripts != [] %}
                {{ is_state(night_boolean_scenes_scripts, 'on') }}
              {% endif %}
  - condition: and
    conditions:
      - condition: trigger
        id: t13
      - '{{ include_night_lights == ''night_lights_enabled'' }}'
      - '{{ ''time_enabled'' in night_lights_conditions }}'
      - condition: or
        conditions:
          - >-
            {{ (expand(light_switch.entity_id) | selectattr('state', '==', 'on')
            | list | count > 0) }}
          - >-
            {{ (include_night_lights == 'night_lights_enabled') and
            (expand(night_lights.entity_id) | selectattr('state', '==', 'on') |
            list | count > 0) }}
          - condition: template
            value_template: >-
              {{ 'manage_scripts_crossing_over' in include_night_light_control
              }}
          - condition: template
            value_template: |-
              {% if boolean_scenes_scripts != [] %}
                {{ is_state(boolean_scenes_scripts, 'on') }}
              {% endif %}
          - condition: template
            value_template: |-
              {% if night_boolean_scenes_scripts != [] %}
                {{ is_state(night_boolean_scenes_scripts, 'on') }}
              {% endif %}
  - condition: and
    conditions:
      - condition: trigger
        id: t14
      - '{{ include_night_lights == ''night_lights_enabled'' }}'
      - '{{ ''sun_enabled'' in night_lights_conditions }}'
      - condition: or
        conditions:
          - >-
            {{ (expand(light_switch.entity_id) | selectattr('state', '==', 'on')
            | list | count > 0) }}
          - >-
            {{ (include_night_lights == 'night_lights_enabled') and
            (expand(night_lights.entity_id) | selectattr('state', '==', 'on') |
            list | count > 0) }}
          - condition: template
            value_template: >-
              {{ 'manage_scripts_crossing_over' in include_night_light_control
              }}
          - condition: template
            value_template: |-
              {% if boolean_scenes_scripts != [] %}
                {{ is_state(boolean_scenes_scripts, 'on') }}
              {% endif %}
          - condition: template
            value_template: |-
              {% if night_boolean_scenes_scripts != [] %}
                {{ is_state(night_boolean_scenes_scripts, 'on') }}
              {% endif %}
  - condition: and
    conditions:
      - condition: trigger
        id: t15
      - condition: or
        conditions:
          - >-
            {{ (expand(light_switch.entity_id) | selectattr('state', '==', 'on')
            | list | count > 0) }}
          - >-
            {{ (include_night_lights == 'night_lights_enabled') and
            (expand(night_lights.entity_id) | selectattr('state', '==', 'on') |
            list | count > 0) }}
          - condition: template
            value_template: |-
              {% if boolean_scenes_scripts != [] %}
                {{ is_state(boolean_scenes_scripts, 'on') }}
              {% endif %}
          - condition: template
            value_template: |-
              {% if night_boolean_scenes_scripts != [] %}
                {{ is_state(night_boolean_scenes_scripts, 'on') }}
              {% endif %}
  - condition: and
    conditions:
      - condition: state
        entity_id:
          - binary_sensor.bedroom_mmwave_radar_target
        match: any
        state: 'on'
      - condition: trigger
        id: t15
  - condition: and
    conditions:
      - >-
        {{ ('bypass_auto_off_enabled_on' in include_bypass_auto_off) or
        ('bypass_auto_off_enabled_off' in include_bypass_auto_off) or
        ('bypass_auto_off_enabled_stop' in include_bypass_auto_off) }}
      - condition: trigger
        id: t15
      - condition: or
        conditions:
          - condition: state
            entity_id: []
            match: any
            state: 'on'
          - condition: state
            entity_id: []
            match: any
            state: 'on'
          - condition: state
            entity_id: []
            match: any
            state: 'on'

You shouldnā€™t get an error.

Could you please provide us your YAML of the automation? This YAML code are the settings you have selected in the automation so I can help. To do this go into your automation, top right 3 dots, Edit in YAML, copy all the code, come back to the forum and in your reply at the top tool bar click on ā€œ</>ā€ and paste code in there.

Blacky :smiley:

What is your trigger, could you explain?

Could you please provide us your YAML of the automation? This YAML code are the settings you have selected in the automation so I can help. To do this go into your automation, top right 3 dots, Edit in YAML, copy all the code, come back to the forum and in your reply at the top tool bar click on ā€œ</>ā€ and paste code in there.

Blacky :smiley:

As a beginner with Home Assistant, thank you for this blueprint. It has many features. After finding it, I canceled my own automation and started using this one.

There is something I havenā€™t figured out yet, and I would appreciate your help: I have a motion sensor in my kitchen, as well as two lights. One is a ceiling light, and the other is LED lighting. I control the ceiling light with a switch I created in ESPHome. Additionally, I have a touch sensor functioning as a binary sensor in ESPHome. I control the LED light using a Sonoff switch. Thanks to the blueprint, if someone is present and itā€™s evening, the ceiling light turns on. If movement is detected at night, the LED light turns on. The touch sensor is set up as a bypass. Everything works flawlessly up to this point.

My question is: When in night mode, I would like to use the touch sensor (used for bypass) to control the ceiling light. Can I do this with this blueprint?

Thanks for a great blueprint, and great support :grinning:


alias: PR LIGHT Kƶk
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.presence_sensor_fp2_b842_presence_sensor_4
    light_switch:
      entity_id: switch.sonoff_switch_05
    light_transition_on: 1
    light_transition_off: 1
    time_delay: 2
    light_brightness: 60
    include_dynamic_lighting: enable_sun_elevation_brightness
    dynamic_lighting_lux_sensor: sensor.presence_sensor_fp2_b842_light_sensor_light_level
    include_ambient: ambient_enabled
    ambient_light_sensor: sensor.presence_sensor_fp2_b842_light_sensor_light_level
    ambient_light_value: 22

I am using mmwave (apollo sensor) for my trigger. But, any time any of the lights are altered it seems the automation stops working or wont work.

alias: Sensor Light - Bedroom
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.bedroom_mmwave_radar_target
    light_switch:
      entity_id:
        - light.bedroom_back_left
        - light.bedroom_back_right
        - light.bedroom_left
        - light.bedroom_right
    time_delay: 3
    light_colour_temperature: 8000
    include_ambient: ambient_disabled
    ambient_light_sensor: sensor.bedroom_mmwave_ltr390_light
    include_device_tracker: zone_people_enabled
    zone: zone.home
    people:
      - person.****
      - person.****
      - person.****
    night_lights:
      entity_id:
        - light.bedroom_left
        - light.bedroom_right
    night_time_delay: 3
    include_night_light_control:
      - use_brightness
      - use_transition
      - if_lights_are_on_adjust_when_crossing_over
    include_night_light_colour_control: use_rgb_colour
    night_light_rgb_colour:
      - 255
      - 0
      - 0
    include_night_lights: night_lights_enabled
    night_lights_conditions:
      - entity_state_enabled
    night_lights_entity_state:
      - input_boolean.bedroom_sonos_helper
    night_lights_after_time: "21:01:00"
    night_lights_before_time: "21:02:00"
    include_light_control:
      - use_transition
    include_light_colour_control: use_colour_temperature
    light_transition_on: 2
    light_transition_off: 2
    night_light_transition_off: 1
    include_dynamic_lighting: enable_lux_controled_brightness
    dynamic_lighting_lux_sensor: sensor.bedroom_mmwave_ltr390_light
    dynamic_lighting_max_lux: 900
    dynamic_lighting_min_lux: 0
    dynamic_lighting_max_colour_temp: 8000
    dynamic_lighting_min_colour_temp: 2000
    dynamic_lighting_heartbeat: 10
    night_light_brightness: 1
    ambient_light_value: 20
    ambient_light_high_value: 100
    dynamic_lighting_boolean: input_boolean.bedroomlights_helper

@muratcesmecioglu

Welcome to the community.

If the touch sensor is used in the bypass and it is night mode then it will control the night mode lights (LED). I not sure what bypass option your using but you may have to create another automation that when you are in night mode the tough sensor turns ON your ceiling light.

I assume your touch sensor has an ON / OFF state. That is when you touch it is becomes ON and when you touch it again it is OFF. Depending on what condition you are using for night lights will depend on how you set this up. Example if time is used for night lights then you could use this blueprint again, copy paste your touch sensor into the trigger set your ceiling light then use the time condition (not night light time condition) to be the same as night lights. Now your ceiling light will turn ON / OFF with your touch sensor at night time only.

Blacky :smiley:

1 Like

@Stefan_Fasth

Thanks for your YAML.

You are using a switch in dynamic lighting. Dynamic lighting only supports a light entity not a switch.

Please disable dynamic lighting as your switch will not have brightness control and it will only be ON / OFF.

Blacky :smiley:

@wagnerks1990

The trigger you are seeing is because you have your sensor.bedroom_mmwave_ltr390_light is in the Ambient input and this option is disabled. If you donā€™t what to use this option and you donā€™t want to see this entry then remove your sensor.bedroom_mmwave_ltr390_light sensor in Ambient condition. Nothing is wrong it is just doing what you asked.

Because you are using dynamic lighting option 1 if you adjust your lights brightness then if it is out of the range (your settings) it will readjust them back to dynamic lighting. During nigh lights if you adjust your light they should stay as is until they go OFF and turn back ON again.

Blacky :smiley:

Thank you for your reply. I think i will add another automation to bypass.

Iā€™m thinking to implement double touch feature to touch sensor for enable/disable light automation.

1 Like

Of course! Thanks (however I did work for like a month or so!)

1 Like