Last active
          May 2, 2025 12:59 
        
      - 
      
- 
        Save blizzrdof77/07417204379764fd76fd8b8226190e4b to your computer and use it in GitHub Desktop. 
    Binary Sensor-activated Light Switch Controller Blueprint
  
        
  
    
      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: Binary Sensor-activated Light Switch Controller | |
| description: Turn on/off a light when binary sensor value turns on/off. | |
| domain: automation | |
| source_url: https://gist.github.com/blizzrdof77/07417204379764fd76fd8b8226190e4b | |
| input: | |
| trigger_entity: | |
| name: Binary Sensor | |
| selector: | |
| entity: | |
| domain: binary_sensor | |
| target_entity: | |
| name: Light/Device | |
| selector: | |
| target: | |
| entity: | |
| domain: | |
| - light | |
| - switch | |
| - group | |
| - input_boolean | |
| invert_behavior: | |
| name: Invert Behavior? | |
| description: Select this if you would like to invert the binary sensor's value to turn on/off the device. | |
| default: false | |
| selector: | |
| boolean: {} | |
| wait_time: | |
| name: Wait time | |
| description: Time to leave the light on after door is closed | |
| default: 0 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 1000 | |
| unit_of_measurement: seconds | |
| mode: restart | |
| max_exceeded: silent | |
| trigger: | |
| - platform: state | |
| entity_id: !input trigger_entity | |
| from: "on" | |
| to: "off" | |
| id: turn_off | |
| - platform: state | |
| entity_id: !input trigger_entity | |
| from: "off" | |
| to: "on" | |
| id: turn_on | |
| action: | |
| - variables: | |
| invert: !input 'invert_behavior' | |
| timeout: !input 'wait_time' | |
| target_entity_id: !input 'target_entity' | |
| target_state: >- | |
| {%- if invert == True -%} | |
| {%- set target_state = trigger.from_state.state -%} | |
| {%- else -%} | |
| {%- set target_state = trigger.to_state.state -%} | |
| {%- endif -%} | |
| {{ target_state }} | |
| - if: | |
| - condition: template | |
| value_template: "{{ target_state == 'off' }}" | |
| then: | |
| - delay: !input wait_time | |
| - service_template: >- | |
| {{ 'homeassistant.turn_' }}{{ target_state }} | |
| target: !input target_entity | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment