Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DefenestrateIT/d63510ad17f39a8eb6aa94299d9901d5 to your computer and use it in GitHub Desktop.
Save DefenestrateIT/d63510ad17f39a8eb6aa94299d9901d5 to your computer and use it in GitHub Desktop.
blueprint:
domain: script
name: Aurora [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/d63510ad17f39a8eb6aa94299d9901d5
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