Difference between revisions of "Install alert"
(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...") |
(→Launch the xPL alert sender at startup) |
||
(17 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
− | The | + | The alert sender plays a given sound on the reception of the corresponding xPL message. |
− | + | ||
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 | + | = Install xPL alert sender = |
− | + | The alert sender bases in a command-line control allowing to play a sound file. | |
+ | On Linux, this generally is the [http://www.alsa-project.org/ Advanced Linux Sound Architecture] (ALSA). | ||
+ | Basic debug info: | ||
+ | lspci -nn | ||
+ | head -n 1 /proc/asound/card0/codec* | ||
+ | lsmod | grep '^snd' | ||
+ | aplay -l | ||
+ | |||
+ | Add the <code>control</code> user to the <code>audio</code> group: | ||
su | su | ||
− | + | cat /etc/group | grep control | |
− | + | usermod -G dialout,audio control | |
− | + | ||
+ | systemctl --global disable pulseaudio.service pulseaudio.socket | ||
+ | |||
+ | Plug loudspeakers on your PC's line out. | ||
+ | The [https://en.wikipedia.org/wiki/PC_99 PC System Design Guide] defines the analog line level audio output | ||
+ | [https://en.wikipedia.org/wiki/Phone_connector_(audio) phone connector] to be lime green. | ||
+ | |||
+ | Play a sound: | ||
+ | SOUND_FILES_LOCATION='/home/control/Documents/Controls/Sounds' | ||
+ | aplay $SOUND_FILES_LOCATION/doorBell.wav | ||
− | Download the [http://www.dspc.ch/xPL/Downloads/xpl-alert.pl xPL alert | + | 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 36: | ||
chmod 775 $SCRIPTS_BASE_DIR/*.pl | chmod 775 $SCRIPTS_BASE_DIR/*.pl | ||
− | = Test xPL alert | + | = Test xPL alert sender = |
Test it on a [[install BeagleBone|BeagleBone]]: | Test it on a [[install BeagleBone|BeagleBone]]: | ||
Line 34: | Line 50: | ||
Open a 3rd terminal window (on any machine with xPL installed) and control the lights: | 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=/home/control/Documents/Controls | ||
− | $SCRIPTS_BASE_DIR/xpl-send.pl -v -c | + | $SCRIPTS_BASE_DIR/xpl-send.pl -v -c alert.basic command=play |
− | + | $SCRIPTS_BASE_DIR/xpl-send.pl -v -c alert.basic command=play soundFile=pop.wav | |
− | $SCRIPTS_BASE_DIR/xpl-send.pl -v -c | + | |
− | The | + | The doorbell sound should play. |
− | + | ||
− | = Launch the xPL alert | + | = Launch the xPL alert sender at startup = |
− | The xPL alert | + | The xPL alert sender is to be launched after the xPL hub. |
− | == Ubuntu == | + | == Ubuntu with GUI login == |
− | On Ubuntu, the xPL alert | + | It seems that if there is a GUI login, the system services don't have access to the sound card. |
+ | In this case, the command: | ||
+ | /home/control/Documents/Controls/xpl-alert.pl -n door | ||
+ | can be added to the <code>Startup Applications</code>. | ||
+ | |||
+ | == Debian with SystemD == | ||
+ | |||
+ | On Debian with [https://wiki.debian.org/systemd systemd] (such as [https://www.raspbian.org/ Raspbian]), | ||
+ | the scripts can be defined as services. | ||
+ | |||
+ | The access to the sound system needs the service to be run as a user. | ||
+ | Check his group id: | ||
+ | su control | ||
+ | cat /etc/group | grep `whoami`:x | ||
+ | |||
+ | Edit <code>/lib/systemd/system/xpl-alert.service</code> (adapt to your values): | ||
+ | [Unit] | ||
+ | Description=xPL alert, playing a sound | ||
+ | After=network.target | ||
+ | |||
+ | [Service] | ||
+ | Type=simple | ||
+ | User=control | ||
+ | Group=users | ||
+ | Environment="XDG_RUNTIME_DIR=/run/user/1001" | ||
+ | ExecStart=/home/control/Documents/Controls/xpl-alert.pl -n door -s doorBell.wav | ||
+ | Restart=always | ||
+ | |||
+ | [Install] | ||
+ | WantedBy=multi-user.target | ||
+ | |||
+ | Activate the service: | ||
+ | su | ||
+ | systemctl enable xpl-alert.service | ||
+ | service xpl-alert start | ||
+ | |||
+ | Reboot and check: | ||
+ | ps ax | grep -v grep | grep -i xpl | ||
+ | service xpl-alert status | ||
+ | |||
+ | == Ubuntu with Upstart == | ||
+ | |||
+ | 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>: | ||
################################################################################ | ################################################################################ | ||
− | # xPL alert, | + | # xPL alert, plays sound |
# | # | ||
description "xPL alert" | description "xPL alert" | ||
Line 62: | Line 118: | ||
env SCRIPTS_DIR='/home/control/Documents/Controls' | env SCRIPTS_DIR='/home/control/Documents/Controls' | ||
env SCRIPT_NAME='xpl-alert.pl' | env SCRIPT_NAME='xpl-alert.pl' | ||
− | env PARAMETERS='-n | + | env PARAMETERS='-n door -s doorBell.wav' |
#------------------------------------------------------------------------------- | #------------------------------------------------------------------------------- | ||
Line 71: | Line 127: | ||
respawn | respawn | ||
setuid control | setuid control | ||
− | setgid | + | setgid audio |
#------------------------------------------------------------------------------- | #------------------------------------------------------------------------------- | ||
Line 84: | Line 140: | ||
initctl list | grep xpl | initctl list | grep xpl | ||
ps aux | grep -i xpl | grep -v grep | sed 's/.*\/Controls\///' | ps aux | grep -i xpl | grep -v grep | sed 's/.*\/Controls\///' | ||
+ | |||
+ | su control | ||
+ | SCRIPTS_BASE_DIR=/home/control/Documents/Controls | ||
+ | $SCRIPTS_BASE_DIR/xpl-send.pl -v -c alert.basic command=play | ||
== Mac OS == | == Mac OS == | ||
− | On Mac OS, the xPL alert | + | 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 155: | ||
<dict> | <dict> | ||
<key>Label</key> | <key>Label</key> | ||
− | <string> | + | <string>Audio alert sender </string> |
<key>OnDemand</key> | <key>OnDemand</key> | ||
<false/> | <false/> | ||
Line 116: | Line 176: | ||
ps ax | grep -i xpl | grep -v grep | ps ax | grep -i xpl | grep -v grep | ||
− | [[Category: install]] | + | [[Category: all]] [[Category: install]] [[Category: xPL]] |
Latest revision as of 11:11, 11 June 2021
The alert sender plays a given sound on the reception of the corresponding xPL message.
Before all, make sure you have installed an xPL hub.
Contents
Install xPL alert sender
The alert sender bases in a command-line control allowing to play a sound file. On Linux, this generally is the Advanced Linux Sound Architecture (ALSA). Basic debug info:
lspci -nn head -n 1 /proc/asound/card0/codec* lsmod | grep '^snd' aplay -l
Add the control
user to the audio
group:
su cat /etc/group | grep control usermod -G dialout,audio control systemctl --global disable pulseaudio.service pulseaudio.socket
Plug loudspeakers on your PC's line out. The PC System Design Guide defines the analog line level audio output phone connector to be lime green.
Play a sound:
SOUND_FILES_LOCATION='/home/control/Documents/Controls/Sounds' aplay $SOUND_FILES_LOCATION/doorBell.wav
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 alert.basic command=play $SCRIPTS_BASE_DIR/xpl-send.pl -v -c alert.basic command=play soundFile=pop.wav
The doorbell sound should play.
Launch the xPL alert sender at startup
The xPL alert sender is to be launched after the xPL hub.
Ubuntu with GUI login
It seems that if there is a GUI login, the system services don't have access to the sound card. In this case, the command:
/home/control/Documents/Controls/xpl-alert.pl -n door
can be added to the Startup Applications
.
Debian with SystemD
On Debian with systemd (such as Raspbian), the scripts can be defined as services.
The access to the sound system needs the service to be run as a user. Check his group id:
su control cat /etc/group | grep `whoami`:x
Edit /lib/systemd/system/xpl-alert.service
(adapt to your values):
[Unit] Description=xPL alert, playing a sound After=network.target [Service] Type=simple User=control Group=users Environment="XDG_RUNTIME_DIR=/run/user/1001" ExecStart=/home/control/Documents/Controls/xpl-alert.pl -n door -s doorBell.wav Restart=always [Install] WantedBy=multi-user.target
Activate the service:
su systemctl enable xpl-alert.service service xpl-alert start
Reboot and check:
ps ax | grep -v grep | grep -i xpl service xpl-alert status
Ubuntu with Upstart
On Ubuntu, the xPL alert sender starts-up once xpl-hub_started
has been emitted.
Edit /etc/init/xpl-alert.conf
:
################################################################################ # xPL alert, plays sound # 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 door -s doorBell.wav' #------------------------------------------------------------------------------- # Start and stop conditions # start on xpl-hub_started stop on shutdown respawn setuid control setgid audio #------------------------------------------------------------------------------- # 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\///' su control SCRIPTS_BASE_DIR=/home/control/Documents/Controls $SCRIPTS_BASE_DIR/xpl-send.pl -v -c alert.basic command=play
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>Audio 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