From: Tim S. <tp...@ma...> - 2007-10-23 17:21:31
|
On Tue, October 23, 2007 10:58, Joel Davidson wrote: > Jocelyn, > > Here's the code I use to read a couple of temp sensors with mh. I don't > know if this will help or not. This is some of the earlier code I wrote > for mh, and looking at it now I don't think I need the Generic_Items to > hold the temp, but it seems to work... And then again I really don't > see much functional difference between my code and yours. > > Joel > ------------------------------------------------------------ > $Garage_Temp_b = new iButton '10000800128eb8'; > $WineCellar_Temp_b = new iButton '100008000524ed'; > $Garage_Temp = new Generic_Item; > $WineCellar_Temp = new Generic_Item; > > if ($New_Minute) { > $Garage_Temp = read_temp $Garage_Temp_b; > $WineCellar_Temp = read_temp $WineCellar_Temp_b; > } > ------------------------------------------------------------ I've done it another way. I have a process (owfs) collection the data, and writing the data I want to a text file that is simply: var|value var1|value var2|value Then I use the following code to pull it into MH. Maybe this isn't the best way of doing it, but it's been working for a couple of years for me. # # ## get weather from txt file, pushs to status line. ## ## Tim Sailer 9/15/05 ## # # File is simply lines with 2 values separated by a | # var_value|value # WindSpeed|3.5 # # I run a script that dumps the file into /tmp, and I read it once a minute. # This is rough, but it works, in case you have data from somwhere with no # direct way to get it into MisterHouse # # noloop=start my @ar1; my $wcount=0; my $keyword; my $keyval; my $temperature; # noloop=stop if (time_cron('0,5,10,15,20,25,30,35,40,45,50,55 * * * *') || $Startup) { open (WIN,'</tmp/weather.txt'); while (<WIN>) { chomp; ($keyword,$keyval)=split(/\|/,$_); if ($keyword eq "") { next; } $wcount++; $Weather{$keyword}=$keyval; logit ("/var/log/mh/weather.log","$keyword,$keyval"); } close WIN; $temperature = $Weather{TempOutdoor} if $Reload; $Weather{RainTotal}=$Weather{Rain}; $Weather{WindSpeed} = sprintf("%3.1f",$Weather{WindSpeed}); $Weather{Summary_Short}= sprintf("%3.1f %3d%% %4.2f", $Weather{TempOutdoor}, $Weather{HumidOutdoor}, $Weather{Rain}); $Weather{Wind} = " $Weather{WindSpeed} $Weather{wind_dir}"; set $fBR round $Weather{FBedroom}; set $attic round $Weather{Attic}; set $by round $Weather{TempOutdoor}; set $solar round $Weather{solar}; set $garage round $Weather{garage}; } -- Tim Sailer Coastal Internet, Inc. www.buoy.com 631-399-2910 |