Difference between revisions of "Install state"
(→Configure xPL home state device) |
|||
Line 25: | Line 25: | ||
chmod 775 $SCRIPTS_BASE_DIR/*.pl | chmod 775 $SCRIPTS_BASE_DIR/*.pl | ||
− | = | + | = Home state information = |
− | + | The home state information is categorised in 4 hierarchy levels: | |
+ | * the ''room'' | ||
+ | * the ''kind'', such as <code>lights</code>, <code>shutters</code>, etc… | ||
+ | * the ''object'': a given light or shutter | ||
+ | * the ''value'', such as <code>on</code> or <code>off</code> | ||
+ | |||
+ | The following example shows a possible content of <code>/home/control/Documents/Controls/state.xml</code>: | ||
<?xml version="1.0" encoding="ISO-8859-1"?> | <?xml version="1.0" encoding="ISO-8859-1"?> | ||
− | + | <state> | |
− | + | <lounge name="lights" center="off" entry="off" stand="off" table="off" /> | |
− | + | <lounge name="shutters" center="up" east="up" west="up" /> | |
− | + | <lounge name="audio" balance="0" power="on" mute="off" source="CD" surround="stereoSub" volume="50" /> | |
− | + | <lounge name="screen" aspect="43" input="RGB" power="on" /> | |
− | + | <study name="lights" ceiling="off" stand="off" /> | |
− | + | <study name="shutters" window="louvresDown" /> | |
− | < | + | <study name="audio" balance="0" source="CD" power="off" volume="30" /> |
− | + | </state> | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | </ | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
= Test xPL home state device = | = Test xPL home state device = |
Revision as of 17:15, 1 April 2014
The xPL home state device stores the current state of different devices
such as lights, shutters, etc…
This information can be retrieved by clients such as web 2.0 pages
in order to display the proper state of the devices to be controlled.
The state update is best controlled with the help of the central xPL device.
Before all,make sure you have installed an xPL hub.
Contents
[hide]Install xPL home state device
Download the xPL home state script.
Move the script to xPL scripts directory:
SCRIPTS_BASE_DIR=/home/control/Documents/Controls mv xpl-homeState.pl $SCRIPTS_BASE_DIR chown control:users $SCRIPTS_BASE_DIR/*.pl chmod 775 $SCRIPTS_BASE_DIR/*.pl
Home state information
The home state information is categorised in 4 hierarchy levels:
- the room
- the kind, such as
lights
,shutters
, etc… - the object: a given light or shutter
- the value, such as
on
oroff
The following example shows a possible content of /home/control/Documents/Controls/state.xml
:
<?xml version="1.0" encoding="ISO-8859-1"?> <state> <lounge name="lights" center="off" entry="off" stand="off" table="off" /> <lounge name="shutters" center="up" east="up" west="up" /> <lounge name="audio" balance="0" power="on" mute="off" source="CD" surround="stereoSub" volume="50" /> <lounge name="screen" aspect="43" input="RGB" power="on" /> <study name="lights" ceiling="off" stand="off" /> <study name="shutters" window="louvresDown" /> <study name="audio" balance="0" source="CD" power="off" volume="30" /> </state>
Test xPL home state device
Test it on a BeagleBone:
su control SCRIPTS_BASE_DIR=/home/control/Documents/Controls $SCRIPTS_BASE_DIR/xpl-homeState.pl -h $SCRIPTS_BASE_DIR/xpl-homeState.pl -v -n home
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 another terminal and send a message to the serial port:
su control SCRIPTS_BASE_DIR=/home/control/Documents/Controls $SCRIPTS_BASE_DIR/xpl-send.pl -v -c pingPong.basic message=ping
The monitor should display the ping
message,
directly followed by a pong
message emitted by the xPL central device.
Launch the xPL home state device at startup
The xPL central device is to be launched after the xPL hub.
Ubuntu
On Ubuntu, the xPL central device starts-up once xpl-hub_started
has been emitted.
Edit /etc/init/xpl-homeState.conf
:
################################################################################ # xPL central message parser # description "xPL central message parser" version "1.0" author "Francois Corthay" #------------------------------------------------------------------------------- # Configuration variables # env SCRIPTS_DIR='/home/control/Documents/Controls' env SCRIPT_NAME='xpl-homeState.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-central start service xpl-central status SCRIPTS_BASE_DIR=/home/control/Documents/Controls $SCRIPTS_BASE_DIR/xpl-send.pl -v -c pingPong.basic message=ping
Mac OS
On Mac OS, the xPL central device starts-up later than the hub.
Edit /Library/LaunchDaemons/xpl-central.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 central message parser</string> <key>OnDemand</key> <false/> <key>UserName</key> <string>control</string> <key>ProgramArguments</key> <array> <string>/Users/control/Documents/Controls/xpl-central.pl</string> <string>-n</string> <string>lounge</string> <string>-w</string> <string>25</string> <string>-a</string> <string>/Users/control/Documents/Controls/centralActions.xml</string> </array> </dict> </plist>
Start the device and test it:
su root launchctl load /Library/LaunchDaemons/xpl-central.plist SCRIPTS_BASE_DIR=/Users/control/Documents/Controls $SCRIPTS_BASE_DIR/xpl-send.pl -v -c pingPong.basic message=ping