LinuxMCE Forums

General => Users => Topic started by: davegravy on February 18, 2010, 05:32:29 pm

Title: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: davegravy 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
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: davegravy on February 18, 2010, 10:31:31 pm
Warning, this is my first bash script EVER.

#!/bin/bash

Code: [Select]
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.
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: purps on February 18, 2010, 10:41:44 pm
Let us know how well it works! I would be very interested in this.
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: totallymaxed on February 18, 2010, 11:29:32 pm
Warning, this is my first bash script EVER.

#!/bin/bash

Code: [Select]
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
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: davegravy 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

Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: jimbodude 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.  ;)
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: sambuca 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 ;) Might not even get into 810.

best regards,
sambuca
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: valent 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 ?
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: huh on April 20, 2010, 04:55:27 am
This is a really cool idea- has it been implemented in the main build?


Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: bongowongo on April 20, 2010, 09: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
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: davegravy on April 20, 2010, 03: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.
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: bongowongo on April 20, 2010, 03:35:12 pm
Yes like soft bird sounds, or crickets or an ocean breeze.
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: davegravy on April 20, 2010, 07: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.
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: davegravy on April 20, 2010, 07: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: [Select]
/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.
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: d0t on April 23, 2010, 11: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...

.
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: Kooma on September 21, 2010, 08:46:37 am
It's been awhile.... Any new experience with the sunrise simulation or even new developments regarding this? Happy being woken up with the lights?

I just adopted timed events to turn off the lights automatically in the bedroom in the night, which is just great in my case. I tend to fall asleep every night having the lights on, and then wake up too early due to this.
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: davegravy on September 21, 2010, 03:41:42 pm
I stopped using it because it bothered my wife. I've been meaning to buy her one of those blindfold thingamajigs to keep the light out but keep forgetting...
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: Kooma on September 22, 2010, 01:10:01 pm
(davegravy, your wife likes to sleep late?)

Okay, automated lights off function was fantastic for the three days it worked. Slept better, not only because it was dark but also the room temperature did not rise that much cause I wasn't burning the lights all night.

I have few 12 V halogens for the bedroom, connected to a conventional transformer. I suppose this is the reason why the ACT plug in lamp-module just died last night. It was used only for these few days :-[

Has anyone tried to fix those modules? It must be the output stage that died..
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: purps on September 22, 2010, 08:43:09 pm
Are those things fused?
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: Kooma on September 22, 2010, 09:29:35 pm
Yes, there is a fuse and I was quite positive that it would had been blown, but it wasn't. Checked that in the night instead of sleeping..

Not a big deal, but still decided to ask the ACT for advice on probable parts to replace. Got this idea since I know that some others have broken plug-in units, too.   :-\
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: daballiemo on September 23, 2010, 08:24:03 pm
Also note that you need to specifiy the device ID of the light you're trying to control in the line

Code: [Select]
/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.

We'll I liked the idea and gave it a go but...

34 is the device ID of the light and 76 the setlevel command, so replace 34 with your light Device ID  ;D
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: posde on September 24, 2010, 10:02:29 am
A quick note on sunrise simulation: Yesterday our bedroom drapes got motorized, and I included them into the LinuxMCE setup. This morning they went up at the designated time, and SWMBO got the shock of her lifetime, as she did not know, I wired it already  :D - needless to say, she was awake right away.

Let's see if she can overcome her state of shock in the following days.
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: purps on September 24, 2010, 10:38:11 am
A quick note on sunrise simulation: Yesterday our bedroom drapes got motorized, and I included them into the LinuxMCE setup. This morning they went up at the designated time, and SWMBO got the shock of her lifetime, as she did not know, I wired it already  :D - needless to say, she was awake right away.

Let's see if she can overcome her state of shock in the following days.

That sounds awesome! The drapes that is, not the shock your Mrs got. Did you buy the motorised drapes as a complete unit, or add the motors yourself? Are you using something like this to control it? http://store.homeseer.com/store/ABMHZ---Z-Wave-AC-ShadeBlind-Motor-Controller-ESI-P852C192.aspx
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: hari on September 24, 2010, 03:12:13 pm
possy is using a mature home automation system, no zwave toys ;-))

br Hari
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: posde on September 24, 2010, 03:32:30 pm
:)

I am using http://www.mdtautomation.de/download/Shutter%20Actuator.pdf to control all my drapes (15 atm three more to follow). And the motors are Somfy 20nm motors. And no, I did not install the motors myself. /me has two left hands.
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: valent on September 27, 2010, 12:07:02 pm
:)

I am using http://www.mdtautomation.de/download/Shutter%20Actuator.pdf to control all my drapes (15 atm three more to follow). And the motors are Somfy 20nm motors. And no, I did not install the motors myself. /me has two left hands.

Where did you buy MDT Shutter Actuator and how much does it cost?
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: DragonK on September 27, 2010, 01:27:48 pm
Hi,

Newbie here <-----

Can this be achived with X10 devices too?
I started implementing X10 light switches/dimmers and motion sensors. The blinds would score some browny points with the wife.
I have to open and close all the blinds in the house manually every morning and evening.

Would safe me time and energy if my hybrid can do it....

Karel
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: posde on September 27, 2010, 01:53:23 pm
Where did you buy MDT Shutter Actuator and how much does it cost?

They can be sourced easily around the web. One source is http://www.eibhandel.de/Jalousieaktoren_6
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: posde on September 27, 2010, 01:55:53 pm
Can this be achived with X10 devices too?

yes, you should be able to do the same thing with X10, as X10 has support for blinds/drapes as well. The thing is, EIB/KNX sounds expensive at 280EUR for 8 blinds, but if you calculate it per blind, you will find that it ain't much, if any, more expensive than X10. Marmitek SW10 is such an X10 blinds controller.
Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: Kooma on October 14, 2010, 09:37:54 am
(davegravy, your wife likes to sleep late?)

Okay, automated lights off function was fantastic for the three days it worked. Slept better, not only because it was dark but also the room temperature did not rise that much cause I wasn't burning the lights all night.

I have few 12 V halogens for the bedroom, connected to a conventional transformer. I suppose this is the reason why the ACT plug in lamp-module just died last night. It was used only for these few days :-[

Has anyone tried to fix those modules? It must be the output stage that died..

Sleepless nights... it turned out that the ACT module is fine. The thing is that something messes up the control of this particular module during the night. I cannot turn it on with a remote (hand-held or an orbiter). Only after reloading the router things get back to normal.

I know that answer to this problem lies in the logs somewhere. DCERouter log is 200 pgs long... so using grep might be in place.

Any ideas what to look for? And at this point, I'm just using events, not any scripts for this.

Thanks for your help!

Title: Re: Bedroom Sunrise Simulation Lighting Event: Can this be done?
Post by: davegravy on October 14, 2010, 03:43:57 pm
Plug the module in a room somewhere (not bedroom). Have it switch on and off once per minute all night long. Using the lighting device log, try to find out what time it fails. Look for errors in the other logs that occur around the same time.