From: storemike <sto...@ya...> - 2007-04-16 13:09:54
|
that did it! Thanks Chris. Mike --- In mis...@ya..., "Chris Barrett" <chris@...> wrote: > > > > I'm trying to get the state of a DS10. The web UI and the DOS window > > show the state changes just fine, but the code I wrote isn't getting > > the state, although it is getting pulled in and is running. Here's > > what I have (it's very basic so far): > > > > my $mailbox_state =3D state $mailbox; > > #print $mailbox_state."\n"; > > > > if ($mailbox_state =3D~ /^alert/i){ > > print $mailbox_state; > > speak "You have mail, man"; > > } > > > > but, when I uncomment the 2nd line above, the DOS window scrolls up > > with blank lines. The speak bit is never executed. The item is > > defined in my items.mht as: > > > > RF,C9,mailbox,Sensors > > > > What am I missing? > > > Hi Mike, > > Try this: > > if (state_now $mailbox eq OPEN){ > speak "You have mail, man"; > } > if (state_now $mailbox eq CLOSED){ > speak "You have just cleared the mail"; > } > > You may need to reverse the OPEN and CLOSED, depending on how the switch and > its sensor are configured. > > > FWIW, here's some code that I use to monitor the status of a closet door and > control a light within the closet. > > ### Closet Door ### > $DOTL_ClosetDoor_timer =3D new Timer(); > $DOTL_ClosetDoor_flag =3D new Generic_Item(); > my $DOTL_ClosetDoor_timeout =3D 10; > > if (state_now $ClosetDoor eq OPEN) { > set $Closet_light ON if $Dark; > print_log "Closet door is open"; > set $DOTL_ClosetDoor_timer ($DOTL_ClosetDoor_timeout * 60); > } > > if (state_now $ClosetDoor eq CLOSED) { > unset $DOTL_ClosetDoor_timer; > print_log "Closet door is closed"; > set $Closet_light OFF; > } > > if (expired $DOTL_ClosetDoor_timer) { > set $Closet_light OFF; > } > > I have the following defined in my mht file: > > RF, d3, ClosetDoor_sensor > DOOR, ClosetDoor_sensor, ClosetDoor, Doors|Closet(1;1.5) > > rather > > > -------------------------------------------------------------------- ----- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > ________________________________________________________ > To unsubscribe from this list, go to: http://sourceforge.net/mail/? group_id=3D1365 > |