LinuxMCE Forums
May 24, 2013, 12:53:42 am GMT-1 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Rule #1 - Be Patient - Rule #2 - Don't ask when, if you don't contribute - Rule #3 - You have coding skills - LinuxMCE's small brother is available: http://www.agocontrol.com
 
   Home   Help Search Chat Login Register  
Pages: [1] 2 3
  Print  
Author Topic: Bedroom Sunrise Simulation Lighting Event: Can this be done?  (Read 3496 times)
davegravy
Guru
****
Posts: 451


View Profile
« on: February 18, 2010, 05:32:29 pm »

I have a problem with waking up in the morning, and I'm hoping my LinuxMCE setup can help me. The traditional auditory alarm clock doesn't suit me very well. The key, for me, to waking up early with a feeling of being refreshed appears to be light.

I would like to dim my bedroom lights from 0 to 100% gradually over a 15 minute period, beginning at a time that can be set each night before bed, like a traditional alarm clock. For the most realistic sunrise-simulation, I'd like to use as many discrete intervals as allowed by the Zwave protocol (I think it's 128?)

I see that I can use a timed lighting event to set a certain level on my bedroom lights, but I'd like to avoid having to create 128 or so different events occuring 7 seconds apart. I'm wondering if there's a way to create a single alarm clock event which executes a script. Conceptually it would look like:

<Bedroom_Sunrise_Simulation_Event_Script>
setlevel lightingdeviceXYZ 1
pause 7
setlevel lightingdeviceXYZ 2
pause 7
setlevel lightingdevice XYZ 3
pause 7
etc... but done using a loop and incrementing variable.

Can someone let me know if this is possible, and if so, point me in the right direction for getting started?

Thanks in advance.

Dave
Logged
davegravy
Guru
****
Posts: 451


View Profile
« Reply #1 on: February 18, 2010, 10:31:31 pm »

Warning, this is my first bash script EVER.

#!/bin/bash

Code:
NEXTLEVEL=1

#loop for 15 minutes (900 seconds)
for ((i=1;i<900;i+=1))
do

#logarithmically adjust time for increases to provide a more even light gradient
NEXTTIME=$(echo "scale=5;450*l($NEXTLEVEL)/l(10)" | bc -l)
#convert to integer
NEXTTIME=$(printf %.0f $NEXTTIME)

#execute if it's time to advance to the next lighting level
if [ "$i" -gt "$NEXTTIME" ]
        then
        /usr/pluto/bin/MessageSend localhost 0 34 1 184 76 "$NEXTLEVEL"
        (( NEXTLEVEL++ ))
        fi
#pause 1 second
sleep 1
done


Quick test ran fine. We'll find out tomorrow morning how well it works.
Logged
purps
NEEDS to work for LinuxMCE
***
Posts: 1270


If it ain't broke, tweak it


View Profile
« Reply #2 on: February 18, 2010, 10:41:44 pm »

Let us know how well it works! I would be very interested in this.
Logged

1004 RC :: looking good :: upgraded 01/04/2013
my setup :: http://wiki.linuxmce.org/index.php/User:Purps
my blog :: http://projectsofmatt.wordpress.com/
totallymaxed
LinuxMCE God
****
Posts: 4310


View Profile WWW
« Reply #3 on: February 18, 2010, 11:29:32 pm »

Warning, this is my first bash script EVER.

#!/bin/bash

Code:
NEXTLEVEL=1

#loop for 15 minutes (900 seconds)
for ((i=1;i<900;i+=1))
do

#logarithmically adjust time for increases to provide a more even light gradient
NEXTTIME=$(echo "scale=5;450*l($NEXTLEVEL)/l(10)" | bc -l)
#convert to integer
NEXTTIME=$(printf %.0f $NEXTTIME)

#execute if it's time to advance to the next lighting level
if [ "$i" -gt "$NEXTTIME" ]
        then
        /usr/pluto/bin/MessageSend localhost 0 34 1 184 76 "$NEXTLEVEL"
        (( NEXTLEVEL++ ))
        fi
#pause 1 second
sleep 1
done


Quick test ran fine. We'll find out tomorrow morning how well it works.

Cool :-)

Andrew
Logged

Andy Herron,
Convergent Home Technologies Ltd
United Kingdom

Dianemo S Now Shipping on Ubuntu 12.04LTS
Build your system on the latest Ubuntu OS Release!

Get a Dianemo S License: http://forum.linuxmce.org/index.php?topic=8880.0
iOS Orbiter: http://wiki.linuxmce.org/index.php/Dianemo_iOS_Orbiter
Follow us on Facebook: https://www.facebook.com/pages/Dianemo-Home-Automation/226019387454465

Sales & Info:
http://www.dianemo.co.uk
davegravy
Guru
****
Posts: 451


View Profile
« Reply #4 on: February 19, 2010, 03:13:29 pm »

Worked great! I woke up at 6:30am feeling like I slept in till noon. I think 15 minutes might be a bit too fast so I'm gonna play around with the timing algorithm a bit.

I received a question about what brand of zwave device I'm using. The answer is the Act Homepro lamp module.

Would be ideal if we could build in this functionality into lighting control. Instead of just specifying setlevel, you could also specify the time over which you want the change to occur - or a beginlevel, endleve, and time delta

Logged
jimbodude
Guru
****
Posts: 372


View Profile
« Reply #5 on: February 19, 2010, 07:13:12 pm »

Would be ideal if we could build in this functionality into lighting control. Instead of just specifying setlevel, you could also specify the time over which you want the change to occur - or a beginlevel, endleve, and time delta

Fade in/out would, indeed, be a great addition - especially in home theater settings.  I'm not sure how often I would want it set to 15+ minutes, more like 15 seconds in my case, but whatever makes you happy.  Wink
Logged
sambuca
Guru
****
Posts: 420


View Profile
« Reply #6 on: February 19, 2010, 08:36:40 pm »

Hi,

I just meddled around in the event plugin, and just ordered my first Z-wave gear. So I'm going to have a look at it. Don't expect it done right away, though Wink Might not even get into 810.

best regards,
sambuca
Logged
valent
Guru
****
Posts: 380


View Profile WWW
« Reply #7 on: February 20, 2010, 06:18:15 pm »

Whoow, cool idea, love it!

Is there a wall plug what I could control one self-standing lamp via zwave? I guess that the zwave wall plug should have support dimming feature, right? Which one do you recommend for 220V ?
Logged

LinuxMCE - If it was easy, everybody would be doing it!!
My setup - http://wiki.linuxmce.org/index.php/User:Valent
huh
Guru
****
Posts: 212


View Profile
« Reply #8 on: April 20, 2010, 03:55:27 am »

This is a really cool idea- has it been implemented in the main build?


Logged
bongowongo
wants to work for LinuxMCE
**
Posts: 826



View Profile
« Reply #9 on: April 20, 2010, 08:27:33 am »

Whoow, cool idea, love it!

Is there a wall plug what I could control one self-standing lamp via zwave? I guess that the zwave wall plug should have support dimming feature, right? Which one do you recommend for 220V ?

Cool Idea?
Philips Wake up light
http://www.search.philips.com/search/search?q=Wake-up+Light&s=all&l=global&h=all&o=consumer
Logged
davegravy
Guru
****
Posts: 451


View Profile
« Reply #10 on: April 20, 2010, 02:06:19 pm »

Hadn't thought of adding audio to the wake-up experience. If you have a squeezebox or MD in the bedroom you could probably do this, and incorporate a fade-in.
Logged
bongowongo
wants to work for LinuxMCE
**
Posts: 826



View Profile
« Reply #11 on: April 20, 2010, 02:35:12 pm »

Yes like soft bird sounds, or crickets or an ocean breeze.
Logged
davegravy
Guru
****
Posts: 451


View Profile
« Reply #12 on: April 20, 2010, 06:16:15 pm »

I received a question about location and how to trigger this script.

I don't really know where a good place to locate the script is, but I chose /home/linuxmce/sunrise_sim.sh for lack of a better idea.

To trigger:

In webadmin, create a day-of-the-week based timed event. For the Device, select App-Server. For the Command, select Spawn Application. For #13 filename, enter the location of the script, eg /home/linuxmce/sunrise_sim.sh

That should be all. A router reload might be required.
Logged
davegravy
Guru
****
Posts: 451


View Profile
« Reply #13 on: April 20, 2010, 06:29:13 pm »

Also note that you need to specifiy the device ID of the light you're trying to control in the line

Code:
/usr/pluto/bin/MessageSend localhost 0 34 1 184 76 "$NEXTLEVEL"

In the above case, the ID of the light is 76, you most likely need to replace this.
Logged
d0t
Newbie
*
Posts: 14


View Profile
« Reply #14 on: April 23, 2010, 10:56:15 pm »

Just an idea - how about having some text to speech using festival?  Would be cool to have the alarm clock MD read something like:

'Good morning.  Its 8 AM.  Outside conditions are currently sunny, 75 degrees with 50 percent humidity.  (blinds open)  You have 2 new voice mails.  Starting music playback.'

Weather could be pulled from an online source, or from Z-Wave climate sensors.  I haven't a clue how difficult this would be to script, however...

.
Logged
Pages: [1] 2 3
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!