Can scripts be time blocked?

Hello,

Is there a way to time block a script so it can’t be ran during certain times?

I have a few scripts that I’ve turned into buttons on Lovelace. I’ll admit, I’m clumsy and I’ve already lost count of how many times I’ve accidentally hit a wrong button.

I have a few scripts that I would like to prevent from ever being ran during certain times.

For instance, I have a Lovelace button that runs a script to turn on every light in the house to max brightness and color temp. I have a need for this button during the day but if I accidentally hit it at night, nobody in the house would be having a good time (I have over 150 lights).

I searched a lot of threads and was surprised to see there wasn’t even a feature request for this. I’m not sure if that’s because folks don’t have a need or they’re doing it another way.

How about starting the script with a condition like this:

alias: Only Run Scripte between 08:00 and 16:00h
sequence:
  - condition: time
    before: '16:00:00'
    after: '08:00:00'
  - service: light.turn_on
    data: {}
    target:
      entity_id: light.frontdoorlight
mode: single

I did not see that I could do that. Thank you!

In addition to that solution, I protect some of my lovelace buttons with a lock so I have to tap them twice… (in your specific case though time based is the way to go)

That is a good idea also that I did not think about. Thank you. Just making it long press will just avoid the entire situation!