Reset Time Happens Daily At Timer


#1

1) Give a description of the problem
I have a piston that triggers daily at a time with an offset where both the time and offset are defined in variables. I have a separate piston that may modify the offset. However, when the offset is modified, the timer does not change so the event happens at the original time without the offset. Then when it sets up for the event to trigger the next day it sets it up with the offset.

2) What is the expected behaviour?
The piston is set to trigger at 9pm with 0 minute offset. I modify the offset to -15, then the piston is set to trigger at 8:45pm today.

3) What is happening/not happening?
The piston is set to trigger at 9pm with 0 minute offset. I modify the offset to -15, then the piston is still set to trigger at 9pm. After 9pm the piston is set to trigger the next day at 8:45pm.

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach logs after turning logging level to Full
7/19/2021, 8:44:59 PM +61ms
+0ms ╔Received event [Home].time = 1626741900000 with a delay of -940ms
+45ms ║Runtime (37398 bytes) successfully initialized in 7ms (v0.3.110.20191009) (44ms)
+46ms ║╔Execution stage started
+150ms ║║Executed virtual command iftttMaker (86ms)
+153ms ║║Executed virtual command setVariable (1ms)
+155ms ║╚Execution stage complete. (109ms)
+157ms ║Setting up scheduled job for Mon, Jul 19 2021 @ 9:00:00 PM EDT (in 900.783s)
+164ms ╚Event processed successfully (165ms)
7/18/2021, 8:59:59 PM +82ms
+0ms ╔Received event [Home].time = 1626656400000 with a delay of -919ms
+51ms ║Runtime (37400 bytes) successfully initialized in 9ms (v0.3.110.20191009) (49ms)
+52ms ║╔Execution stage started
+568ms ║║Executed virtual command iftttMaker (98ms)
+576ms ║║Executed virtual command setVariable (3ms)
+580ms ║╚Execution stage complete. (527ms)
+582ms ║Setting up scheduled job for Mon, Jul 19 2021 @ 8:45:00 PM EDT (in 85500.337s)
+598ms ╚Event processed successfully (597ms)


#2

A bit of a hack but you can try to add a couple of statements to pause this piston and resume after a few seconds from the same piston that modifies the offset to force the reread.

I know pistons can subscribe to a global variable but not sure how it works when it’s in the same line as a time trigger.


#3

I think if you add …

If @ClareBedtimeOffset changes
then
endIf

… to the piston it will cause a recalculation of the timer for you, as will anything that makes the piston run after the global variable changes (remember that global variables are cached in pistons so changes are only written on exit, and read when instances start up).

You may even be able to do it by simply moving the reset of the variable to before the ‘if’, however wrong it looks.


#4

I was thinking about this when I went to bed lol, add a subscription for the global var.