|
@@ -108,17 +108,6 @@ trigger_variables:
|
|
|
{{ synced_lights_input|unique|sort }}
|
|
|
|
|
|
trigger:
|
|
|
- ############ Hack for ############
|
|
|
- # - platform: state #
|
|
|
- # entity_id: "{{ sensors }}" #
|
|
|
- ##################################
|
|
|
- # - platform: template
|
|
|
- # value_template: >-
|
|
|
- # {% set sensors = namespace(triggered=false) %}
|
|
|
- # {% for sensor in trigger_sensors if is_state(sensor, 'on') %}
|
|
|
- # {% set sensors.triggered = true %}
|
|
|
- # {% endfor %}
|
|
|
- # {{ sensors.triggered }}
|
|
|
- platform: state
|
|
|
# from: "off"
|
|
|
to: "on"
|
|
@@ -191,7 +180,7 @@ action:
|
|
|
- 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 synced_lights == state_attr('scene.' + scene_name, 'entity_id')|sort }}"
|
|
|
sequence: # Scene do exist and is valid
|
|
|
|
|
|
- service: system_log.write
|
|
@@ -268,7 +257,7 @@ action:
|
|
|
Light levels changed: {{ synced_lights }} from {{ synced_lights_values }}.
|
|
|
Saving snapshot to scene «{{ scene_name }}».
|
|
|
|
|
|
- - alias: "Store variable a variable with ON lights."
|
|
|
+ - alias: "Store a variable with ON lights."
|
|
|
variables:
|
|
|
synced_lights_on: >-
|
|
|
{% set lights = namespace(on=[]) %}
|
|
@@ -291,13 +280,12 @@ action:
|
|
|
data:
|
|
|
scene_id: "{{ scene_name }}"
|
|
|
snapshot_entities: >-
|
|
|
- {{ synced_lights if synced_lights_on|count != 0 else [ invalid_light ] }}
|
|
|
+ {{ [ invalid_light ] if synced_lights_on|count == 0 else synced_lights }}
|
|
|
|
|
|
- - alias: >-
|
|
|
- Listen for motion change, and wait for it to become 'OFF',
|
|
|
- wait for the delay and actions to finish, and then send event to kill parallelism.
|
|
|
- sequence: # @ignore: Missing property "condition"
|
|
|
-
|
|
|
+ - sequence: # @ignore: Missing property "condition"
|
|
|
+ # alias: >-
|
|
|
+ # Listen for motion change, and wait for it to become 'OFF',
|
|
|
+ # wait for the delay and actions to finish, and then send event to kill parallelism.
|
|
|
- alias: "Wait for motion to end."
|
|
|
wait_template: >-
|
|
|
{% set sensors = namespace(triggered=false) %}
|
|
@@ -312,7 +300,7 @@ action:
|
|
|
logger: "{{ scene_name }}"
|
|
|
message: >-
|
|
|
No motion detected by {{ trigger_sensors }}. Run wait actions
|
|
|
- wait {{ (delay_seconds * 1/3)|int }} seconds,, then end
|
|
|
+ wait {{ (delay_seconds * 2/3)|int }} seconds,, then end
|
|
|
automation (parallelism) by issuing an event, and let automation «re-trigger».
|
|
|
|
|
|
- alias: "Run and wait for actions to finish"
|