Skip to content

Instantly share code, notes, and snippets.

@Belphemur
Last active February 5, 2026 15:25
Show Gist options
  • Select an option

  • Save Belphemur/ad86ca5288be43a57a6b47eaf39a0fc6 to your computer and use it in GitHub Desktop.

Select an option

Save Belphemur/ad86ca5288be43a57a6b47eaf39a0fc6 to your computer and use it in GitHub Desktop.
Night Light Home Assistant
blueprint:
name: "Third Reality Light - Occupancy, Lux & Color Control"
description: |
**Occupancy and Light Level Automation for Third Reality Lights with Color Control**
This blueprint automatically controls a Third Reality light based on:
- **Occupancy detection**: Light turns on when motion/occupancy is detected
- **Light level**: Only turns on when ambient light is below the threshold
- **Color selection**: Choose your preferred color via color picker
- **Timeout**: Turns off after a configurable period of no occupancy
Perfect for hallways, bathrooms, closets, and other areas where you want automatic lighting that respects ambient light conditions with custom colors.
**Requirements:**
- Motion/occupancy sensor
- Light/illuminance sensor
- Third Reality light (or any RGB-compatible light)
domain: automation
author: "Home Assistant User"
homeassistant:
min_version: "2026.1.0"
input:
# Device Selection Section
device_section:
name: "🏠 Device Selection"
description: "Select your sensors and light"
icon: mdi:devices
input:
occupancy_sensor:
name: "Occupancy Sensor"
description: "Motion or occupancy sensor that triggers the automation"
selector:
entity:
filter:
- domain: binary_sensor
device_class:
- motion
- occupancy
lux_sensor:
name: "Light Level Sensor"
description: "Sensor that measures ambient light (illuminance/lux)"
selector:
entity:
filter:
- domain: sensor
device_class: illuminance
target_light:
name: "Target Light"
description: "The Third Reality light (or any RGB-compatible light) to control"
selector:
entity:
filter:
- domain: light
# Behavior Settings Section
behavior_section:
name: "⚙️ Behavior Settings"
description: "Configure when and how the light operates"
icon: mdi:cog
input:
lux_threshold:
name: "Light Level Threshold"
description: "Light will only turn on when ambient light is below this value"
default: 50
selector:
number:
min: 0
max: 1000
step: 10
unit_of_measurement: "lx"
mode: slider
occupancy_timeout:
name: "No Occupancy Timeout"
description: "How long to wait after no occupancy before turning off the light"
default: 60
selector:
duration:
brightness_level:
name: "Brightness Level"
description: "Brightness percentage when the light turns on"
default: 80
selector:
number:
min: 1
max: 100
step: 5
unit_of_measurement: "%"
mode: slider
light_color:
name: "Light Color"
description: "Choose the color for the light when it turns on"
default: [255, 255, 255]
selector:
color_rgb:
# Advanced Options Section
advanced_section:
name: "🔧 Advanced Options"
description: "Optional advanced configuration"
icon: mdi:tune
collapsed: true
input:
enable_logging:
name: "Enable Logging"
description: "Log automation actions to the logbook for debugging"
default: true
selector:
boolean:
automation_mode:
name: "Automation Mode"
description: "How the automation should behave when triggered multiple times"
default: "restart"
selector:
select:
options:
- label: "Single (ignore new triggers while running)"
value: "single"
- label: "Restart (restart when triggered again) - Recommended"
value: "restart"
- label: "Queued (queue multiple triggers)"
value: "queued"
- label: "Parallel (run multiple instances)"
value: "parallel"
# FIXED: Convert !input values to variables for use in templates
variables:
lux_sensor_entity: !input lux_sensor
brightness_value: !input brightness_level
color_value: !input light_color
timeout_value: !input occupancy_timeout
mode: !input automation_mode
max_exceeded: silent
trigger:
# Turn on when occupancy detected
- platform: state
entity_id: !input occupancy_sensor
to: "on"
id: "occupancy_detected"
# Turn off when no occupancy for specified time
- platform: state
entity_id: !input occupancy_sensor
to: "off"
for: !input occupancy_timeout
id: "occupancy_cleared"
condition: []
action:
- choose:
# Turn light ON when occupancy detected AND lux is low
- conditions:
- condition: trigger
id: "occupancy_detected"
- condition: numeric_state
entity_id: !input lux_sensor
below: !input lux_threshold
- condition: state
entity_id: !input target_light
state: "off"
sequence:
- service: light.turn_on
target:
entity_id: !input target_light
data:
brightness_pct: !input brightness_level
rgb_color: !input light_color
- if:
- condition: template
value_template: !input enable_logging
then:
- service: logbook.log
data:
name: "Third Reality Automation"
message: >
Light turned on - occupancy detected,
lux: {{ states(lux_sensor_entity) }}{{ state_attr(lux_sensor_entity, 'unit_of_measurement') }},
brightness: {{ brightness_value }}%,
color: {{ color_value }}
# Turn light OFF when no occupancy for timeout period
- conditions:
- condition: trigger
id: "occupancy_cleared"
- condition: state
entity_id: !input target_light
state: "on"
sequence:
- service: light.turn_off
target:
entity_id: !input target_light
- if:
- condition: template
value_template: !input enable_logging
then:
- service: logbook.log
data:
name: "Third Reality Automation"
message: >
Light turned off - no occupancy for {{ timeout_value }} seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment