Difference between revisions of "Install alert"

From xPL
Jump to: navigation, search
(Created page with "The [http://developers.meethue.com hue] system consists of LED light bulbs connected via [http://www.zigbee.org/ ZigBee] to a bridge which is in turn connected to Ethernet. Th...")
 
Line 4: Line 4:
 
Before all, make sure you have installed an [[install xpl hub|xPL hub]].
 
Before all, make sure you have installed an [[install xpl hub|xPL hub]].
  
= Install xPL alert controller =
+
= Install xPL alert sender =
  
 
Install <code>HTTP::Tiny</code>:
 
Install <code>HTTP::Tiny</code>:
Line 12: Line 12:
 
  exit
 
  exit
  
Download the [http://www.dspc.ch/xPL/Downloads/xpl-alert.pl xPL alert controller] script.
+
Download the [http://www.dspc.ch/xPL/Downloads/xpl-alert.pl xPL alert sender] script.
  
 
Move the script to xPL scripts directory:
 
Move the script to xPL scripts directory:
Line 20: Line 20:
 
  chmod 775 $SCRIPTS_BASE_DIR/*.pl
 
  chmod 775 $SCRIPTS_BASE_DIR/*.pl
  
= Test xPL alert controller =
+
= Test xPL alert sender =
  
 
Test it on a [[install BeagleBone|BeagleBone]]:
 
Test it on a [[install BeagleBone|BeagleBone]]:
Line 41: Line 41:
 
The answer is seen in the xPL traffic monitor.
 
The answer is seen in the xPL traffic monitor.
  
= Launch the xPL alert controller at startup =
+
= Launch the xPL alert sender at startup =
  
 
The xPL alert clock controller is to be launched after the xPL hub.
 
The xPL alert clock controller is to be launched after the xPL hub.
Line 47: Line 47:
 
== Ubuntu ==
 
== Ubuntu ==
  
On Ubuntu, the xPL alert controller starts-up once <code>xpl-hub_started</code> has been emitted.
+
On Ubuntu, the xPL alert sender starts-up once <code>xpl-hub_started</code> has been emitted.
  
 
Edit <code>/etc/init/xpl-alert.conf </code>:
 
Edit <code>/etc/init/xpl-alert.conf </code>:
Line 87: Line 87:
 
== Mac OS ==
 
== Mac OS ==
  
On Mac OS, the xPL alert controller starts-up later than the hub.
+
On Mac OS, the xPL alert sender starts-up later than the hub.
  
 
Edit <code>/Library/LaunchDaemons/xpl-alert.plist</code>:
 
Edit <code>/Library/LaunchDaemons/xpl-alert.plist</code>:
Line 95: Line 95:
 
   <dict>
 
   <dict>
 
     <key>Label</key>
 
     <key>Label</key>
     <string>xPL Philips alert controller</string>
+
     <string>xPL Philips alert sender </string>
 
     <key>OnDemand</key>
 
     <key>OnDemand</key>
 
     <false/>
 
     <false/>

Revision as of 13:46, 22 May 2014

The hue system consists of LED light bulbs connected via ZigBee to a bridge which is in turn connected to Ethernet. The bridge API implements a RESTful web service using HTTP methods.

Before all, make sure you have installed an xPL hub.

Install xPL alert sender

Install HTTP::Tiny:

su
perl -MFile::Find=find -MFile::Spec::Functions -Tlw -e 'find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC' 2> /dev/null | grep -i http
perl -MCPAN -e "install 'HTTP::Tiny'"
exit

Download the xPL alert sender script.

Move the script to xPL scripts directory:

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

Test xPL alert sender

Test it on a BeagleBone:

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

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 -c lighting.request device=3
$SCRIPTS_BASE_DIR/xpl-send.pl -v -c lighting.basic device=3 command=activate
$SCRIPTS_BASE_DIR/xpl-send.pl -v -c lighting.basic device=3 command=deactivate

The first xpl-send command asks for the status of the bulb. The answer is seen in the xPL traffic monitor.

Launch the xPL alert sender at startup

The xPL alert clock controller is to be launched after the xPL hub.

Ubuntu

On Ubuntu, the xPL alert sender starts-up once xpl-hub_started has been emitted.

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

################################################################################
# xPL alert, controls Philips alert light bulbs
#
description "xPL alert"
version     "1.0"
author      "Francois Corthay"

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

#-------------------------------------------------------------------------------
# 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-alert start
service xpl-alert status
initctl list | grep xpl
ps aux | grep -i xpl | grep -v grep | sed 's/.*\/Controls\///'

Mac OS

On Mac OS, the xPL alert sender starts-up later than the hub.

Edit /Library/LaunchDaemons/xpl-alert.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 Philips alert sender </string>
    <key>OnDemand</key>
    <false/>
    <key>UserName</key>
    <string>control</string>
    <key>ProgramArguments</key>
    <array>
      <string>/Users/control/Documents/Controls/xpl-alert.pl</string>
      <string>-n</string>
      <string> alert </string>
      <string>-w</string>
      <string>25</string>
    </array>
  </dict>
</plist>

Load the xPL client:

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