From: Jocelyn B. <joc...@vi...> - 2007-10-23 19:06:51
|
Thanks to everyone for your reply, I have a lot of thing to try. Best regards, Jocelyn ----- Original Message ----- From: "Jim Serack" <js...@sy...> To: "'The main list for the MisterHouse home automation program'" <mis...@li...> Sent: Tuesday, October 23, 2007 1:36 PM Subject: Re: [mh] IButton Help request >I use the Process_Item structure within MrHouse to run digitemp and dump >the > results into a file - which I have code to process and transfer the > results > into $misc variables for other programs to use - and map to the weather > variables - here is the code; > > # Program: Reads the temperature sensors on the OneWire Bus > # Author: J. Serack > # Orginal date: May 15, 2005 > # Changed date: May 30, 2005 > # This next line categorizes the program for program code control > # Category = iButtons > # This next line provides a description of the code in the setup control > #@ This code reads the temperature sensors on the OneWire Bus using > Digitemp > ################# Assumptions and Definitions > ################################## > # Assumes that digitemp is installed and there is a symbolic link to the > executable defined as digitemp > # > my $digitempserialport ="/dev/ttyS1"; > my $digitempreadspeed = 1000; > my $digitemprcfile > ="/usr/local/misterhouse/thislocation/data/onewire/.digitemprc"; > my $digitempinitresultfile > ="/usr/local/misterhouse/thislocation/data/onewire/ibuttoninit.data"; > my $digitempresultfile > ="/usr/local/misterhouse/thislocation/data/onewire/ibutton.data"; > $v_iButton_readtemps = new Voice_Cmd "Read the iButton temperature > buttons"; > $v_iButton_readtemps-> set_info('This reads all all iButton temperature > devices.'); > $ibutton_read = new Process_Item("digitemp -c$digitemprcfile -a > -r$digitempreadspeed"); > $ibutton_init = new Process_Item("digitemp -c$digitemprcfile -i > -s$digitempserialport"); > $v_iButton_init = new Voice_Cmd "Initialize digitemp"; > $v_iButton_init-> set_info('This initializes the iButton devices serial > numbers.'); > ################ Definitions of Ibuttons to temperature names > ################ > # > # Map Ibutton temperature sensors by ID to meaningful names > # This insures that a missing sensor does not affect the digitemp mapping > # to temperature names and values. > # > #DS1820/DS18S20/DS1920 Temperature Sensor > $Misc{ID10AAB7ED000800D4} = "Temperature_pool_water_high"; > $Misc{TS10AAB7ED000800D4} = "TempSpare3"; > #DS1820/DS18S20/DS1920 Temperature Sensor > $Misc{ID102BD53100080088} = "Temperature_pool_water_low"; > $Misc{TS102BD53100080088} = "TempSpare2"; > #DS1820/DS18S20/DS1920 Temperature Sensor > $Misc{ID1009D7ED000800C0} = "Temperature_pool_air"; > $Misc{TS1009D7ED000800C0} = "TempSpare4"; > #DS1820/DS18S20/DS1920 Temperature Sensor > $Misc{ID109BF5ED00080064} = "Temperature_pool_water"; > $Misc{TS109BF5ED00080064} = "TempSpare1"; > #DS1820/DS18S20/DS1920 Temperature Sensor > $Misc{ID106EE53100080092} = "Temperature_basement"; > $Misc{TS106EE53100080092} = "TempSpare6"; > #DS1820/DS18S20/DS1920 Temperature Sensor > $Misc{ID107DC13100080077} = "Temperature_outside"; > $Misc{TS107DC13100080077} = "TempSpare5"; > #digitemp 10DFCC31000800A9 : DS1820/DS18S20/DS1920 Temperature Sensor > $Misc{ID10DFCC31000800A9} = "Temperature_wet_test"; > $Misc{TS10DFCC31000800A9} = "TempSpare7"; > #digitemp 10DFCC31000800A9 : DS1820/DS18S20/DS1920 Temperature Sensor > $Misc{ID10EADDED0008000D} = "Humidity_wet_bulb"; > $Misc{TS10EADDED0008000D} = "TempSpare8"; > $Misc{ID105BDEED00080073} = "Humidity_dry_bulb"; > $Misc{TS105BDEED00080073} = "TempSpare9"; > # > # > ################ Initialization to run once > ################################## > # > my $initready; # Make sure the read is only run after the init is > complete. > if ($Reread or $Startup or said $v_iButton_init) { > $initready = 0; > set_output $ibutton_init $digitempinitresultfile; > start $ibutton_init; > } > if (done_now $ibutton_init) { > $initready =1; > # ROM assignment line looks like > #ROM #0 : 10A8BC31000800D9 > for my $data (file_read $digitempinitresultfile) { > next unless $data =~ /ROM \#(\d+) : (\S+)/; > $Misc{"DigitempID$1"}= $2; > print "$1 $2 \n"; > } > } > ################ Regular Code to get the temperature > ######################### > # > my $ID; > my $Tempspare; > my $Tempname; > if (new_minute 1 or said $v_iButton_readtemps) { > set_output $ibutton_read $digitempresultfile; > start $ibutton_read if $initready; > } > > # Data looks like this: Feb 28 22:44:16 Sensor 0 C: 3.01 F: 37.42 > if (done_now $ibutton_read) { > for my $data (file_read $digitempresultfile) { > next unless $data =~ /Sensor (\d+) C: (\S+) F: (\S+)/; > next if $3 > 180; # False readings look like 185 > # Looking up by the order of reading which sensor is which > # referenced to its name by the ID of the ibutton device > $ID = $Misc{"DigitempID$1"}; > $Tempname = $Misc{"ID$ID"}; > $Tempspare = $Misc{"TS$ID"}; > print "$Tempname temp=$2\n"; > # Putting the temperatures into the weather hash for plotting and > use > $Weather{$Tempspare} = $2; > $Weather{$Tempname} = $2; > } > } > > > -----Original Message----- > From: mis...@li... > [mailto:mis...@li...] On Behalf Of Tim > Sailer > Sent: October 23, 2007 1:07 PM > To: jr...@io...; The main list for the MisterHouse home automation program > Subject: Re: [mh] IButton Help request > > > > 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 > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > ________________________________________________________ > To unsubscribe from this list, go to: > http://sourceforge.net/mail/?group_id=1365 > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > ________________________________________________________ > To unsubscribe from this list, go to: > http://sourceforge.net/mail/?group_id=1365 > |