Afternoon, just a simple one which I hope some one could advise on please. This is a piston I have created to turn my underfloor heating ON and then OFF when the temperature has been reached. I just wanted to ask, will this work? or would I need an ‘else’ if statement in the middle? I have seen a couple other examples where people are using ‘else if’, also running it every 10mins etc., but I don’t understand webcore coding that well, so I am a bit lost
Your piston should work without the else.
However, my floor heat takes several hours to get to a comfortable level. I could not turn mine on at 5 am and expect it to be warm enough by 7am. Your system may be different.
I think it might be better to use if it falls below and rises above.
I believe it will work as is, but every time there is a temp change it will fire between 5:30 and 8:00 it will send a turn off or turn on command depending on the temp.
If the device is already off or on it will not actually send the command if command optimization is on, which is default, but it will use a little more overhead I would think.
If you use rises above or falls below it will only send the turn off or on as they break the thresholds you set.
… And of course do a “happens everyday at 0530”, if temp is… Then turn on…
To keep everything in sync at the starting point.
I would normally recommend this as well, but not if you are using ONLY WHEN up top.
(plus, the threshold may be crossed outside of times, so it would not fire until the next day)
If you follow @Alwas advice and have a initialize check, which I should have mentioned in my original post, then I still think using rises and drops is a better choice. You also need a do always at 08:00 to turn it back off. With the OPs current example the temps could change outside the time range, so I think a start and stop at the beginning and end of each day is a good idea. Of coarse I might not understand something, which is often the case
Excellent addition, @Terminal…
I use this “three pronged approach” often…
(even though it adds more “
triggers” and code to the piston)
For ease of read, here is everyone’s ideas all rolled up into one piston:
IF Sensor 5's temperature changes <-- Trigger and Time is between 5:30am and 8am <-- Condition Then IF Sensor 5's temp is less than 17 <-- Condition Then Turn on Keypad 1 END IF IF Sensor 5's temp is greater than 19 <-- Condition Then Turn off Keypad 1 END IF END IF Every day at 5:30am <-- Timer IF Sensor 5's temp is less than 17 <-- Condition Then Turn on Keypad 1 END IF END EVERY Every day at 8am <-- Timer Turn off Keypad 1 END EVERY
With regards to SHM, you could add restrictions to the first two blocks, but I would recommend not using any restrictions on the last block.
Thank you very much for everyones valuable input, and special thanks to @WCmore for spelling it out for me, otherwise there was no way I would have been able to implement this piston.
Here is the final version, does this look ok to deploy?
It looks real good, @impee.
One observation though… If Location mode is AWAY before 8am, I am not sure if the last block will execute. (your restriction on line 17 should affect the whole piston)
I would likely only place that extra restriction on the first two blocks, and leave the last block unrestricted to make sure that it turns off every day at 8am.
My apologies. Here is that variation:
IF Sensor 5's temperature drops below 17 <-- Trigger and Time is between 5:30am and 8am <-- Condition Then Turn on Keypad 1 END IF IF Sensor 5's temperature rises above 19 <-- Trigger and Time is between 5:30am and 8am <-- Condition Then Turn off Keypad 1 END IF Every day at 5:30am <-- Timer IF Sensor 5's temp is less than 17 <-- Condition Then Turn on Keypad 1 END IF END EVERY Every day at 8am <-- Timer Turn off Keypad 1 END EVERY
For the end-users, the last two examples are mostly identical. When I want a more “stubborn” piston, I may use my last post. When I want very minimal commands being sent, I’ll often use this method.
In other words, if you have other programming also controlling Keypad 1 during those times, then you’ll likely want to use this type of piston instead. (since it typically only sends two commands per day)
On the other hand, the example we created earlier can be quite persistent.
(and can potentially “take control” many times in that 2.5 hours)
For example, if it’s 15°, and someone manually turns off Keypad 1 at 7am…
- Our earlier piston will turn it back on the next time the temp changed (if before 8:30)
- This piston won’t do anything until it rises, and then drops again
Note: Regardless of which
trigger you use, the piston will execute the same number of times.
(each time a temperature change comes in)