Install Hue clock

From xPL
Jump to: navigation, search

The hue system consists of LED light bulbs connected via ZigBee to a bridge which is in turn connected to Ethernet. An xPL bulb controller allows to change colours. This device will be driven every minute in order to display the time with the help of 2 bulbs: one for the hour and one for the minutes.

Before all, make sure you have installed an xPL hub. You will also need the xPL clock which sends ticks every minute and, obviously, the xPL bulb controller.

Install xPL Hue time display

Download the xPL Hue time display script.

Move the script to xPL scripts directory:

SCRIPTS_BASE_DIR=/home/control/Documents/Controls
mv xpl-hueClock.pl $SCRIPTS_BASE_DIR
chown control:users $SCRIPTS_BASE_DIR/*.pl
chmod 775 $SCRIPTS_BASE_DIR/*.pl

Test xPL Hue time display

Test it on a BeagleBone:

su control
SCRIPTS_BASE_DIR=/home/control/Documents/Controls
$SCRIPTS_BASE_DIR/xpl-hueClock.pl -h
$SCRIPTS_BASE_DIR/xpl-hueClock.pl -vn hue

Open a 2nd terminal window (on any machine with xPL installed) and monitor the xPL protocol:

SCRIPTS_BASE_DIR=/home/control/Documents/Controls
$SCRIPTS_BASE_DIR/xpl-monitor.pl -vf

Open a 3rd terminal window (on any machine with xPL installed) and control the lights:

SCRIPTS_BASE_DIR=/home/control/Documents/Controls
$SCRIPTS_BASE_DIR/xpl-send.pl -v -t stat -c clock.tick time=00h01

This should turn both bulbs red.

Launch the xPL Hue controller at startup

The xPL Hue time display is to be launched after the xPL hub.

Ubuntu

On Ubuntu, the xPL Hue time display starts-up once xpl-hub_started has been emitted.

Edit /etc/init/xpl-hue.conf :

################################################################################
# xPL Hue time indicator
#
description "xPL hue clock"
version     "1.0"
author      "Francois Corthay"

#-------------------------------------------------------------------------------
# Configuration variables
#
env SCRIPTS_DIR='/home/control/Documents/Controls'
env SCRIPT_NAME='xpl-hueClock.pl'
env PARAMETERS='-n home'

#-------------------------------------------------------------------------------
# Start and stop conditions
#
start on xpl-hub_started
stop on shutdown
respawn
setuid control
setgid users

#-------------------------------------------------------------------------------
# Start daemon
#
exec $SCRIPTS_DIR/$SCRIPT_NAME $PARAMETERS

Start the device and test it:

su root
service xpl-hueClock start
service xpl-hueClock status
initctl list | grep xpl
ps aux | grep -i xpl | grep -v grep | sed 's/.*\/Controls\///'

Mac OS

On Mac OS, the xPL Hue time display device starts-up later than the hub.

Edit /Library/LaunchDaemons/xpl-hueClock.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>xPL hue time display</string>
    <key>OnDemand</key>
    <false/>
    <key>UserName</key>
    <string>control</string>
    <key>ProgramArguments</key>
    <array>
      <string>/Users/control/Documents/Controls/xpl-hueClock.pl</string>
      <string>-n</string>
      <string>home</string>
      <string>-w</string>
      <string>25</string>
    </array>
  </dict>
</plist>

Load the xPL client:

launchctl load /Library/LaunchDaemons/xpl-hue.plist
launchctl list | grep -i xpl 
ps ax | grep -i xpl | grep -v grep