123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- blueprint:
- name: Motion active lights
- description: >-
- Motion active lights that respects the illumination in the room.
-
- Turrent light scene will be saved as a new scene so the lights can dim
- to a certain point before turning off. This way it will «alert» someone
- in the room that the light is about to go off.
- Additional criterias can be set in the `after_wait_actions` so you can
- listen for additional sensors to become off, before turning off the lights.
- E.g wait for the humitidy in the bathroom to come down before turning off
- the lights.
- domain: automation
- input:
- trigger_sensors:
- name: Sensors
- description: >-
- Sensors that will trigger the light to turn on. It's
- recommended to select entities explicitly instead of areas
- and/or devices.
- selector:
- target:
- entity:
- domain: binary_sensor
- synced_lights:
- name: Lights
- description: >-
- Lights that will adapt to the motion in the room. It's
- recommended to select entities explicitly instead of areas
- and/or devices.
- selector:
- target:
- entity:
- domain: light
- dim_percentage:
- name: Dim-percentage
- description: >-
- Dim lights to this level (%) of current light level,
- before turning lights off. Current level will be stored
- in a scene. Setting this to 0.0 or 1.0 will skip this action.
- default: 0.3
- selector:
- number:
- max: 1.0
- min: 0.0
- step: 0.01
- after_wait_actions:
- name: Wait actions
- description: >-
- Actions to run to delay further, e.g wait until media player state is off,
- housekeeping mode is off etc.
- default: []
- selector:
- action:
- delay:
- name: Delay
- description: >-
- Time (minutes) to wait to turn off after last movement was detected.
- selector:
- number:
- min: 0.0
- max: 300.0
- step: 5.0
- default: 3
- mode: restart
- trigger_variables:
- trigger_sensors_input: !input trigger_sensors
- trigger_sensors: >-
- {% set sensors = namespace(entities=[]) %}
- {% if 'entity_id' in trigger_sensors_input %}
- {% for entity in ([ trigger_sensors_input['entity_id'] ] if trigger_sensors_input['entity_id'] is string else trigger_sensors_input['entity_id']) %}
- {% set sensors.entities = sensors.entities + [entity] %}
- {% endfor %}
- {% endif %}
- {% if 'area_id' in trigger_sensors_input %}
- {% for area in ([ trigger_sensors_input['area_id'] ] if trigger_sensors_input['area_id'] is string else trigger_sensors_input['area_id']) %}
- {% for entity in area_entities(area) if entity.startswith('binary_sensor.') %}
- {% set sensors.entities = sensors.entities + [entity] %}
- {% endfor %}
- {% endfor %}
- {% endif %}
- {% if 'device_id' in trigger_sensors_input %}
- {% for device in ([ trigger_sensors_input['device_id'] ] if trigger_sensors_input['device_id'] is string else trigger_sensors_input['device_id']) %}
- {% for entity in device_entities(device) if entity.startswith('binary_sensor.') %}
- {% set sensors.entities = sensors.entities + [entity] %}
- {% endfor %}
- {% endfor %}
- {% endif %}
- {{ sensors.entities|unique|list }}
- trigger:
- 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 }}
- variables:
- synced_lights_inputs: !input synced_lights
- synced_lights: >-
- {% set lights = namespace(entities=[]) %}
- {% if 'entity_id' in synced_lights_inputs %}
- {% for entity in ([ synced_lights_inputs['entity_id'] ] if synced_lights_inputs['entity_id'] is string else synced_lights_inputs['entity_id']) %}
- {% set lights.entities = lights.entities + [entity] %}
- {% endfor %}
- {% endif %}
- {% if 'area_id' in synced_lights_inputs %}
- {% for area in ([ synced_lights_inputs['area_id'] ] if synced_lights_inputs['area_id'] is string else synced_lights_inputs['area_id']) %}
- {% for entity in area_entities(area) if entity.startswith('light.') %}
- {% set lights.entities = lights.entities + [entity] %}
- {% endfor %}
- {% endfor %}
- {% endif %}
- {% if 'device_id' in synced_lights_inputs %}
- {% for device in ([ synced_lights_inputs['device_id'] ] if synced_lights_inputs['device_id'] is string else synced_lights_inputs['device_id']) %}
- {% for entity in device_entities(device) if entity.startswith('light.') %}
- {% set lights.entities = lights.entities + [entity] %}
- {% endfor %}
- {% endfor %}
- {% endif %}
- {{ lights.entities|unique|list|sort }}
- scene_name: >-
- {{ this.entity_id.replace('.', '_') }}
- dim_percentage: !input dim_percentage
- delay_minutes: !input delay
- delay_seconds: "{{ delay_minutes * 60 }}"
- log_level: warning
- action: []
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|