Page 1 of 1

Wake Me Up light

Posted: Monday 15 September 2014 21:23
by Philos31
Using AppLamp/MiLight/LimitedLed etc lamp I created a script that tries to emulate the sunrise.
It goes from dark purple to bright yellow, then switches to white and brightens up untill full.
You need to put the white and collored light on the lowest setting and then off before using this script, because the lamp will turn on at its last postion.

Hope someone likes it. Will work on every linux system, not Domoticz only.

I tried it on group 1, would be happy if someone could test on other groups.
https://www.youtube.com/watch?v=dLhDJibXruk
Here you can see what it does....

Code: Select all

#!/bin/bash 
# This script comes with no warranty ...use at own risk 
# Copyright (C) 2014  Peter H. Roubos
# 
# This program is free software; you can redistribute it and/or modify 
# it under the terms of the GNU General Public License as published by 
# the Free Software Foundation; version 2 of the License. 
# 
# This program is distributed in the hope that it will be useful, 
# but WITHOUT ANY WARRANTY; without even the implied warranty of 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
# GNU General Public License for more details. 
# 
# This script can be used as a wake me up script using a wifi RGBW led
# like AppLamp/LimitedLed/Mi-Light/IWY Color etc.
# I use it in Domoticz but should work on every linux system
#
# Version 0.1 15 sept 2014
#
# Change variables to your liking here

IP=192.168.1.38							# ip adress of your wifibox
PORT=8899								# port of your wifibox, normaly 8899
GROUP=1 								# use 1,2,3,4 for the group you want
RUNTIME=6								# time that the script will go from begin to end (0 is about 2 minutes 6 about 10 minutes 15 about 30 minutes)

#############################################################################################################################
#       NO CHANGES AFTER THIS LINE -NO CHANGES AFTER THIS LINE -NO CHANGES AFTER THIS LINE -NO CHANGES AFTER THIS LINE      #
#############################################################################################################################

let GROUP=$GROUP*2
let LAMPCODE=67+$GROUP
let WHITECODE=195+$GROUP
let UIT=$AAN-1
let DIMMER=2
let COLOR=190

function verzend(){
  echo -n -e $SENDCOM | nc -u -q 1 $IP $PORT 
  sleep $RUNTIME
}

##SEND ON Command
printf -v ONCOMMAND '%x' $LAMPCODE
SENDCOM="\x"$ONCOMMAND"\x00"
echo -n -e $SENDCOM | nc -u -q 1 $IP $PORT

## Loop to change the colors and the brightness
while [ $DIMMER > 27 ]
do
## Send dimmer command
   printf -v ONCOMMAND '%x' $DIMMER 
SENDCOM="\x4E\x"$ONCOMMAND   
verzend
## Send Again, it's udp, you never know
verzend
## Send Color command 
     printf -v ONCOMMAND '%x' $COLOR
   SENDCOM="\xC0\x"$ONCOMMAND
verzend
COLOR=`expr $COLOR - 1`
        printf -v ONCOMMAND '%x' $COLOR 
SENDCOM="\xC0\x"$ONCOMMAND
verzend 
###  
   
   if [ $DIMMER -eq 27 ]
   then
      break
   fi
   DIMMER=`expr $DIMMER + 1`
   COLOR=`expr $COLOR - 1` 
done
## Now we do the same, but with white and start with a bit of light already
DIMMER=5
while [ $DIMMER > 27 ]
do
   printf -v ONCOMMAND '%x' $DIMMER
   
SENDCOM="\x4E\x"$ONCOMMAND
verzend
## Send Again, it's udp, you never know
verzend
printf -v ONCOMMAND '%x' $WHITECODE
SENDCOM="\x"$ONCOMMAND"\x00" #White
verzend
   if [ $DIMMER -eq 27 ]
   then
      break
   fi
   DIMMER=`expr $DIMMER + 1`
done

Re: Wake Me Up light

Posted: Tuesday 28 October 2014 12:31
by remb0
Very nice ;)

Re: Wake Me Up light

Posted: Sunday 10 May 2015 18:54
by Hanss
Does this script also work on a Synology Diskstation DS214 Play. I get errors like : ./milight.sh: line 38: syntax error: unexpected "("
Thank you for any feedback :-) ;-)

Best regards,

Hans

Re: Wake Me Up light

Posted: Saturday 30 May 2015 21:59
by matthijs
Did you set the executing rights for this script correct? You can do this with "chmod 775 <your directory>"

Re: Wake Me Up light

Posted: Thursday 14 January 2016 17:15
by deennoo
Thx for this

I'm looking a way to make it start from night mode, and if possible deep blue night mode, do you know how to do this.

Next step will be top set on make me sleep light