Last active
December 17, 2025 06:33
-
-
Save ConnorGriffin/1331f0db05811858fa15fd0495dc8790 to your computer and use it in GitHub Desktop.
HomeAssistant Blueprint: ConnorGriffin's Light Modes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| blueprint: | |
| name: "ConnorGriffin's Light Modes" | |
| description: "Controls light brightness at Off->On based on a configurable curve, as well as min/max bright modes based. Requires a dropdown (input-select) helper with modes: Auto, Min, Max." | |
| domain: automation | |
| input: | |
| light: | |
| name: Light | |
| description: The light to control | |
| selector: | |
| entity: | |
| domain: light | |
| mode_selector: | |
| name: Mode Selector | |
| description: Input select controlling light mode (Auto / Min / Max) | |
| selector: | |
| entity: | |
| domain: input_select | |
| min_brightness: | |
| name: Minimum Brightness | |
| description: Brightness percentage when minimum | |
| default: 20 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 100 | |
| unit_of_measurement: "%" | |
| max_brightness: | |
| name: Maximum Brightness | |
| description: Brightness percentage when maximum | |
| default: 100 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 100 | |
| unit_of_measurement: "%" | |
| pre_sunrise: | |
| name: Minutes Before Sunrise | |
| description: Start ramp-up this many minutes before sunrise | |
| default: 120 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 480 | |
| unit_of_measurement: "min" | |
| morning_ramp: | |
| name: Morning Ramp Duration | |
| description: Duration of ramp-up in minutes | |
| default: 150 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 480 | |
| unit_of_measurement: "min" | |
| pre_sunset: | |
| name: Minutes Before Sunset | |
| description: Start ramp-down this many minutes before sunset | |
| default: 30 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 480 | |
| unit_of_measurement: "min" | |
| evening_ramp: | |
| name: Evening Ramp Duration | |
| description: Duration of ramp-down in minutes | |
| default: 360 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 480 | |
| unit_of_measurement: "min" | |
| trigger: | |
| - platform: state | |
| entity_id: !input light | |
| from: "off" | |
| to: "on" | |
| id: turned_on | |
| - platform: state | |
| entity_id: !input light | |
| from: "on" | |
| to: "off" | |
| id: turned_off | |
| - platform: state | |
| entity_id: !input mode_selector | |
| id: mode_change | |
| variables: | |
| light: !input light | |
| mode_selector: !input mode_selector | |
| min_brightness: !input min_brightness | |
| max_brightness: !input max_brightness | |
| pre_sunrise: !input pre_sunrise | |
| morning_ramp: !input morning_ramp | |
| pre_sunset: !input pre_sunset | |
| evening_ramp: !input evening_ramp | |
| action: | |
| - choose: | |
| - conditions: | |
| - condition: or | |
| conditions: | |
| - condition: and | |
| conditions: | |
| - condition: trigger | |
| id: turned_on | |
| - condition: state | |
| entity_id: !input mode_selector | |
| state: "Auto" | |
| - condition: and | |
| conditions: | |
| - condition: trigger | |
| id: mode_change | |
| - condition: state | |
| entity_id: !input mode_selector | |
| state: "Auto" | |
| - condition: state | |
| entity_id: !input light | |
| state: "on" | |
| sequence: | |
| - service: light.turn_on | |
| target: | |
| entity_id: !input light | |
| data: | |
| brightness_pct: > | |
| {% set sr = today_at((state_attr('sun.sun','next_rising')|as_datetime|as_local).strftime('%H:%M')) %} | |
| {% set ss = today_at((state_attr('sun.sun','next_setting')|as_datetime|as_local).strftime('%H:%M')) %} | |
| {% set t = now() %} | |
| {% set ramp_up_start = sr - timedelta(minutes=pre_sunrise) %} | |
| {% set ramp_up_end = ramp_up_start + timedelta(minutes=morning_ramp) %} | |
| {% set ramp_down_start = ss - timedelta(minutes=pre_sunset) %} | |
| {% set ramp_down_end = ramp_down_start + timedelta(minutes=evening_ramp) %} | |
| {% if ramp_up_start <= t < ramp_up_end %} | |
| {{ (min_brightness + ((t - ramp_up_start).total_seconds() / (morning_ramp*60)) * (max_brightness - min_brightness)) | int }} | |
| {% elif ramp_up_end <= t < ramp_down_start %} | |
| {{ max_brightness }} | |
| {% elif ramp_down_start <= t < ramp_down_end %} | |
| {{ (max_brightness - ((t - ramp_down_start).total_seconds() / (evening_ramp*60)) * (max_brightness - min_brightness)) | int }} | |
| {% else %} | |
| {{ min_brightness }} | |
| {% endif %} | |
| - conditions: | |
| - condition: trigger | |
| id: turned_off | |
| sequence: | |
| - service: input_select.select_option | |
| target: | |
| entity_id: !input mode_selector | |
| data: | |
| option: Auto | |
| - conditions: | |
| - condition: and | |
| conditions: | |
| - condition: trigger | |
| id: mode_change | |
| - condition: state | |
| entity_id: !input mode_selector | |
| state: "Min" | |
| sequence: | |
| - service: light.turn_on | |
| target: | |
| entity_id: !input light | |
| data: | |
| brightness_pct: !input min_brightness | |
| - conditions: | |
| - condition: and | |
| conditions: | |
| - condition: trigger | |
| id: mode_change | |
| - condition: state | |
| entity_id: !input mode_selector | |
| state: "Max" | |
| sequence: | |
| - service: light.turn_on | |
| target: | |
| entity_id: !input light | |
| data: | |
| brightness_pct: !input max_brightness |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment