Temperature and contact closure fan speed controller


I ran into heat problems after putting too many devices in a non-active computer desk enclosure. To help I grabbed some components I had around the house from other projects and purchased a AC fan. The piston design was to reduce or increase fan speed given the temperature inside the enclosure & turn off the fan when the door is open. Enjoy and comment. Thanks!

Parts list:
AC Infinity AXIAL 1225 Quiet Muffin Fan
Samsung SmartThings Multipurpose Sensor
Leviton DZPD3-2BW Decora Smart Plug-in Dimmer



Maybe I am reading this wrong, but it looks like if the door is closed, and the temp changes from (let’s say) 75 to 74, then the fan will come on at low level…
(over-riding line 31)

If you don’t want this, it can be resolved by changing line 79 to say “inside the range of 85 and 90”, and then adding a new condition to the bottom “IF {myTemp} is less than 85, then Turn off


I was thinking the same originally, but the if, then, elseif appears to work with line 31 proving true under 85 degrees and then executing the turn off and not attempting the [if] at line 41. Is your thought that dropping from 84 to 83 would not prove true and then evaluate line 41?

New to webcore piston game so not sure my side.


That’s what I am thinking, yes. The trigger “drops below 85” is only true at the moment 85 drops to 84… Not when 84 drops to 83 etc


Was attempting to keep the ‘shut off’ in one block of code. Updated the piston based upon WCmore comments and ran a full cycle last night when it cools down to 75. Worked as wanted. Thanks for the help.