Enabled Pump based on motion detection between 6am and 23.30

Hello Guys!

I’m trying to create an automation to enable a pump for 3 minutes if motion is detected on a sensor and the time is between 6am and 23.30.

For some reason I fail to set it up the right way.
Can you please advise ?
Here is the sample I’ve created:

- id: '1648667920315'
  alias: Turn Off Pump (Duplicate) TEst
  description: ''
  trigger:
  - entity_id: binary_sensor.mozgas_iroda
    platform: state
    to: 'on'
  condition:
  - after: '00:06:00'
    before: '23:30:00'
    condition: time
  action:
  - data:
      type: turn_on
      entity_id: switch.smart_switch_7
      device_id: 44f07b44afec5f0a6029eddecd0e4ccb
      domain: switch
  - timeout: 00:03:00
    wait_template: ''
  - data:
      type: turn_off
      entity_id: switch.smart_switch_7
      device_id: 44f07b44afec5f0a6029eddecd0e4ccb
      domain: switch
    mode: single  

Did you manually write that or use the UI?

Does this help?
It is for detection of motion between 22:00 and 06:00 and send an alert with a snapshot.
It should be easy to adept :wink:

alias: Send a doorcam snapshot on movement 
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.frontdoormotion_sensor
    from: 'off'
    to: 'on'
condition:
  - condition: time
    after: '22:00'
    before: '06:00'
action:
  - service: camera.snapshot
    data:
      filename: /config/www/tmp/snapshot_doorcam.jpg
    target:
      entity_id: camera.doorcam
  - service: notify.mobile_app_aceindy
    data:
      message: Frontdoor Motion Detected
      title: Alert
      data:
        push:
          sound:
            critical: 1
            name: default
            volume: 1
        attachment:
          url: /local/tmp/snapshot_doorcam.jpg
          content_type: JPEG
mode: single

Thanks will try to adopt it.