Why won't my piston trigger? [Offset expression displays incorrect value for any unit other than milliseconds]

fixed
expression

#1

I’m trying to create a piston to write to a variable called “circadiantemperature” that I can use in other pistons to set the temp of my bulbs depending on a circadian pattern. I’ve devised an expression that should allow me to offset the times properly, and it references $sunrise and $sunset, so that as sunrise/sunset times change, the pattern changes proportionately. The expression I’m using is:

(($sunset-$sunrise)/1000000)*0.0825

where I change the multiplier at the end (see my screenshot attached)

The expression output looks good; I’ve set up my piston to Happen At Sunrise with offset “(($sunset-$sunrise)/1000000)*0.0825” seconds, which computes to Sunrise with offset 2000 seconds (or 33 minutes after sunrise)

I have a series of these which are supposed to work at other times, and the expressions all give me a number of seconds that makes sense (2000 seconds, 5000 seconds, 8000 seconds, etc.), but it’s not actually triggering at 2000/5000/8000 seconds after sunrise.

When I look at the Log, it say the next scheduled job is at sunset (4:54 pm). Any idea why the earlier instances aren’t triggering?

Logs
11/9/2017, 10:43:03 AM +967ms
+5ms ╔Starting piston… (v0.2.0fd.20171105)
+236ms ║╔Subscribing to devices…
+355ms ║╚Finished subscribing (123ms)
+812ms ║Setting up scheduled job for Thu, Nov 9 2017 @ 4:54:00 PM AST (in 22255.225s), with 12 more jobs pending
+836ms ╚Piston successfully started (833ms)

Thanks for any insight!


Webcore variable problem bug?
#2

I’m not sure if this is your issue, but you can give it a try…

Time does not include a date. $Sunrise and $Sunset do. Change your condition to Date Time happens daily at…


#3

You’ll want to divide by 1000 rather than 1000000 to account for the milliseconds in $sunset and $sunrise, currently all those events would happen within a few seconds of sunrise.


#4

Even though the expression validates to “Sunrise with offset 2000 seconds”, you’re telling me it’s actually milliseconds?


#5

Something else to consider, you may want to use a timer block instead of the if blocks.


#6

Sorry, I don’t understand what that means… Can you explain what I’m seeing?


#7

you are using

if
happens daily at sunrise

then
do
set variable = blah blah blah
end do
end if

the timer block is:

every day at sunrise
do
set variable - blah blah blah
end every

overall, you will get the same results, the timer block is a little cleaner.


Vacation light help
#8

Wow that is strange, I was just testing in the evaluation console. The expression evaluation shows the wrong value inside this offset field. I tested a piston with a single subscription to see what time it would fall and it does appear that dividing by 1000 is correct despite the evaluation that is displayed.


Random in expression for time only works with milliseconds? Giant numbers for minutes!
#9

ok, I’ll give this a go a little later and report back.


#12

The next release will include a fix for the incorrect display of the evaluation of duration expressions, thanks for reporting!


#13

The incorrect display of the evaluation of duration expressions should be fixed in today’s 0.2.102 update.