Last active
December 8, 2022 23:07
-
-
Save DefenestrateIT/169979c02c321b308626a96e401c606d to your computer and use it in GitHub Desktop.
This file contains 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: | |
domain: script | |
name: Random [HAssNic's] Light Profile Effect | |
description: > | |
#Random [HAssNic's] Light profile Effect V.1\n | |
This blueprint is desghned to be part of A larger moduler script system.\n | |
I normally use this blueprint to create 'Bright', 'Dimmed' & 'Night-Light' profiles.\n | |
External varbles excepted: | |
v_target - The variable for 'Target:'. | |
v_transition_override - boolean Override, the 'data:' variable 'Transition:'\n | |
v_transition - 'Transition: time'\n | |
v_themed - boolean, all Random or themed. | |
source_url: https://gist.github.com/DefenestrateIT/169979c02c321b308626a96e401c606d | |
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_transition: | |
name: Transition Time | |
description: The Light.Turn_On Transition Time. | |
default: 0 | |
selector: | |
number: | |
min: 0.0 | |
max: 300.0 | |
mode: slider | |
step: 1.0 | |
input_Themed: | |
name: All different or the same | |
description: Random. | |
default: false | |
selector: | |
boolean: {} | |
variables: | |
input_Themed: !input input_Themed | |
input_transition: !input input_transition | |
input_target_lights: !input input_target_lights | |
transition: "{{ 0 if v_transition_override else transitions }}" | |
themed: "{{ v_themed if v_themed is defined else input_themed }}" | |
target: "{{ v_target if v_target is defined else input_target_lights }}" | |
transitions: "{{ v_transition if v_transition is defined else input_transition }}" | |
entities: > | |
{%- set ns = namespace(ret=[]) %} | |
{%- for key in ['device_id', 'area_id', 'entity_id'] %} | |
{%- set items = target.get(key, [] ) %} | |
{%- if items %} {#@petroUlegend#} | |
{%- set items = [ items ] if items is string else items %} | |
{%- set filt = key.split('_') | first %} | |
{%- set items = items if filt == 'entity' else items | map(filt ~ '_entities') | sum ( start = [] ) %} | |
{%- set ns.ret = ns.ret + [ items ] %} | |
{%- endif %} | |
{%- endfor %} | |
{{ ns.ret | sum(start=[]) }} | |
expanded: "{{ [] if target.entity_id is undefined else expand ( target.entity_id ) | map ( attribute = 'entity_id' ) | list }}" | |
filtered: "{{ entities | select( 'search' , '^light' ) | list }}" | |
lights_on: "{{ lights | select('is_state', 'on') | list }}" | |
lights_test: "{{ lights_on | count > 0 }}" | |
lights: "{{ filtered + expanded }}" | |
sequence: | |
- if: | |
- condition: template | |
value_template: "{{ Themed }}" | |
then: | |
- service: light.turn_on | |
data: | |
hs_color: | |
- "{{ range ( 360 ) | random }}" | |
- "{{ range ( 80 , 100 ) | random }}" | |
brightness_pct: 100 | |
transition: "{{ transition_aurora }}" | |
target: "{{ target }}" | |
else: | |
- repeat: | |
for_each: "{{ lights | reject ( 'in' , integration_entities ( 'group' ) ) | list }}" | |
sequence: | |
- service: light.turn_on | |
data: | |
hs_color: | |
- "{{ range ( 360 ) | random }}" | |
- "{{ range ( 80 , 100 ) | random }}" | |
brightness_pct: 100 | |
transition: "{{ transition_aurora }}" | |
target: | |
entity_id: "{{ repeat.item }}" | |
mode: parallel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment