EWhite Posted August 2 Share Posted August 2 many know i have chickens...and yes.. their environment is partly controlled by my Polisy. what i want to do is this...control a fan to come on at a certain temperature and humidity. i am using a variable right now that sets to 1 for temperature on and sets to 2 for humidity on. anything over zero turns fan on... its not very reliable. any ideas? how to turn a fan off and on via 2 separate inputs? thanks! Quote Link to comment
gregkinney Posted August 2 Share Posted August 2 Can't you just use both temperature AND humidity in the if statement? if humidity is > x AND if temperature is > x then turn fan on The program should check the logic in the 'if' even if only one of the pieces has changed value, then if both statements are true, it will execute 'then'. Quote Link to comment
TJF1960 Posted August 2 Share Posted August 2 @gregkinney, respectfully, he will run into a situation where the program will execute the Then/Else with every miniscule change in either temp or humidity. Personally, I do the same thing the OP is doing with variables. Yes, each program changing a variable will run Then/Else with every change in temp. and humid. but its loading effect on the IoX is small and at least its not flooding the powerlines with constant on/off commands (if he is controlling an Insteon switch or whatever). Plus, it has the added benefit of being able to add some hysteresis to the mix. @EWhite, can you post your programs so that we can see what is going on? Also, so I am clear, you want the fan to run if either the temp or humidity is above your threshold, otherwise if both are below the threshold, turn the fan off? And lastly, what is not very reliable, or what are you seeing during the course of operation that is not desirable? -Tim 1 Quote Link to comment
EWhite Posted August 2 Author Share Posted August 2 (edited) yes.. i want fan on when it hits either threshold. yes.. i will try to post all parts of the program. the reliable part is...for some reason..its turning fan of and on every few seconds, and also...if i manually over ride it, the variable keeps setting to 0(which is shut off fan) variable is just a state Chicken Humidity Set - [ID 0047][Parent 0015] If $coop_hum > 65 And $coop_hum > $outside_hum And 'Whitehouse / main' Temperature > 40.0°F Then $chicken_coop = 2 Else Run Program 'Chicken Init Var' (If) Chicken Temperature Set - [ID 004C][Parent 0015] If 'MQTT / ChickCoop1' Temperature > 85.00°F And 'MQTT / ChickCoop1' Temperature < 120.00°F Then $chicken_coop = 1 Else Run Program 'Chicken Init Var' (If) Chicken Fan Control - [ID 0046][Parent 0045] If $chicken_coop > 0 Then Set 'MQTT / ChickCoop3' On Else Set 'MQTT / ChickCoop3' Off Chicken Init Var - [ID 004F][Parent 0045][Not Enabled] If $chicken_coop >= 2 Then Wait 5 minutes and 30 seconds $chicken_coop = 1 Else $chicken_coop = 0 Edited August 2 by EWhite Quote Link to comment
gregkinney Posted August 2 Share Posted August 2 @TJF1960 @EWhite Wouldn't it be much simpler to do it without the variables, and just limit the amount of times the program can run? It looks like there is some logic above based on 5 minutes and 30 seconds, so what if it was: if humidity is > x AND temperature is > x then turn fan on wait 5 minutes and 30 seconds else turn fan off wait 5 minutes and 30 seconds Quote Link to comment
EWhite Posted August 2 Author Share Posted August 2 with that.. it would only work if both temp and humidity are both above threshhold. i want fan on independent of those...plus.. as stated above, each change would trigger program. Quote Link to comment
EWhite Posted August 2 Author Share Posted August 2 i did find one issue...in the humidity program. right now my coop humidity is lower than outside humidity.. so it is running the init var program, which is resetting the var to 0....now how to figure that out.. it might fix the whole thing... Quote Link to comment
gregkinney Posted August 2 Share Posted August 2 PROGRAM 1 If $coop_hum > 65 And $coop_hum > $outside_hum And 'Whitehouse / main' Temperature > 40.0°F And Fan is Off Then Set 'MQTT / ChickCoop3' On Wait 5 minutes and 30 seconds Else Wait 5 minutes and 30 seconds PROGRAM 2 If 'MQTT / ChickCoop1' Temperature > 85.00°F And 'MQTT / ChickCoop1' Temperature < 120.00°F And Fan is Off Then Set 'MQTT / ChickCoop3' On Wait 5 minutes and 30 seconds Else Wait 5 minutes and 30 seconds PROGRAM 3 If Fan is On And 'MQTT / ChickCoop1' Temperature < 85.00°F And $coop_hum < 65 Then Set 'MQTT / ChickCoop3' Off Wait 5 minutes and 30 seconds Else Wait 5 minutes and 30 seconds Quote Link to comment
TJF1960 Posted August 3 Share Posted August 3 @gregkinney, I am not sure if when you posted the programs, if something happened and it got corrupted or something. Having a wait with nothing after it does nothing. Besides that, anytime you have a wait, it will stop and start over anytime the program reevaluates. Like if the temp or humidity values change, even by a decimal point, the program will reevaluate, the fan may never turn off, or on, depending. That is the beauty of using a simple state variable. A program can set a variable to 1 multiple times but a program monitoring the variable will run when the variable changes. @EWhite, did you figure out your program or could you use a little help. If you need help, post them again, including any changes you made. -Tim Quote Link to comment
gregkinney Posted August 3 Share Posted August 3 @TJF1960 I understood wait was like when I write a sleep function in python...it would literally keep the program in the current state until the time passed. Thank you for educating me otherwise. I've got a few programs to go re-write and a lot to learn. @EWhite I'm sorry to have hijacked your post with my ignorance. I hope you get it figured out. Quote Link to comment
EWhite Posted August 3 Author Share Posted August 3 no problem @gregkinney, we are all still learning.. hehe @TJF1960 I have NOT changed anything...i thot I had an idea.. but then i talked myself out of it... my brain is not doing logic well as of late. so.. yes.. i do need help as it is still setting my var to 0 but i cant find the error in programming thats doing it... Quote Link to comment
TJF1960 Posted August 3 Share Posted August 3 @gregkinney, I wish I could trade knowledge with you, I have been banging my head against a brick wall trying to hack some python code together for a node server, lol. @EWhite, my brain is a bit foggy as well, its been a long week but let me give it a go. Quote If $coop_hum > 65 And $coop_hum > $outside_hum And 'Whitehouse / main' Temperature > 40.0°F And $chicken coop = 0 Then $chicken_coop = 2 Else Chicken Temperature Set - [ID 004C][Parent 0015] If 'MQTT / ChickCoop1' Temperature > 85.00°F And 'MQTT / ChickCoop1' Temperature < 120.00°F And $chicken coop = 0 Then $chicken_coop = 1 Else Chicken Fan Control - [ID 0046][Parent 0045] If $chicken_coop >= 1 Then Set 'MQTT / ChickCoop3' On Else Set 'MQTT / ChickCoop3' Off Chicken Init Var - [ID 004F][Parent 0045][Not Enabled] If $chicken_coop = 2 Then Wait 5 minutes and 30 seconds $chicken_coop = 0 Else So, in looking over your programs, I think I understand what you want. It looks to me like if the temp is within range you want the fan to turn on until the temp is out of range. If its too humid, you want the fan to turn on for 5:30 then back off. I kept your same programs, just changed the logic a little bit. The first program sets the var to 2 which turns on program 3 to turn the fan on and at the same time turns on program 4 timing it, at the end of 5:30 the fan will turn off. The second program, when temp is in range, will turn on program 3 only, once program 2 turns false, the fans will turn off. I may have missed something so try at your own risk, but in my hazy state tonight from the long week, I think it should do what you want. -Tim Quote Link to comment
TJF1960 Posted August 3 Share Posted August 3 @EWhite, in thinking about it further, if the fan was turned on and you, for whatever reason, rebooted IoX, the variable after IoX came back up would be at 0, the fan could run forever. Simply mark program 3 to run at startup. That way once IoX reboots the program will run else if the variable is 0 and turn the fan off. Quote Link to comment
EWhite Posted August 3 Author Share Posted August 3 how do i set it to run at startup? thanks! Quote Link to comment
paulbates Posted August 3 Share Posted August 3 Go to the summary tab and right-click on "Run at Startup" 1 Quote Link to comment
EWhite Posted August 3 Author Share Posted August 3 sweet!!.. thanks.. i never knew... Quote Link to comment
DennisC Posted August 3 Share Posted August 3 Another option would be to use this program for the on function only. Write another program using slightly different temperature and humidity settings to turn the fan off. For example a temperature difference of 2 degrees and/or humidity difference of 1% - use whatever numbers you want. 15 hours ago, TJF1960 said: the variable after IoX came back up would be at 0, Not necessarily, you can also set the int variable, which will carry over to the next reboot. When you turn the fan off, remember to set both variables back to 0. Check the ISY Cookbook examples for specifics. 1 Quote Link to comment
EWhite Posted August 6 Author Share Posted August 6 ok.. been running this new set for a few days now....fan never shuts off even tho both temp and humidity are below threshold. the 5minute 30sec thing was just me trying to get the program not to cycle so much...so not needed if the program was right. also.. just to clarify: i want fan on when temp is above threshold and/or when humidity is above threshold. one problem i had previous was one would shut fan off even when the other was above threshold. thats what got me started on the variable, was to try and get them to work together and not against each other. Quote Link to comment
TJF1960 Posted August 6 Share Posted August 6 @EWhite, Please post your current programs. -Tim Quote Link to comment
TJF1960 Posted August 7 Share Posted August 7 @EWhite, giving it some thought, I think you can simplify since you don't need the 5:30 wait. Try this at your own risk, I think this will work. Quote Chicken Temp/Humid Set If Or( And $coop_hum > 65 And $coop_hum > $outside_hum And 'Whitehouse / main' Temperature > 40.0°F ) Or( And 'MQTT / ChickCoop1' Temperature > 85.00°F And 'MQTT / ChickCoop1' Temperature < 120.00°F ) Then $chicken_coop = 1 Else $chicken_coop = 0 *************************** Pgm 2: Chicken Fan Control - [ID 0046][Parent 0045] If $chicken_coop = 1 Then Wait 1 minute Set 'MQTT / ChickCoop3' On Else Wait 5 Minute Set 'MQTT / ChickCoop3' Off *************************** Wait times = to account for hysteresis of temp and humidity. Enable run at startup for program "Chicken Fan Control" Quote Link to comment
EWhite Posted August 20 Author Share Posted August 20 well ... thanks for the help on all this.. i took advice and combined what i had with new ideas and come up with this: added new variables, one each for temp and humid. this seems to make more sense and so far it works.. please critique and point out flaws if any. Thanks! Chicken Humidity Set - [ID 0047][Parent 0045] If $coop_hum > 65 And $coop_hum > $outside_hum And 'Whitehouse / main' Temperature > 40.0°F Then $coop_humid_var = 1 Else $coop_humid_var = 0 Chicken Temperature Set - [ID 004C][Parent 0045] If 'MQTT / ChickCoop1' Temperature >= 85.00°F Then $coop_temp_var = 1 Else $coop_temp_var = 0 Chicken Fan Control - [ID 0046][Parent 0045][Run At Startup] If $coop_humid_var is 1 Or $coop_temp_var is 1 Then Set 'MQTT / ChickCoop3' On Else Set 'MQTT / ChickCoop3' Off as you can see... i simplified it way down from what i had originally. so far it seems to be working as expected. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.