blueprint: name: Motion activated scene description: Activates different scenes for daytime/nighttime on detecting motion and returns to an off-scene after a configurable timeout or exceeded illuminace threshold. source_url: https://git.klelifo.de/projects/homeassistant/raw/branch/main/blueprints/motion_activated_scene.yaml domain: automation author: Florian Klemenz input: motion_section: name: "Motion" #icon: mdi:window-shutter-cog description: Configure motion activation input: motion_sensors: name: Motion/Presence/Occupancy Sensors selector: entity: multiple: true filter: - domain: binary_sensor device_class: motion - domain: binary_sensor device_class: occupancy - domain: binary_sensor device_class: presence no_motion_wait: name: Wait time description: Time to leave the scene on after last motion is detected. default: 120 selector: number: min: 0 max: 300 unit_of_measurement: seconds illuminance_section: name: "Illuminance" #icon: mdi:window-shutter-cog description: Configure illuminance override input: illuminance_sensors: name: Illuminance sensors description: The illuminance sensor to get lux data. selector: entity: multiple: true filter: domain: sensor device_class: illuminance illuminance_cutoff: name: Illuminance threshold description: Lux above this threshold will activate the "off" scene. default: 10 selector: number: min: 0 max: 100 unit_of_measurement: lx humidity_section: name: "Humidity" #icon: mdi:window-shutter-cog description: Configure humidity override (optional) input: humidity_sensors: name: Humidity sensors description: The humidity sensor for shower detection. default: [] selector: entity: multiple: true filter: domain: sensor device_class: humidity humidity_threshold: name: Humidity threshold description: Humidity above this threshold will activate the "on" scene. default: 75 selector: number: min: 50 max: 90 unit_of_measurement: '%' scene_section: name: "Scene configuration" #icon: mdi:window-shutter-cog description: Configure times of day schedule and scenes input: daytime_trigger: name: Daytime description: Binary sensor (TimeOfDay) or schedule to indicate when it is daytime selector: entity: filter: - integration: tod domain: binary_sensor - domain: schedule daytime_scene: name: Daytime scene selector: entity: filter: domain: scene nighttime_scene: name: Nighttime scene selector: entity: filter: domain: scene off_scene: name: Off scene selector: entity: filter: domain: scene # If motion is detected within the delay, # we restart the script. mode: restart max_exceeded: silent ################################################################################ # TRIGGER VARIABLES # Everything defined here can be used inside Jinja code in triggers ################################################################################ trigger_variables: humidity_sensors: !input humidity_sensors humidity_threshold: !input humidity_threshold ################################################################################ # VARIABLES ################################################################################ variables: version: "2026.06.1" #blind_entities: "{{ expand(blind) | map(attribute='entity_id') | list }}" ################################################################################ # TRIGGERS ################################################################################ triggers: # Trigger when motion is detected by any of the defined motion sensors - trigger: state entity_id: !input motion_sensors from: "off" to: "on" - trigger: template value_template: > {{ expand(humidity_sensors) | selectattr('state', 'gt', humidity_threshold) | list | count == 1 }} #- trigger: numeric_state # entity_id: !input humidity_sensors # above: {{ states(humidity_threshold) | float }} # - trigger: template # value_template: > # {{ expand('binary_sensor.window1', 'binary_sensor.window2', # 'binary_sensor.window3', 'binary_sensor.window4') # | selectattr('state', 'eq', 'on') | list | count == 4 }} ################################################################################ # ACTIONS ################################################################################ actions: - choose: # "Activate off-scene if illuminance is above threshold" - conditions: - condition: numeric_state entity_id: !input illuminance_sensors above: !input illuminance_cutoff sequence: - service: scene.turn_on target: entity_id: !input off_scene - conditions: [] sequence: # "Activate day-/-night scene depending on time of day" - choose: - conditions: - condition: state alias: "Check for daytime" entity_id: !input daytime_trigger state: 'on' sequence: - service: scene.turn_on target: entity_id: !input daytime_scene - conditions: [] sequence: - service: scene.turn_on target: entity_id: !input nighttime_scene - alias: "Wait until there is no motion from device" wait_for_trigger: platform: state entity_id: !input motion_sensors from: "on" to: "off" # "If not restarted because of any motion the light is turned off after the delay" - alias: "Wait the number of seconds that has been set" delay: !input no_motion_wait - alias: "Activate off scene" service: scene.turn_on target: entity_id: !input off_scene