Simple Christmas Tree Script for Philips Hue

All kinds of 'OS' scripts

Moderator: leecollings

Post Reply
mcduarte2000
Posts: 24
Joined: Friday 17 July 2015 5:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Simple Christmas Tree Script for Philips Hue

Post 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.
User avatar
bbqkees
Posts: 407
Joined: Sunday 17 August 2014 21:01
Target OS: Linux
Domoticz version: 4.1x
Location: The Netherlands
Contact:

Re: Simple Christmas Tree Script for Philips Hue

Post 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.
Bosch / Nefit / Buderus / Junkers / Worcester / Sieger EMS bus Wi-Fi MQTT Gateway and interface boards: https://bbqkees-electronics.nl/
mcduarte2000
Posts: 24
Joined: Friday 17 July 2015 5:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Simple Christmas Tree Script for Philips Hue

Post 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).
User avatar
bbqkees
Posts: 407
Joined: Sunday 17 August 2014 21:01
Target OS: Linux
Domoticz version: 4.1x
Location: The Netherlands
Contact:

Re: Simple Christmas Tree Script for Philips Hue

Post 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.
Bosch / Nefit / Buderus / Junkers / Worcester / Sieger EMS bus Wi-Fi MQTT Gateway and interface boards: https://bbqkees-electronics.nl/
GerardM
Posts: 8
Joined: Monday 30 November 2015 11:38
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Gouda, The Neatherlands
Contact:

Re: Simple Christmas Tree Script for Philips Hue

Post 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
Domoticz newbee | arduino and Esp8266 hobbyist
mcduarte2000
Posts: 24
Joined: Friday 17 July 2015 5:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Simple Christmas Tree Script for Philips Hue

Post 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).
andrew0123
Posts: 1
Joined: Wednesday 04 October 2017 14:01
Target OS: -
Domoticz version:
Contact:

Re: Simple Christmas Tree Script for Philips Hue

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest