Created
December 11, 2021 08:21
-
-
Save breuhan/3299596e288d215ea4a65606f6029b97 to your computer and use it in GitHub Desktop.
This file contains hidden or 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: | |
| name: Adaptive Motion-activated Light | |
| description: Yet Another Motion Automation | |
| domain: automation | |
| source_url: https://gist.github.com/cylonbrain/3299596e288d215ea4a65606f6029b97 | |
| input: | |
| motion_entity: | |
| name: Motion Sensor | |
| selector: | |
| entity: | |
| domain: binary_sensor | |
| device_class: motion | |
| illuminance_entity: | |
| name: Illuminance Sensor | |
| default: | |
| selector: | |
| entity: | |
| domain: sensor | |
| device_class: illuminance | |
| light_target: | |
| name: Light | |
| selector: | |
| target: | |
| entity: | |
| domain: light | |
| motion_scene: | |
| name: Ambient Motion Scene (Optional) | |
| description: Ambient Motion Scene for motion state. Will be activated when motion is detected and condition is on | |
| default: scene.none | |
| selector: | |
| entity: | |
| domain: scene | |
| motion_scene_condition: | |
| name: Ambient Motion Scene Condition (Optional) | |
| description: Ambient Scene condition. | |
| default: | |
| selector: | |
| entity: | |
| domain: binary_sensor | |
| no_motion_scene: | |
| name: Ambient Dark Scene (Optional) | |
| description: Ambient Scene for no motion state. Will be activated when motion is detected and Ambient Dark Scene Condition is on | |
| default: scene.none | |
| selector: | |
| entity: | |
| domain: scene | |
| no_motion_scene_condition: | |
| name: Ambient Dark Scene Condition(Optional) | |
| description: Ambient Scene condition. | |
| default: | |
| selector: | |
| entity: | |
| domain: binary_sensor | |
| enable_below_illuminace: | |
| name: Enable Automation below Illuminace value | |
| description: (OPTIONAL) Only run when Illuminace is below the specified value | |
| default: 100 | |
| selector: | |
| number: | |
| min: 0.0 | |
| max: 1000.0 | |
| step: 10.0 | |
| mode: box | |
| unit_of_measurement: Lux | |
| no_motion_wait: | |
| name: Wait time | |
| description: Time to leave the light on after last motion is detected. | |
| default: 120 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 1000 | |
| unit_of_measurement: seconds | |
| blocker_entity: | |
| name: (OPTIONAL) Blocking entity | |
| description: If this entity's state is on, it will prevent the automation from running. E.g. sleepmode or away mode. | |
| default: | |
| selector: | |
| entity: | |
| time_night_begin: | |
| name: Time for begin of the night brightness | |
| description: A time input which defines the time from which on the brightness is reduced if motion is detected. | |
| default: 00:00:00 | |
| selector: | |
| time: | |
| time_night_end: | |
| name: Time for end of the night brightness | |
| description: A time input which defines the time to which on the scene will | |
| be activated if motion is detected. | |
| default: 00:00:00 | |
| selector: | |
| time: | |
| nighttime_brightness: | |
| name: Nighttime Brightness | |
| description: The brightness to set the light at night (100%) | |
| default: 75 | |
| selector: | |
| number: | |
| min: 1.0 | |
| max: 100.0 | |
| mode: box | |
| unit_of_measurement: '%' | |
| step: 1.0 | |
| off_transition_time: | |
| name: Fade to off seconds | |
| description: Transition time in seconds until light will go dark. | |
| default: 4 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 30 | |
| unit_of_measurement: seconds | |
| variables: | |
| blocker_entity: !input blocker_entity | |
| motion_scene: !input motion_scene | |
| motion_scene_condition: !input motion_scene_condition | |
| no_motion_scene: !input no_motion_scene | |
| no_motion_scene_condition: !input no_motion_scene_condition | |
| illuminance_entity: !input illuminance_entity | |
| enable_below_illuminace: !input enable_below_illuminace | |
| # If motion is detected within the delay, | |
| # we restart the script. | |
| mode: restart | |
| max_exceeded: silent | |
| trigger: | |
| - platform: state | |
| entity_id: !input motion_entity | |
| from: "off" | |
| to: "on" | |
| - platform: state | |
| entity_id: !input motion_entity | |
| from: "on" | |
| to: "off" | |
| for: !input no_motion_wait | |
| condition: | |
| - condition: template | |
| value_template: "{{ (blocker_entity == none) or is_state(blocker_entity, 'off') }}" | |
| action: | |
| - alias: Trigger to state == "on" or "off" | |
| choose: | |
| # Trigger to state = "on" | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ trigger.to_state.state == 'on' }}" | |
| sequence: | |
| - choose: | |
| - conditions: | |
| - "{{ motion_scene != 'scene.none'}}" | |
| - "{{ no_motion_scene_condition != none }}" | |
| - "{{ is_state(no_motion_scene_condition, 'on') }}" | |
| sequence: | |
| - scene: !input 'motion_scene' | |
| #- conditions: | |
| # - condition: template | |
| # value_template: "{{ (illuminance_entity == none) or (states[illuminance_entity].state | float <= enable_below_illuminace) }}" | |
| default: | |
| - choose: | |
| - conditions: | |
| - condition: time | |
| after: !input 'time_night_begin' | |
| before: !input 'time_night_end' | |
| sequence: | |
| - service: light.turn_on | |
| target: !input light_target | |
| data: | |
| brightness_pct: !input 'nighttime_brightness' | |
| default: | |
| - service: light.turn_on | |
| target: !input light_target | |
| # Trigger to state = "off" | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ trigger.to_state.state == 'off' }}" | |
| sequence: | |
| - choose: | |
| - conditions: | |
| - "{{ no_motion_scene != 'scene.none'}}" | |
| - "{{ no_motion_scene_condition != none }}" | |
| - "{{ is_state(no_motion_scene_condition, 'on') }}" | |
| sequence: | |
| - scene: !input 'no_motion_scene' | |
| default: | |
| # If State -> "off" default to turn lights off | |
| - service: light.turn_off | |
| target: !input light_target | |
| data: | |
| transition: !input 'off_transition_time' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment