Simple Christmas Tree Script for Philips Hue
Posted: Sunday 29 November 2015 18:20
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):
The off action script kills the script running in background and makes sure the lights are off:
The group is controlled by timers.
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
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