Last active
November 19, 2025 00:27
-
-
Save lavoiesl/cdb90680693c8c7494e7414c7ad17254 to your computer and use it in GitHub Desktop.
HomeAssistant Blueprint – Light Pairing
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: Light Pairing | |
| description: Toggle a light depending on a binary sensor | |
| domain: automation | |
| source_url: https://gist.githubusercontent.com/lavoiesl/cdb90680693c8c7494e7414c7ad17254/raw/light_pairing.yaml | |
| author: [email protected] | |
| input: | |
| trigger_entity: | |
| name: Binary Sensor | |
| selector: | |
| entity: | |
| filter: | |
| - device_class: occupancy | |
| domain: binary_sensor | |
| - device_class: motion | |
| domain: binary_sensor | |
| - device_class: door | |
| domain: binary_sensor | |
| - domain: light | |
| light_target: | |
| name: Light | |
| selector: | |
| target: | |
| entity: | |
| domain: light | |
| brightness: | |
| name: Brightness | |
| description: Brightness to turn on the light to. Use 0 to ignore. | |
| default: 0 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 100 | |
| unit_of_measurement: "%" | |
| invert: | |
| name: Invert | |
| description: Turn on when the trigger entity is off | |
| default: false | |
| selector: | |
| boolean: | |
| mode: restart | |
| max_exceeded: silent | |
| triggers: | |
| trigger: state | |
| entity_id: !input trigger_entity | |
| from: null | |
| to: null | |
| actions: | |
| - variables: | |
| input_target: !input light_target | |
| input_brightness: !input brightness | |
| input_invert: !input invert | |
| trigger_state: "{{ trigger.to_state.state == 'on' }}" | |
| target_supports_brightness: "{{ 'brightness' in state_attr(input_target.entity_id, 'supported_color_modes') }}" | |
| target_state: "{{ trigger_state != input_invert }}" | |
| target_action: "{{ iif(target_state, 'light.turn_on', 'light.turn_off') }}" | |
| target_brightness: "{{ iif(target_state and target_supports_brightness, input_brightness, 0) }}" | |
| target_data: >- | |
| {{ iif(target_brightness > 0, { 'brightness_pct': input_brightness }, | |
| {}) }} | |
| - action: "{{ target_action }}" | |
| data: "{{ target_data }}" | |
| target: "{{ input_target }}" | |
| enabled: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment