From: Bruce W. <br...@mi...> - 2002-04-05 14:25:56
|
> > If you have the lates mh 2.66, you can try: > > > > set $bedroom_light '40%' if time_now '10:00 pm'; > > > > If off, it should turn it on first, then dim it 60%. > > The avoce code does work, but what I am trying to accomplish is that if > the time becomes 10pm and the light is on, to dim it to 60%, otherwise do > nothing. The other code snipplet that I posted was a portion of your > lights.pl, that I changed to match my setup. The full portion of your > code is: > > if (($nick_reading_light->{state_now} eq ON or $all_lights_on_nick-> > {state_now}) and > time_greater_than '11:45 PM') { > speak "room=nick Master Nick, you bad boy. It is time to sleep, not > to speak."; > set $nick_reading_light OFF; > } Ah, ok. I get it now. The nick reading light code uses time_greater_than, which returns true if the time is later than the time specified. time_now only returns true once, at the specified time. The above code gives a message if he tries to turn it on when it is really late. Something we needed when he was younger and would stay up all night reading :) Try this: set $bedroom_light '-60' if time_now '10:00 pm' and state $bedroom_light eq ON; or this (if using 2.66): set $bedroom_light '40%' if time_now '10:00 pm' and state $bedroom_light eq ON; The trick is to use state, not state_now, to get the current state. Bruce |