Using Wait in a timer


#1

1) Give a description of the problem
I created a small piston that writes energy usage data to a thingspeak account. It works great and have been using it for a few weeks now.
I decided to make a small update. I added a second data write for energy cost. This piston runs every hour at 30 past the hour. I have seen this same failure behavior in a another piston that runs at the same time every day. I basically tried to do the same thing. I moved to this piston since it runs more often so I could watch what was happening.

2) What is the expected behaviour?
I just added a 15 second wait after the first HTTP Get because with my thingspeak account you can only write data every 15 seconds. So I assumed it would wait 15 seconds and then complete the piston

3) What is happening/not happening?
What happens is the piston starts running every 15 seconds. I assume the wait is changing the run every time. Is this expected behavior? If so, is there a way I can put in a delay or do I need to use 2 separate timers?

**4) Post a Green Snapshot of the piston!

5) Attach logs after turning logging level to Full
By the time I caught what was happening it had written a lot of data to the log and I get get back to the point it started.

[edit]Just before posting this I did one last search and found this post. So I guess using a a wait is not going to work. I see a few ways to get around this but I thought I would ask what others might do.


#2

take a look at this… maybe it works


#3

I originally had the TCP set to never and figured that is what was causing it, so I changed it to the default with same result.

Probably should have mentioned that.


#4

The timed triggers (‘every …’) are a little unusual in that they trigger just the ‘every’ block and I believe run it asyncronously. So I don’t know how they interact with ‘wait’. The normal behaviour of a ‘wait’ over about five seconds is to schedule a new run and exit, and when they wake start at the top of the piston and ‘fast forward’ to after the wait. What does that do with an ‘every’? Then there is the TCP to consider. It would be interesting to know what does happen, but being interesting doesn’t help you much.


#5

Whenever there is a WAIT inside a “Every hour at X” block, I never fiddle with TCP. Even left at default, it runs that entire block, and then stops.

That being said, if thingspeak has a 15 second limitation, then I would increase your WAIT to at least 20 seconds… (and turn logging level to Full for proper diagnose)