Start Action at specific time

Sorry if this has been discussed before, I couldn't find it...

I would like to do the following:

When Trigger fires:
If it's before 9:30 start Action at 9:30.
If its after 9:30 start Action.

You can create a rule that is triggered at 9:30 every day, and that rule could check whatever condition you want. If true, start Action. That may resolve your first requirement.

Okay. Let's say i make a Global Variable to decide if the Rule should run.

Trigger at 9:30.
If Global Variable = 1 Rule should run.
Global Variable changes to 1 at 10:30.

Will the Rule be executed?

Why not use an IF-THEN and an ELSE-IF-THEN statement.
Trigger happens.
IF time between (say) 00:00 and 09:30
THEN
do your stuff.
ELSE-IF time between 09:30 and 00:00
THEN
do different stuff
END-IF.
Would that work for you?

Thanks. This will work.

If you want actions to happen at 9:30, why do you have any condition related to time? If you had this:

Trigger: 9:30 AM
Action:
Turn on light.

The light would turn on at 9:30 am. The rule you listed,

Trigger at 9:30.
If Global Variable = 1 Rule should run.
Global Variable changes to 1 at 10:30.

This would run at 9:30 the day after you first hit 9:30 am and then every day at 9:30 after that because the GV will always be 1 after that. If you are trying to use a GV to limit a rule running, you have to debounce it.

He has a separate trigger that happens when it happens. He wants the actions to happen not earlier than 9:30.

This would work:

IF (Time between 12:00 AM MST and 9:29 AM MST FALSE) Wait for events: When time is 9:30 AM MST
Other Actions

Then the trigger has to be whatever the REAL event is, in addition to the time. The trigger of 9:30am will only fire at 9:30 am. For example, if you are trying to announce at 9:30 am if the front door was opened during the night then also announce when the front door is opened during the day, it would be this:

Trigger: Front door contact changed or 9:30am

If  time between 9:30am- 10:00 pm
       IF PB True
                 Speak door open.
       Else-if contact open
                  Speak door open
        end-if
        set PB false
If time between 10pm and 9:30am
    set private boolean to true.

You get the prize for the most complicated solution.

1 Like

So, this would only work for events between midnight and 9:30 am....do wait's work across the midnight threshold? So, if the rule said time btween 10 pm and 9:30 am would the wait work correctly?

I suppose it all depends on what "before 9:30" means. Use whatever time that fits. The impression I had is that it meant in the morning before 9:30, but the OP didn't specify.

Sure, midnight doesn't mean anything. If you have something scheduled for tomorrow at 9:30 AM, then it's going to happen tomorrow at 9:30 AM.

Okay...so, it's 8:30pm on Wednesday. When you say wait for 9:30 am, it automatically assumes you're waiting from 9:30 am tomorrow? I didn't think the wait would be that smart.

Yes, what else could it mean? It couldn't mean wait until 9:30 AM today, now could it?

It's not wait that is that small, it's the scheduler built-in to the hub.

2 Likes

Here's an explanation of the rule:

We have a sunset transition scene in our bedroom. This should happen at 21:30. But we don't go to our bedroom at the same time every night... A virtual button turns off the lights downstairs and turns our bedroom lights on.

If bedroom lights are turned on before 21:30, wait until 21:30 to start sunset scene.
If bedroom lights are turned on after 21:30, start the sunset scene (after 5 minutes).

I've done it based on the suggestions of @ogiewon and @bobbles:
I've made a Global Variable, SunsetTimer.
When go-to-bed button is pressed:
image

I've made a second trigger at 21:30
image

It's working fine.
(I've translated the Dutch names for clarity)

The solution by @bravenel seems to be the simplest way of doing it. I wasn't aware of the "Wait for events" option. I'll definitely play with that in future.

Thank you all for the help.

EDIT: I see now that I will have to add a Set Global variable to false at the end of the 21:30 trigger :slight_smile: