|
@@ -161,12 +161,12 @@ action:
|
|
|
data:
|
|
|
level: warning
|
|
|
logger: "{{ scene_name }}"
|
|
|
- message: "Lights: {{ synced_lights }} vs {{ synced_lights_input }}"
|
|
|
+ message: "Lights: {{ synced_lights }} vs {{ synced_lights_input }}. Invalid light ({{ invalid_light }})."
|
|
|
|
|
|
- alias: "Motion: Turn on exisiting scene or turn on lights."
|
|
|
continue_on_error: true # if scenes are empty (might happen after a scene.reload)
|
|
|
choose:
|
|
|
- conditions: "{{ states.scene|selectattr('attributes.friendly_name', 'eq', scene_name)|list|count == 1 and synced_lights == state_attr('scene.' + scene_name, 'entity_id')|sort }}"
|
|
|
+ conditions: "{{ states.scene|selectattr('attributes.friendly_name', 'eq', scene_name)|list|count == 1 and invalid_light not in state_attr('scene.' + scene_name, 'entity_id') }}"
|
|
|
sequence: # Scene do exist and is valid
|
|
|
|
|
|
- service: system_log.write
|
|
@@ -174,7 +174,7 @@ action:
|
|
|
level: "{{ log_level }}"
|
|
|
logger: "{{ scene_name }}"
|
|
|
message: >-
|
|
|
- Scene «{{ scene_name }}» already exists and contains all lights. Restore scene.
|
|
|
+ Scene «{{ scene_name }}» already exists and contains valid lights ({{ state_attr('scene.' + scene_name, 'entity_id') }}). Restore scene.
|
|
|
|
|
|
- alias: "Motion: Turn on existing scene for synced lights"
|
|
|
service: scene.turn_on
|
|
@@ -189,7 +189,7 @@ action:
|
|
|
logger: "{{ scene_name }}"
|
|
|
message: >-
|
|
|
Scene «{{ scene_name }} does NOT exist or is INVALID.
|
|
|
- Entities to sync: {{ synced_lights }} => Turn ON every light sourcce.
|
|
|
+ Entities to sync: {{ synced_lights }} => Turn ON every light source.
|
|
|
|
|
|
- alias: "Motion: Turn on synced lights"
|
|
|
service: light.turn_on
|
|
@@ -214,10 +214,10 @@ action:
|
|
|
synced_lights_values: >-
|
|
|
{% set lights = namespace(values=[]) %}
|
|
|
{% for light in synced_lights %}
|
|
|
- {%if is_state_attr(light, 'color_mode', 'brightness') %}
|
|
|
+ {%if is_state_attr(light, 'supported_color_modes', 'brightness') %}
|
|
|
{% set lights.values = lights.values + [state_attr(light, 'brightness')] %}
|
|
|
{% else %}
|
|
|
- {% set lights.values = lights.values + [states(light)] %}
|
|
|
+ {% set lights.values = lights.values + [ states(light) ] %}
|
|
|
{% endif %}
|
|
|
{% endfor %}
|
|
|
{{ lights.values }}
|
|
@@ -226,23 +226,23 @@ action:
|
|
|
wait_template: >-
|
|
|
{% set lights = namespace(changed=false) %}
|
|
|
{% for light in synced_lights %}
|
|
|
- {%if is_state_attr(light, 'color_mode', 'brightness') and not is_state_attr(light, 'brightness', synced_lights_values[loop.index0]) %}
|
|
|
+ {%if is_state_attr(light, 'supported_color_modes', 'brightness') and not state_attr(light, 'brightness') == synced_lights_values[loop.index0] %}
|
|
|
{% set lights.changed = true %}
|
|
|
- {% elif not is_state_attr(light, 'color_mode', 'brightness') and not is_state(light, synced_lights_values[loop.index0]) %}
|
|
|
+ {% elif not states(light) == synced_lights_values[loop.index0] %}
|
|
|
{% set lights.changed = true %}
|
|
|
{% endif %}
|
|
|
{% endfor %}
|
|
|
{{ lights.changed }}
|
|
|
|
|
|
- - alias: "Store variable with new light values (on or brightness)"
|
|
|
+ - alias: "Store variable with new light values (on or brightness), for debuging purposes"
|
|
|
variables:
|
|
|
synced_lights_new_values: >-
|
|
|
{% set lights = namespace(values=[]) %}
|
|
|
{% for light in synced_lights %}
|
|
|
- {%if is_state_attr(light, 'color_mode', 'brightness') %}
|
|
|
+ {%if is_state_attr(light, 'supported_color_modes', 'brightness') %}
|
|
|
{% set lights.values = lights.values + [state_attr(light, 'brightness')] %}
|
|
|
{% else %}
|
|
|
- {% set lights.values = lights.values + [states(light)] %}
|
|
|
+ {% set lights.values = lights.values + [ states(light) ] %}
|
|
|
{% endif %}
|
|
|
{% endfor %}
|
|
|
{{ lights.values }}
|
|
@@ -253,7 +253,7 @@ action:
|
|
|
level: "{{ log_level }}"
|
|
|
logger: "{{ scene_name }}"
|
|
|
message: >-
|
|
|
- Light levels changed: {{ synced_lights }} from {{ synced_lights_values }} to {{ synced_lights_new_values }}.
|
|
|
+ Light levels changed: {{ synced_lights }}\n\nfrom:{{ synced_lights_values }}\n\nto:{{ synced_lights_new_values }}.
|
|
|
Saving snapshot to scene «{{ scene_name }}».
|
|
|
|
|
|
- alias: "Store a variable with ON lights."
|
|
@@ -338,7 +338,7 @@ action:
|
|
|
brightness: >-
|
|
|
{% set brightness = namespace(levels=[]) %}
|
|
|
{% for light in synced_lights if is_state(light, 'on') %}
|
|
|
- {% if is_state_attr(light, 'color_mode', 'brightness') and state_attr(light, 'brightness')|int != 0 %}
|
|
|
+ {% if is_state_attr(light, 'supported_color_modes', 'brightness') and state_attr(light, 'brightness')|int != 0 %}
|
|
|
{% set brightness.levels = brightness.levels + [ state_attr(light, 'brightness')|float ] %}
|
|
|
{% else %}
|
|
|
{% set brightness.levels = brightness.levels + [ 100 ] %}
|