Page 1 of 1

Simple Christmas Tree Script for Philips Hue

Posted: Sunday 29 November 2015 18:20
by mcduarte2000
Hi, I just finished working in a Christmas Tree script and now sharing it as someone may want to do something similar. I've two Philips Living Whites plugs each controlling one row of lights. I created a group for the lights and two bash scripts. Do you have any suggestion on how to improve the scripts?

The on action passes a time to turn off the tree lights to the script and sends it to the background (as it may run for many hours):

Code: Select all

script:///home/pi/domoticz/scripts/bash/christmas_tree_on.sh 23:58 &

Code: Select all

#!/bin/bash
while [ $(date +%H:%M) '<' "$1" ]; 
do
curl --request PUT --data "{\"on\": true}" http://192.168.1.xx/api/xxxx/lights/5/state
curl --request PUT --data "{\"on\": false}" http://192.168.1.xx/api/xxxx/lights/7/state
sleep 2
curl --request PUT --data "{\"on\": false}" http://192.168.1.xx/api/xxxx/lights/5/state
curl --request PUT --data "{\"on\": true}" http://192.168.1.xx/api/xxxx/lights/7/state
sleep 2
echo $(date +%H:%M)
echo $1
done
curl --request PUT --data "{\"on\": false}" http://192.168.1.xx/api/xxxx/lights/5/state
curl --request PUT --data "{\"on\": false}" http://192.168.1.xx/api/xxxx/lights/7/state
The off action script kills the script running in background and makes sure the lights are off:

Code: Select all

script:///home/pi/domoticz/scripts/bash/christmas_tree_off.sh

Code: Select all

#!/bin/bash
killall christmas_tree_on.sh
curl --request PUT --data "{\"on\": false}" http://192.168.1.xx/api/xxxx/lights/5/state
curl --request PUT --data "{\"on\": false}" http://192.168.1.xx/api/xxxx/lights/7/state
The group is controlled by timers.

Re: Simple Christmas Tree Script for Philips Hue

Posted: Monday 30 November 2015 13:48
by bbqkees
If your goal is to just turn the lighting on and off why are you using a script instead of the built in timers?
You can just add the LivingWhites as switches in Domoticz and add the timers there or create a scene with timers.

Re: Simple Christmas Tree Script for Philips Hue

Posted: Tuesday 01 December 2015 0:21
by mcduarte2000
bbqkees wrote:If your goal is to just turn the lighting on and off why are you using a script instead of the built in timers?
You can just add the LivingWhites as switches in Domoticz and add the timers there or create a scene with timers.
The script above is turning intermittently each row of light every two seconds (blinking). From what I see, timers don't even have seconds and don't have a way of repeating a cycle (I would have to create n on/offs).

Re: Simple Christmas Tree Script for Philips Hue

Posted: Tuesday 01 December 2015 10:07
by bbqkees
Ok I did not notice the 'sleep' statements.

Maybe nice to use the dimmer function (if you are not using LED christmas lights)?
You can also set sweeps and blinks etc via the Hue API.

Re: Simple Christmas Tree Script for Philips Hue

Posted: Saturday 05 December 2015 12:57
by GerardM
Nice,

Adapted it to my needs..
Using nc instead of curl

Just one question, why is there a '&' at the end of your script line ?

[edit]
My ipad prints the wrong caracter when i wat to type '&'
The character i mean is the enpercent sing

Re: Simple Christmas Tree Script for Philips Hue

Posted: Tuesday 08 December 2015 9:55
by mcduarte2000
GerardM wrote:Nice,

Adapted it to my needs..
Using nc instead of curl

Just one question, why is there a '&' at the end of your script line ?

[edit]
My ipad prints the wrong caracter when i wat to type '&'
The character i mean is the enpercent sing
It is to send the process to the background, if not, from what I saw, Domoticz would wait for the script to stop (and it doesn't until the time I set on it).

Re: Simple Christmas Tree Script for Philips Hue

Posted: Wednesday 04 October 2017 14:22
by andrew0123
Hi,

It is a good idea.

Christmas lights mean lines — that is quite recently the way it is. Air is attempting to change that with a remote lighting framework that appears to be something out you had always wanted. The enormous, delightful Aura knobs dangle from your trees like trimmings, however, they're considerably more cutting edge than the silver balls you're accustomed to snaring from the branches.