First automation beginner

In the future, please paste your automation to the post with proper formatting so we do not have to re-type it.

As you have it currently, your conditions are not limiting your automation in any way… it will execute every time motion is detected. To explain:

before: sunset
before_offset: '00:30:00'

The above clause makes the condition true from just after midnight until 30 minutes past sunset. This effectively makes the sunrise condition pointless.

after: sunset

The above clause makes the condition true from sunset until midnight.

The combined effect is that it is true from midnight until the next midnight…

To limit your automation so that it will only execute in the hours 30 minutes after sunset until sunrise you use the following condition:

condition:
  condition: or
  conditions:
    - condition: sun
      after: sunset
      after_offset: '00:30:00'
    - condition: sun
      before: sunrise