Motion_light + input_datetime

blueprint:
  name: Czujnik ruchu Warsztat
  domain: automation
  source_url: https://github.com/home-assistant/core/blob/71af0fac1644821b9303815b680914b9eeca444d/homeassistant/components/automation/blueprints/motion_light.yaml
  input:
    motion_entity:
      name: Czujnik ruchu
      selector:
        entity:
          domain: binary_sensor
          device_class: motion
    light_target:
      name: Light
      selector:
        target:
          entity:
            domain: light
    no_motion_wait:
      name: Wait time
      description: Time to wait until the light should be turned off.
      default: 5
      selector:
        number:
          min: 0
          max: 3600
          unit_of_measurement: seconds
    time_limit_before:
      name: Uruchom tylko przed czasem.
      description:  Automatyzacja będzie działać tylko wtedy, gdy czas będzie wcześniejszy niż ta wartość
      default: 07:30:00
      selector:
        entity:
          domain: input_datetime
    time_limit_after:
      name: Uruchom tylko po czasie.
      description: Automatyzacja będzie działać tylko wtedy, gdy czas będzie późniejszy niż ta wartość
      default: '15:30:00'
      selector:
        entity:
          domain: input_datetime
# If motion is detected within the delay,
# we restart the script.
mode: restart
max_exceeded: silent

variables:

  time_limit_before: !input time_limit_before
  time_limit_after: !input time_limit_after

trigger:
  platform: state
  entity_id: !input motion_entity
  from: "off"
  to: "on"
condition:
  - condition: and
    conditions:
    - condition: time
      after: !input time_limit_after
      before: !input time_limit_before

action:
  - service: light.turn_on
    target: !input light_target
  - 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
2 Likes

If only I found this earlier! Would’ve saved so much pain and suffering from creating something extremely similar.

Useful for households with pets that can trigger the motion sensor at night!

The blueprint is great! I’ve added an “illuminance”-check. Now I’m looking for an improvement to have different actions over the day (e.g. 7:30 to 22:00) and a second action over night, i.e. the remaining time between 22:01 to 7:29).
It is possible to bring this in one Blueprint?
Thank you