Wake Me Up light

All kinds of 'OS' scripts

Moderator: leecollings

Post Reply
Philos31
Posts: 33
Joined: Friday 15 August 2014 22:37
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Wake Me Up light

Post 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
RasPi2/KaKu/HUE/Xiaomi/Z-Wave/Nuki/Daikin 3,5kw Ururu Sarara/IR Heating Panels all working together with domoticz
User avatar
remb0
Posts: 499
Joined: Thursday 11 July 2013 22:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Wake Me Up light

Post by remb0 »

Very nice ;)
Hanss
Posts: 35
Joined: Friday 01 May 2015 12:13
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Wake Me Up light

Post 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
matthijs
Posts: 17
Joined: Friday 29 May 2015 12:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Wake Me Up light

Post by matthijs »

Did you set the executing rights for this script correct? You can do this with "chmod 775 <your directory>"
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Wake Me Up light

Post 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
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest