Offset Minutes in Scheduled Events


#1

1) Give a description of the problem
I am attempting to vary the start time of my heating system based on current thermostat temperature reading, my heating setpoint and the heating rate. I have set up my heating set point and rate as global variables, the calculation then takes one from the other and multiplies by 7 (minutes per degree) to figure out how long before the heating needs to switch on to be warm in time for use.

I’ve tried various, set offset as global variable, run a piston to calculate this, then another (a couple of minutes later) to use this. I’ve tried calling the 2nd piston from the first, with and without an argument.

I’m going nuts…

2) What is the expected behaviour?
Heating switch on based on time I want it to be warm minus offset minutes

3) What is happening/not happening?
Sometimes ignores the offset, sometimes I ‘think’ it’s calculating, but using the last calculated offset.

**4) Post a Green Snapshot of the piston
Caller Piston:

Callee Piston:

5) Attach logs after turning logging level to Full
Caller Piston:
12/23/2020, 1:26:59 PM +38ms
+0ms ╔Received event [Casagale].time = 1608730020000 with a delay of -963ms
+51ms ║RunTime Analysis CS > 17ms > PS > 6ms > PE > 29ms > CE
+54ms ║Runtime (38937 bytes) successfully initialized in 6ms (v0.3.110.20191009) (53ms)
+55ms ║╔Execution stage started
+66ms ║║Cancelling statement #27’s schedules…
+73ms ║║Calculating (string) Pre-Poll Offset = + (string) -95 >> (string) Pre-Poll Offset = -95
+79ms ║║Pre-Poll Offset = -95
+80ms ║║Executed virtual command [Cabin Thermostat].log (2ms)
+345ms ║║Executed physical command [Cabin Thermostat].poll() (262ms)
+346ms ║║Executed [Cabin Thermostat].poll (264ms)
+357ms ║║Calculating (decimal) 20.0 - (decimal) 6.5 >> (decimal) 13.5
+362ms ║║Calculating (decimal) 13.5 * (decimal) 7.0 >> (decimal) 94.5
+365ms ║║Calculating (decimal) 0.0 - (decimal) 95.0 >> (decimal) -95.0
+368ms ║║Executed virtual command [Cabin Thermostat].setVariable (1ms)
+374ms ║║Calculating (string) Post-Poll Offset = + (string) -95 >> (string) Post-Poll Offset = -95
+378ms ║║Post-Poll Offset = -95
+379ms ║║Executed virtual command [Cabin Thermostat].log (2ms)
+389ms ║║Executed virtual command [Cabin Thermostat].executePiston (6ms)
+392ms ║╚Execution stage complete. (338ms)
+394ms ║Setting up scheduled job for Thu, Dec 24 2020 @ 1:27:00 PM GMT (in 86400.569s)
+401ms ╚Event processed successfully (401ms)

Callee Piston:
12/23/2020, 1:26:59 PM +467ms
+0ms ╔Received event [Casagale].execute = :d347a3ca7509ba7889e97373b4a092a9: with a delay of 45ms
+64ms ║RunTime Analysis CS > 15ms > PS > 5ms > PE > 43ms > CE
+66ms ║Runtime (47264 bytes) successfully initialized in 5ms (v0.3.110.20191009) (65ms)
+67ms ║╔Execution stage started
+72ms ║║Cancelling statement #32’s schedules…
+78ms ║║Calculating (string) Offset = + (string) -95 >> (string) Offset = -95
+81ms ║║Offset = -95
+82ms ║║Executed virtual command log (1ms)
+92ms ║╚Execution stage complete. (25ms)
+95ms ║Setting up scheduled job for Wed, Dec 23 2020 @ 4:00:00 PM GMT (in 9180.439s), with 3 more jobs pending
+105ms ╚Event processed successfully (105ms)


#2

Sorry, Callee image is wrong, it should be this:


#3

The difficult part of updating an ‘every’ statement is when the piston is executed it restarts the timer before doing anything else. This is why you see it using the lat calculated value instead of the latest. to get around this, you can add an extra call of the piston to get the latest data. Nothing within the every will execute but it will update the timers.


#4

I tried to get around a recalculation of my offset by setting the result of my first piston in a global variable, then calling the global variable in my second. I thought this would work…


#5

If you trigger on the change of the global I think it will work. Add something like:

If @global changes
then
   log "global update"
endif

I think that will trigger the recalculation whenever the global variable changes but you will have to test it.