From: Jeff S. <ne...@si...> - 2009-06-04 02:25:35
|
> Your comments about local rainfall measurement make a lot of sense. It > also makes me wonder about using ETzero values from distant ( > 5km) > locations, and whether ET is worrying about at all. > > It would be great if you could post your code. Maybe I could steal > some bits.... > > Andy. Andy, Here's some info about my config. I store the "dryness" factor as a generic object so it survives reboots and can be viewed/manipulated from the web interface. Here's the line from my .mht file which creates it: GENERIC, Dryness, Irrigation|House Here's a sample of an irrigation control: # Turn on the South lawn sprinklers at 12:01 AM for 40 minutes every Wednesday between # May 1 (month 5) and September 30 (month 9) when $Automatically_Water is set. # Also turn on the water when manually triggered. if (((time_cron '1 0 * 5-9 3') && (state $Automatically_Water eq ON)) || (state_now $Front_Yard_South_Lawn_Macro eq ON)) { set_with_timer $Front_Yard_South_Lawn_AM (ON, (40 * 60 * (state $Dryness))); print_log "Front Yard South Lawn: Started watering for " . state $Dryness . " * 40 minutes..."; } The script for calculating the dryness is attached in it's entirety below. Unfortunately text wrapping may mess it up but hopefully you get the idea. Let me know if you have any questions. Jeff ---------- #!/usr/bin/perl -w # Irrigation-jsiddall.pl - Misterhouse Irrigation controls # Copyright (C) 2006 Jeff Siddall # Last modified: 2006-06-20 # noloop=start # Calculate the running average using this weight (default: 1% when dry, 3% # when wet when called hourly) my $new_rain_data_weight = 0.03; my $new_dry_data_weight = 0.01; set_states $Dryness (0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1); # noloop=stop # Soil dryness estimator # This system estimates the dryness of the soil based on input from a rain # sensor switch. It uses a simple weighted running average algorithm so no # state information, except the last estimated $Dryness value, is required. # Update the moisture value hourly if ($New_Hour) { &Update_Soil_Dryness; } sub Update_Soil_Dryness { # Update the soil $Dryness running average based on the current value of the # $Rain_Sensor # If the sensor is on then the soil is drying out if (state $Rain_Sensor eq ON) { set $Dryness (((state $Dryness) * (1 - $new_dry_data_weight)) + $new_dry_data_weight); # Otherwise it is getting less dry } else { set $Dryness ((state $Dryness) * (1 - $new_rain_data_weight)); } print_log "Irrigation: Soil dryness now " . (state $Dryness); } |