Timer with expression, when expression get refreshed?

expression
piston
triggers

#1

1) Give a description of the problem
I have a piston with a timer and an expression that tell the time of the day to start the routine… Like: if before sunrise, use sunrise, else sunset (more complex but something like that)… I see the next run time in the dashboard and its like 24h… so the expression seem to not refresh automatically! Looks like it need to run piston first… I have several trigger so it works for now but if nothing get triggered I would like to know if it would work and if it exist a workaround!

(PUT YOUR INFO HERE)2) What is the expected behaviour?
refresh auto

3) What is happening/not happening?
not refresh until next run

4) Post a Green Snapshot of the pistonimage
(UPLOAD YOUR IMAGE HERE)

5) Attach logs after turning logging level to Full
(PASTE YOUR LOGS HERE THEN HIGHLIGHT ALL OF THE LOGS AND CLICK ON THE </> ICON TO FORMAT THEM CORRECTLY)

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

I am not totally clear what you are doing, but pistons are responsible for scheduling their own next execution time and they update it every time they execute. They may be maintaining a whole list of times when they know they need to execute but they only ever have that next one scheduled. That’s actually a potential problem if there is a glitch and the timer event doesn’t happen, so every time any piston runs, and also at regular intervals, a check is made for any piston where a scheduled timer is overdue by 30 seconds or more and if one is found it is sent a ‘recovery’ event just so it can run and schedule a new time.

In order to update timers, a piston needs to not only execute but it needs to evaluate the actual conditions where the timers are used. So if, for example, you have a timer as the second condition in an AND group and the first condition evaluates as false, the piston won’t (as a default) bother to evaluate the second one so doesn’t use it to update timers.

You will often see users writing pistons with an ‘if time happens at 4am daily then do nothing’ block. The actual time varies to taste but the idea is to make sure the piston executes between possible DST adjustments and the first timed event of the day, and also gets a chance to update sunrise/sunset times for the day.

You can adapt that idea to make sure the piston runs at certain times of day.


#3

Hi,
Thanks for reply! I think its because I use the $now variable to set the trigger time… so when it run it know the first (actually the both first time are ok so far but the last one seem not to work, after running the second trigger, its indicate 24h so it looks like it ignore the last one but if the piston is trigger by a on changes trigger, it seems to update and works…

  I use local variable for all 3 time and also those local seem not to be updated but not sure about it! The evaluation section is always right but since I m inside the piste in editing mode I assume that its up to date! I made a post on this but I would like my local variable to show the result so I could see what its taken but I only see the equation beside the variable... here the piston trigger...

here the local:


#4

Few things to ensure you understand:


#5

thanks for your reply! Here what I have after some test and still have some bug… Do you know why the expressions seems not to be updated on time…In the evaluation section in the piston it gives the right things but it execute well few times and then skip some timer events…


#6

I guess you need to show logs of the piston runs and the results of the evaluation to comment.


#7

The log of the timer part do not exist since its not triggering all the time! When it works, it works great so the log lead nowhere! But I continue to make some test and I think that I found something… It looks like the expression inside the timer itself wont update every times… So I made a local variable that is time based. I set this variable to be the time where I want to trigger the timer, so that variable have the expression that need to be updated…

        I just refer this variable inside timer event... For now it seems to work, I ll be sure after few days... If I use an if condition as trigger at specific time, its working but I cant since it run the entire piston and I have some 'timer' (if variable stays x for 2h...) and it reset those on every run...

       Here what I have for now if it could help someone with same issue, I ll mark it as solved as soon as its working for few das...


#8

looks like nothing gets updated except if the complete piston run… I would try to add a block to set the local variable to the expression inside the timer or even better, inside the @report changes event. The report is updated every 15 minutes (only if actual meteo changes). I can add the block inside the last part wich is calculate the time after trigger…so at each trigger it would set the value for the next!


#9

Also are any of the variables being predefined being modified at run time? I would be careful mixing predefine with runtime changes.


#10

I have some predefined but the one I intent to use to change at run time will be not set.


#11

here the result , I just put a time manually to make it run the first time… and then it works fine!

1- timer event fire
2- inside the timer event I set variable to 1
3- inside this event again, if this variable stay 1 for the delay, return variable to 0 and set the variable that is the next time for the timer event