Skip to content

Commit

Permalink
[Light hook] Add support for Adaptive Lighting
Browse files Browse the repository at this point in the history
  • Loading branch information
KrzysztofHajdamowicz committed Nov 21, 2021
1 parent 218b342 commit 284781a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
27 changes: 26 additions & 1 deletion blueprints/hooks/light/light.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ blueprint:
default: true
selector:
boolean:
enable_adaptive_lighting:
name: (Optional) Use Adaptive Lighting
description: Use Adaptive Lighting custom component to power on light with parameters reflecting current sun position. Not available when 'Force brightness' is enabled
default: false
selector:
boolean:
adaptive_lighting_switch:
name: Entity of Adaptive Lighting switch
description: Adaptive lighting switch to pull parameters from
selector:
entity:
domain: switch

# Automation schema
variables:
# convert blueprint inputs into variables to be used in templates
Expand Down Expand Up @@ -256,6 +269,9 @@ variables:
on_brightness: !input on_brightness
smooth_power_on: !input smooth_power_on
smooth_power_off: !input smooth_power_off
enable_adaptive_lighting: !input enable_adaptive_lighting
adaptive_lighting_switch: !input adaptive_lighting_switch
# Blueprint data
color_modes:
Auto: auto
Color Temperature: color_temp
Expand Down Expand Up @@ -291,13 +307,18 @@ action:
- service: light.toggle
entity_id: !input light
data:
brightness: !input on_brightness
color_temp: >-
{{ state_attr(adaptive_lighting_switch, 'color_temp_mired') |int if enable_adaptive_lighting }}
transition: '{{ light_transition / 1000 }}'
default:
- service: light.toggle
entity_id: !input light
data:
transition: '{{ light_transition / 1000 }}'
brightness_pct: >-
{{ state_attr(adaptive_lighting_switch, 'brightness_pct') |int if enable_adaptive_lighting }}
color_temp: >-
{{ state_attr(adaptive_lighting_switch, 'color_temp_mired') |int if enable_adaptive_lighting }}
- conditions: '{{ action == turn_on }}'
sequence:
- choose:
Expand All @@ -313,6 +334,10 @@ action:
entity_id: !input light
data:
transition: '{{ light_transition / 1000 }}'
brightness_pct: >-
{{ state_attr(adaptive_lighting_switch, 'brightness_pct') |int if enable_adaptive_lighting }}
color_temp: >-
{{ state_attr(adaptive_lighting_switch, 'color_temp_mired') |int if enable_adaptive_lighting }}
- conditions: '{{ action == turn_off }}'
sequence:
- service: light.turn_off
Expand Down
10 changes: 10 additions & 0 deletions website/docs/blueprints/hooks/light.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ This integration provides the entity which represents a light in Home Assistant.
description='Allow a brightness down command (single or continuous) to turn off the light when at minimum brightness. Disabling this will prevent the light from being turned off by brightness down commands.'
selector='boolean'
/>
<Input
name='Use Adaptive Lighting'
description='Integrate with [Adaptive Lighting](https://github.com/basnijholt/adaptive-lighting) custom integration to provide flicker-free powering on experience. Light will be powered with proper parameters, providing instantaneous settings for brightness and color temperature.
selector='boolean'
/>
<Input
name='Entity of Adaptive Lighting switch'
description='Specify entity created by Adaptive Lighting integration. For example: `switch.adaptive_lighting_bedroom`'
selector='select'
/>

## Supported Controllers

Expand Down

0 comments on commit 284781a

Please sign in to comment.