Automation running until sun.sun is above_horizon

I see this in my log:

Script script.anti_thief_light already running.

I see this now, then i am using script.turn_off

AttributeError: 'NoneType' object has no attribute 'is_on'

you probably have the wrong spelling for the script in your turn off service.

- service: script.turn_off
  entity_id:
  - script.anti_thief_light

The scripts is

  anti_thief_light:
    sequence:
      - delay:
          seconds: 10
      - service: switch.turn_on

My script runs now, but the script.turn_off does NOT stop the script then i am home again, if i then leave my house, the script does not run from start again, its in a delay that i put in my script, so its stuck until the delay is over, howto fix this?

Please post your code as it stands now. You’re asking us to do a lot of guessing about what exactly you have.

EDIT: I mean please don’t just post snippets. Post the entire automations, scripts, configuration, etc. that’s related to this topic.

Hi
The script and automation is working.

The only issue i got is then the script is running, after 1 minute in the automation, the script will try to run, but it cannot, because its already running.

How can i minimize this?

Some solutions, but not good solution is to change the interval from 1 minute to x minutes, as long the scripts are running, but the bad thing about this, is that the script will first run after x minutes again.

As I said before, please post all the related code. We can’t be expected to remember all your details, or guess at what you might have done.

I did some changes about this anti thief light automation.

Simple actually, i created a automation that turn the script on then below_horizon and turned it off then above_horizon, no time_pattern needed.