Stove light on for 2 minutes after motion detected between 10PM and Sunrise

Hi all!
Total noob here transitioning from SmartThings to Home Assistant and my very first go has me stumped.

I have a light over the stove in the kitchen that is normmally off after sunset.
I also have a motion sensor on the fridge.
I would like the stove light to come on if the motion sensor detects motion between 10:00 PM and sunrise every night.
I would like it to stay on for 2 minutes, then turn off again if no motion is detected.
What am I missing here?
Thanks in advance!

alias: Kitchen Motion After 10PM
description: “”
triggers:

  • entity_id:
    • binary_sensor.kitchen_motion_ias_zone
      to: “on”
      trigger: state
      conditions:
  • condition: time
    after: “22:00:00”
  • condition: sun
    before: sunrise
    actions:
  • target:
    entity_id: light.stove_light
    action: light.turn_on
    data: {}
  • delay:
    hours: 0
    minutes: 2
    seconds: 0
  • target:
    entity_id: light.stove_light
    action: light.turn_off
    data: {}
    mode: restart
1 Like

https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

Welcome! :grin:

Please post your code as preformatted text (</> in the cogwheel menu). Spaces at the beginning of each line are critical and simple pasting doesn’t retain them.

Having said that, I suspect the problem may be to do with the conditions. Conditions are always AND, so you’re asking the automation to run if it’s between 10.30pm and midnight, AND if it’s between midnight and sunrise - which can never be true.

Try sun state instead (above or below horizon) instead of sunrise: