blueprint: name: Gibbon's Advanced Motion Sensor (v2.0) description: > Turn on a light when motion is detected based on various factors (Time, Sun, Lux). Upgraded to fix 'unsupported color_temp' errors and includes Transition fading and Bypass modes. domain: automation input: test0: name: "*** Trigger Motion Sensor ***" default: "The following section is simply the motion entity you want to trigger the lights turning on." selector: text: multiline: true motion_entity: name: Motion Sensor description: The entity which you want the motion to be based on. selector: entity: domain: binary_sensor test1: name: "*** Condition variables ***" default: "The following section are methods of determining if the automation should proceed." selector: text: multiline: true bypass_entity: name: Bypass Switch (optional) description: If this entity is ON, the automation will be paused and will not trigger (Useful for a 'Guest Mode' or 'Force Off' helper). default: selector: entity: domain: - input_boolean - switch - binary_sensor ilum_entity: name: Light Binary Sensor (optional) description: The optional entity for a binary sensor (which should report ON for brighter than specified light level or OFF for darker). default: selector: entity: domain: binary_sensor lux_entity: name: Light Iluminance Sensor (optional) description: The optional entity for any entity which reports a lux value. default: selector: entity: domain: sensor lux_value: name: Desired Lux value (optional) description: If you are using the illuminance entity above, automation will trigger if lux value is less than this value. default: selector: number: min: 0 max: 100 mode: slider step: 1 elevation_shift: name: Elevation Shift description: Using an elevation offset (height of sun relative to the horizon) to shift the sunset trigger. default: selector: number: min: -20 max: 20 mode: slider step: 1 use_time: name: 'Use timeslot only' description: 'Enable this to ONLY use the timeslot in the automation (this overrides the sun/lux conditions)' default: false selector: boolean: time_from: name: 'Time from' description: 'Automation only activates after this time' default: "00:00:00" selector: time: time_to: name: 'Time to' description: 'Automation only activates before this time' default: "23:59:59" selector: time: test2: name: "*** Action variables ***" default: "The following section manages which lights turn on, how bright, their transition, and wait times." selector: text: multiline: true target_light: name: Lights description: This is the light(s) that will be activated. selector: target: entity: domain: light target_brightness: name: Brightness description: Brightness of the light(s) when they're activated. default: 50 selector: number: min: 5.0 max: 100.0 mode: slider step: 5.0 unit_of_measurement: '%' enable_color_temp: name: Enable Color Temperature description: TURN ON ONLY if your target bulbs support changing color temperature. Leaving this off prevents Home Assistant errors. default: false selector: boolean: target_color_temp: name: Temperature description: Temperature of the light(s) when activated (Ignored if toggle above is OFF). default: 280 selector: color_temp: min_mireds: 153 max_mireds: 500 transition_time: name: Transition Time description: How long (in seconds) the lights should take to gracefully fade ON and OFF. default: 2 selector: number: min: 0 max: 30 unit_of_measurement: seconds no_motion_wait: name: Wait time description: Time to leave the light on after last motion is detected. default: 120 selector: number: min: 0 max: 3600 unit_of_measurement: seconds mode: restart max_exceeded: silent variables: bypass_entity: !input bypass_entity motion_entity: !input motion_entity ilum_entity: !input ilum_entity lux_entity: !input lux_entity lux_value: !input lux_value elevation_shift: !input elevation_shift use_time: !input use_time time_from: !input time_from time_to: !input time_to target_light: !input target_light target_brightness: !input target_brightness enable_color_temp: !input enable_color_temp target_color_temp: !input target_color_temp transition_time: !input transition_time no_motion_wait: !input no_motion_wait # Fixed time span logic to properly handle overnights (e.g. 22:00 to 06:00) within_time_use: > {% set t_from = time_from | today_at %} {% set t_to = time_to | today_at %} {% if t_from < t_to %} {{ t_from <= now() <= t_to }} {% else %} {{ now() >= t_from or now() <= t_to }} {% endif %} within_time: > {{ not use_time or within_time_use }} sun_elevation_below_shift: > {{ elevation_shift is not none and elevation_shift != '' and (state_attr('sun.sun', 'elevation') | float(0) < elevation_shift | float(0)) }} lux_check: > {{ lux_entity is not none and lux_value is not none and lux_value != '' and states(lux_entity) | float(1000) < lux_value | float(0) }} ilum_check: > {{ ilum_entity is not none and is_state(ilum_entity, 'off') }} trigger: - platform: state entity_id: !input motion_entity from: "off" to: "on" condition: # Check if the bypass switch is active. If so, halt the automation. - condition: template value_template: > {{ bypass_entity == none or bypass_entity == '' or not is_state(bypass_entity, 'on') }} # Time, Sun, and Lux checks - condition: template value_template: > {% if use_time %} {{ within_time_use }} {% else %} {{ within_time and (ilum_check or lux_check or sun_elevation_below_shift) }} {% endif %} action: # Choose block dynamically decides whether to send color_temp based on the user toggle - choose: - conditions: - condition: template value_template: "{{ enable_color_temp }}" sequence: - service: light.turn_on target: !input target_light data: brightness_pct: '{{ target_brightness | int }}' color_temp: '{{ target_color_temp | int }}' transition: '{{ transition_time | int }}' default: - service: light.turn_on target: !input target_light data: brightness_pct: '{{ target_brightness | int }}' transition: '{{ transition_time | int }}' - wait_for_trigger: platform: state entity_id: !input motion_entity from: "on" to: "off" - delay: !input no_motion_wait - service: light.turn_off target: !input target_light data: transition: '{{ transition_time | int }}'