Skip to content

Instantly share code, notes, and snippets.

@quallenbezwinger
Last active January 11, 2025 16:33
Show Gist options
  • Select an option

  • Save quallenbezwinger/3e5c23acb05fb639bafdc5036b91aae6 to your computer and use it in GitHub Desktop.

Select an option

Save quallenbezwinger/3e5c23acb05fb639bafdc5036b91aae6 to your computer and use it in GitHub Desktop.

Revisions

  1. quallenbezwinger revised this gist Dec 17, 2020. 1 changed file with 6 additions and 14 deletions.
    20 changes: 6 additions & 14 deletions motion_controlled_scenes_enhanced.yaml
    Original file line number Diff line number Diff line change
    @@ -51,7 +51,7 @@ blueprint:
    selector:
    time:
    scene_morning:
    name: Scene for the morning (Optional)
    name: Scene for the morning
    default: scene.none
    selector:
    entity:
    @@ -63,7 +63,7 @@ blueprint:
    selector:
    time:
    scene_day:
    name: Scene for the bright day (Optional)
    name: Scene for the bright day
    default: scene.none
    selector:
    entity:
    @@ -75,7 +75,7 @@ blueprint:
    selector:
    time:
    scene_evening:
    name: Scene for the evening (Optional)
    name: Scene for the evening
    default: scene.none
    selector:
    entity:
    @@ -87,7 +87,7 @@ blueprint:
    selector:
    time:
    scene_night:
    name: Scene for the dark night (Optional)
    name: Scene for the dark night
    default: scene.none
    selector:
    entity:
    @@ -113,20 +113,15 @@ max_exceeded: silent

    variables:
    scene_ambient: !input scene_ambient
    scene_morning: !input scene_morning
    scene_day: !input scene_day
    scene_evening: !input scene_evening
    scene_night: !input scene_night
    trigger:
    platform: state
    entity_id: !input motion_entity
    from: "off"
    to: "on"

    ## condition for illumination has to be checked for every scece and not global. reason: action should be also triggered if no lights should be enabled to switch off ambient scene if it is to bright
    action:
    - choose:
    - conditions:
    - "{{ scene_morning != 'scene.none'}}"
    - condition: time
    after: !input time_scene_morning
    before: !input time_scene_day
    @@ -136,7 +131,6 @@ action:
    sequence:
    - scene: !input scene_morning
    - conditions:
    - "{{ scene_day != 'scene.none'}}"
    - condition: time
    after: !input time_scene_day
    before: !input time_scene_evening
    @@ -146,7 +140,6 @@ action:
    sequence:
    - scene: !input scene_day
    - conditions:
    - "{{ scene_evening != 'scene.none'}}"
    - condition: time
    after: !input time_scene_evening
    before: !input time_scene_night
    @@ -156,7 +149,6 @@ action:
    sequence:
    - scene: !input scene_evening
    - conditions:
    - "{{ scene_night != 'scene.none'}}"
    - condition: time
    after: !input time_scene_night
    before: !input time_scene_morning
    @@ -184,4 +176,4 @@ action:
    - scene: !input scene_ambient
    default:
    - service: light.turn_off
    target: !input light_target
    target: !input light_target
  2. quallenbezwinger revised this gist Dec 16, 2020. No changes.
  3. quallenbezwinger revised this gist Dec 16, 2020. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions motion_controlled_scenes_enhanced.yaml
    Original file line number Diff line number Diff line change
    @@ -126,7 +126,7 @@ trigger:
    action:
    - choose:
    - conditions:
    - "{{ scene_morning != scene.none}}"
    - "{{ scene_morning != 'scene.none'}}"
    - condition: time
    after: !input time_scene_morning
    before: !input time_scene_day
    @@ -136,7 +136,7 @@ action:
    sequence:
    - scene: !input scene_morning
    - conditions:
    - "{{ scene_day != scene.none}}"
    - "{{ scene_day != 'scene.none'}}"
    - condition: time
    after: !input time_scene_day
    before: !input time_scene_evening
    @@ -146,7 +146,7 @@ action:
    sequence:
    - scene: !input scene_day
    - conditions:
    - "{{ scene_evening != scene.none}}"
    - "{{ scene_evening != 'scene.none'}}"
    - condition: time
    after: !input time_scene_evening
    before: !input time_scene_night
    @@ -156,7 +156,7 @@ action:
    sequence:
    - scene: !input scene_evening
    - conditions:
    - "{{ scene_night != scene.none}}"
    - "{{ scene_night != 'scene.none'}}"
    - condition: time
    after: !input time_scene_night
    before: !input time_scene_morning
    @@ -173,7 +173,7 @@ action:
    - delay: !input no_motion_wait
    - choose:
    - conditions:
    - "{{ scene_ambient != scene.none}}"
    - "{{ scene_ambient != 'scene.none'}}"
    - condition: time
    after: !input time_scene_ambient_start
    before: !input time_scene_ambient_end
  4. quallenbezwinger revised this gist Dec 16, 2020. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions motion_controlled_scenes_enhanced.yaml
    Original file line number Diff line number Diff line change
    @@ -126,7 +126,7 @@ trigger:
    action:
    - choose:
    - conditions:
    - "{{ scene_morning != None}}"
    - "{{ scene_morning != scene.none}}"
    - condition: time
    after: !input time_scene_morning
    before: !input time_scene_day
    @@ -136,7 +136,7 @@ action:
    sequence:
    - scene: !input scene_morning
    - conditions:
    - "{{ scene_day != None}}"
    - "{{ scene_day != scene.none}}"
    - condition: time
    after: !input time_scene_day
    before: !input time_scene_evening
    @@ -146,7 +146,7 @@ action:
    sequence:
    - scene: !input scene_day
    - conditions:
    - "{{ scene_evening != None}}"
    - "{{ scene_evening != scene.none}}"
    - condition: time
    after: !input time_scene_evening
    before: !input time_scene_night
    @@ -156,7 +156,7 @@ action:
    sequence:
    - scene: !input scene_evening
    - conditions:
    - "{{ scene_night != None}}"
    - "{{ scene_night != scene.none}}"
    - condition: time
    after: !input time_scene_night
    before: !input time_scene_morning
    @@ -184,4 +184,4 @@ action:
    - scene: !input scene_ambient
    default:
    - service: light.turn_off
    target: !input light_target
    target: !input light_target
  5. quallenbezwinger revised this gist Dec 16, 2020. 1 changed file with 45 additions and 19 deletions.
    64 changes: 45 additions & 19 deletions motion_controlled_scenes_enhanced.yaml
    Original file line number Diff line number Diff line change
    @@ -31,55 +31,71 @@ blueprint:
    target:
    entity:
    domain: light
    scene_ambient_enabled:
    name: Enable Ambient Scene
    description: Enable scene for ambient state. Will be activated when no motion is detected and light level is under threshold.
    selector:
    boolean:
    scene_ambient:
    name: Ambient Scene
    description: Scene for ambient state. Will be activated when no motion is detected and light level is under threshold.
    name: Ambient Scene (Optional)
    description: Scene for ambient state. Will be activated when no motion is detected and light level is under threshold. Default value = scene.none
    default: scene.none
    selector:
    entity:
    domain: scene
    time_scene_ambient_start:
    name: Ambient time frame start
    description: Time from which on ambient scene will be activated
    default: "00:00:00"
    selector:
    time:
    time_scene_ambient_end:
    name: Ambient time frame end
    description: Time from which on ambient scene will be not activated
    default: "00:00:00"
    selector:
    time:
    scene_morning:
    name: Scene for the morning
    name: Scene for the morning (Optional)
    default: scene.none
    selector:
    entity:
    domain: scene
    time_scene_morning:
    name: Time for the morning scene
    description: A time input which defines the time from which on the scene will be activated if motion is detected
    description: A time input which defines the time from which on the scene will be activated if motion is detected. Default value = scene.none
    default: "00:00:00"
    selector:
    time:
    scene_day:
    name: Scene for the bright day
    name: Scene for the bright day (Optional)
    default: scene.none
    selector:
    entity:
    domain: scene
    time_scene_day:
    name: Time for the day scene
    description: A time input which defines the time from which on the scene will be activated if motion is detected
    description: A time input which defines the time from which on the scene will be activated if motion is detected. Default value = scene.none
    default: "00:00:00"
    selector:
    time:
    scene_evening:
    name: Scene for the evening
    name: Scene for the evening (Optional)
    default: scene.none
    selector:
    entity:
    domain: scene
    time_scene_evening:
    name: Time for the evening scene
    description: A time input which defines the time from which on the scene will be activated if motion is detected
    description: A time input which defines the time from which on the scene will be activated if motion is detected. Default value = scene.none
    default: "00:00:00"
    selector:
    time:
    scene_night:
    name: Scene for the dark night
    name: Scene for the dark night (Optional)
    default: scene.none
    selector:
    entity:
    domain: scene
    time_scene_night:
    name: Time for the night scene
    description: A time input which defines the time from which on the scene will be activated if motion is detectedd
    description: A time input which defines the time from which on the scene will be activated if motion is detectedd. Default value = scene.none
    default: "00:00:00"
    selector:
    time:
    no_motion_wait:
    @@ -96,8 +112,11 @@ mode: restart
    max_exceeded: silent

    variables:
    scene_ambient_enabled: !input scene_ambient_enabled

    scene_ambient: !input scene_ambient
    scene_morning: !input scene_morning
    scene_day: !input scene_day
    scene_evening: !input scene_evening
    scene_night: !input scene_night
    trigger:
    platform: state
    entity_id: !input motion_entity
    @@ -107,6 +126,7 @@ trigger:
    action:
    - choose:
    - conditions:
    - "{{ scene_morning != None}}"
    - condition: time
    after: !input time_scene_morning
    before: !input time_scene_day
    @@ -116,6 +136,7 @@ action:
    sequence:
    - scene: !input scene_morning
    - conditions:
    - "{{ scene_day != None}}"
    - condition: time
    after: !input time_scene_day
    before: !input time_scene_evening
    @@ -125,6 +146,7 @@ action:
    sequence:
    - scene: !input scene_day
    - conditions:
    - "{{ scene_evening != None}}"
    - condition: time
    after: !input time_scene_evening
    before: !input time_scene_night
    @@ -134,6 +156,7 @@ action:
    sequence:
    - scene: !input scene_evening
    - conditions:
    - "{{ scene_night != None}}"
    - condition: time
    after: !input time_scene_night
    before: !input time_scene_morning
    @@ -150,12 +173,15 @@ action:
    - delay: !input no_motion_wait
    - choose:
    - conditions:
    - "{{ scene_ambient_enabled }}"
    - "{{ scene_ambient != scene.none}}"
    - condition: time
    after: !input time_scene_ambient_start
    before: !input time_scene_ambient_end
    - condition: numeric_state
    entity_id: !input lightsensor_entity
    below: !input illuminace_level
    sequence:
    - scene: !input scene_ambient
    default:
    - service: light.turn_off
    target: !input light_target
    target: !input light_target
  6. quallenbezwinger revised this gist Dec 16, 2020. 1 changed file with 26 additions and 3 deletions.
    29 changes: 26 additions & 3 deletions motion_controlled_scenes_enhanced.yaml
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    blueprint:
    name: Motion-activated light scene with surrounding light level check
    name: Motion-activated light scene with surrounding light level check and optional ambient scene
    description: Turn on a light scene when motion is detected. Three different scenes can be defined depending on time of day. Furthermore a source for checking sourrounding light can be defined to enable light only if it is dark enough.
    domain: automation
    source_url: https://gist.github.com/dirkk1980/3e5c23acb05fb639bafdc5036b91aae6
    @@ -31,6 +31,17 @@ blueprint:
    target:
    entity:
    domain: light
    scene_ambient_enabled:
    name: Enable Ambient Scene
    description: Enable scene for ambient state. Will be activated when no motion is detected and light level is under threshold.
    selector:
    boolean:
    scene_ambient:
    name: Ambient Scene
    description: Scene for ambient state. Will be activated when no motion is detected and light level is under threshold.
    selector:
    entity:
    domain: scene
    scene_morning:
    name: Scene for the morning
    selector:
    @@ -84,6 +95,9 @@ blueprint:
    mode: restart
    max_exceeded: silent

    variables:
    scene_ambient_enabled: !input scene_ambient_enabled

    trigger:
    platform: state
    entity_id: !input motion_entity
    @@ -134,5 +148,14 @@ action:
    from: "on"
    to: "off"
    - delay: !input no_motion_wait
    - service: light.turn_off
    target: !input light_target
    - choose:
    - conditions:
    - "{{ scene_ambient_enabled }}"
    - condition: numeric_state
    entity_id: !input lightsensor_entity
    below: !input illuminace_level
    sequence:
    - scene: !input scene_ambient
    default:
    - service: light.turn_off
    target: !input light_target
  7. quallenbezwinger revised this gist Dec 16, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion motion_controlled_scenes_enhanced.yaml
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ blueprint:
    name: Motion-activated light scene with surrounding light level check
    description: Turn on a light scene when motion is detected. Three different scenes can be defined depending on time of day. Furthermore a source for checking sourrounding light can be defined to enable light only if it is dark enough.
    domain: automation
    source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/motion_light.yaml
    source_url: https://gist.github.com/dirkk1980/3e5c23acb05fb639bafdc5036b91aae6
    input:
    motion_entity:
    name: Motion Sensor
  8. quallenbezwinger created this gist Dec 15, 2020.
    138 changes: 138 additions & 0 deletions motion_controlled_scenes_enhanced.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,138 @@
    blueprint:
    name: Motion-activated light scene with surrounding light level check
    description: Turn on a light scene when motion is detected. Three different scenes can be defined depending on time of day. Furthermore a source for checking sourrounding light can be defined to enable light only if it is dark enough.
    domain: automation
    source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/motion_light.yaml
    input:
    motion_entity:
    name: Motion Sensor
    selector:
    entity:
    domain: binary_sensor
    device_class: motion
    lightsensor_entity:
    name: Illuminance Sensor
    selector:
    entity:
    domain: sensor
    device_class: illuminance
    illuminace_level:
    name: Max Illuminance
    description: Maximal immuminance level in lux. If illuminance is higher, light will not be enabled
    default: 600
    selector:
    number:
    min: 0
    max: 5000
    unit_of_measurement: lux
    light_target:
    name: Light
    selector:
    target:
    entity:
    domain: light
    scene_morning:
    name: Scene for the morning
    selector:
    entity:
    domain: scene
    time_scene_morning:
    name: Time for the morning scene
    description: A time input which defines the time from which on the scene will be activated if motion is detected
    selector:
    time:
    scene_day:
    name: Scene for the bright day
    selector:
    entity:
    domain: scene
    time_scene_day:
    name: Time for the day scene
    description: A time input which defines the time from which on the scene will be activated if motion is detected
    selector:
    time:
    scene_evening:
    name: Scene for the evening
    selector:
    entity:
    domain: scene
    time_scene_evening:
    name: Time for the evening scene
    description: A time input which defines the time from which on the scene will be activated if motion is detected
    selector:
    time:
    scene_night:
    name: Scene for the dark night
    selector:
    entity:
    domain: scene
    time_scene_night:
    name: Time for the night scene
    description: A time input which defines the time from which on the scene will be activated if motion is detectedd
    selector:
    time:
    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: 3600
    unit_of_measurement: seconds

    mode: restart
    max_exceeded: silent

    trigger:
    platform: state
    entity_id: !input motion_entity
    from: "off"
    to: "on"

    action:
    - choose:
    - conditions:
    - condition: time
    after: !input time_scene_morning
    before: !input time_scene_day
    - condition: numeric_state
    entity_id: !input lightsensor_entity
    below: !input illuminace_level
    sequence:
    - scene: !input scene_morning
    - conditions:
    - condition: time
    after: !input time_scene_day
    before: !input time_scene_evening
    - condition: numeric_state
    entity_id: !input lightsensor_entity
    below: !input illuminace_level
    sequence:
    - scene: !input scene_day
    - conditions:
    - condition: time
    after: !input time_scene_evening
    before: !input time_scene_night
    - condition: numeric_state
    entity_id: !input lightsensor_entity
    below: !input illuminace_level
    sequence:
    - scene: !input scene_evening
    - conditions:
    - condition: time
    after: !input time_scene_night
    before: !input time_scene_morning
    - condition: numeric_state
    entity_id: !input lightsensor_entity
    below: !input illuminace_level
    sequence:
    - scene: !input scene_night
    - wait_for_trigger:
    platform: state
    entity_id: !input motion_entity
    from: "on"
    to: "off"
    - delay: !input no_motion_wait
    - service: light.turn_off
    target: !input light_target