Last active
March 6, 2024 11:56
-
-
Save fredrike/f02562ea5e45226945e9df2d4b8214df to your computer and use it in GitHub Desktop.
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: Toggle Lights | |
description: Toggle lights brightness with a button press. | |
domain: automation | |
input: | |
button_entity: | |
name: Button Entity | |
description: The entity ID of the button or switch. | |
selector: | |
entity: | |
domain: binary_sensor | |
device_class: button | |
toggle_state: | |
name: Toggle State Input Boolean | |
description: The input boolean used to track the state of the lights. | |
default: input_boolean.light_toggle_state | |
light_entity: | |
name: Light Entity | |
description: The entity ID of the light to toggle. | |
selector: | |
entity: | |
domain: light | |
automation: | |
alias: Toggle Lights | |
description: Toggle lights brightness with a button press. | |
trigger: | |
platform: state | |
entity_id: !input button_entity | |
mode: restart | |
action: | |
- repeat: | |
while: | |
- condition: state | |
entity_id: !input button_entity | |
state: "on" | |
sequence: | |
- service: light.turn_on | |
data: | |
entity_id: !input light_entity | |
brightness_step: "{{ -10 if is_state('input_boolean.light_toggle_state', 'on') else 10 }}" | |
- delay: "00:00:01" # Adjust the delay between each change in brightness | |
- service: input_boolean.toggle | |
entity_id: !input toggle_state |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment