Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DefenestrateIT/7a1efad0d38a94908ce56d05180eb1a7 to your computer and use it in GitHub Desktop.
Save DefenestrateIT/7a1efad0d38a94908ce56d05180eb1a7 to your computer and use it in GitHub Desktop.
blueprint:
domain: script
name: Light Turn_Off [HAssNic's] Profile Effect
source_url: https://gist.github.com/DefenestrateIT/7a1efad0d38a94908ce56d05180eb1a7
description: >
#Light Turn_Off [HAssNic's] Profile Effect V.1\n
This blueprint is desghned to be part of A larger moduler script system.\n
External varbles excepted:\n
v_target - The variable for 'Target:'.
v_transition - Overrides the 'data:' variable 'Transition:'\n
v_profile: -
input:
input_target_lights:
name: Targeted Lights
description: "[OPTIONAL] The Lights this Script is Targeted at for (mainly) testing purposes.\n This option should be overriden by the external variable: 'v_target'"
default:
selector:
target:
entity:
domain: light
input_profile:
name: Profile Selection
description: "[OPTIONAL] The Profile for these Lights"
default:
selector:
entity:
domain: input_select
input_transition_off:
name: Transition 'off' Time
description: "The Transition time in seconds for this 'Profile'.\n Can be overriden with the 'data:' variable 'v_Transition_on'"
default: 0
selector:
number:
min: 0.0
max: 300.0
mode: slider
step: 1.0
input_flash:
name: Flash
default: "Off"
selector:
select:
options:
- "Off"
- "Long"
- "Short"
multiple: false
variables:
input_flash: !input input_flash
input_target_lights: !input input_target_lights
input_transition_off: !input input_transition_off
flash: "{{ 'short' if profile == 'short-flash' or input_flash == 'Short' else 'long' }}"
flash_on: "{{ true if profile == 'short-flash' or profile == 'long-flash' or input_flash != 'Off' else false }}"
transition_off: "{{ v_transition_off if v_transition_off is defined else input_transition_off }}"
transition_override: "{{ v_transition_override if v_transition_override is defined else false }}"
target: "{{ v_target if v_target is defined else input_target_lights }}"
profile: "{{ v_profile if v_profile is defined else input_profile }}"
transition: "{{ 0 if transition_override else transition_off }}"
sequence:
- if:
- condition: template
value_template: "{{ flash_on }}"
then:
- service: light.turn_off
data:
flash: "{{ flash }}"
target: "{{ target }}"
else:
- service: light.turn_off
data:
transition: "{{ transition }}"
target: "{{ target }}"
mode: parallel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment