This is a project originally created by Matthew Fugel (https://github.com/matthewf01/Webex-Teams-Status-Box), which I have copied and improved for my needs. It utilizes a Raspberry Pi computing platform (any model from v3 forward should work - I am using a Pi Zero Wireless), an LED setup connected to the GPIO headers, and the Webex Teams API Python SDK. The Python script is run as a background service in Debian Linux and, utilizing the SDK, it makes an API call to Webex every 60 seconds to check the current presence status of the user configured during setup.
I have encountered regular connection rejects from the API, possibly due to rate-limiting, which I handle by backing off for 10 seconds and then re-running the API call. The service and script will run indefinitely unless explicitly killed via a root privileged user, or if the service encounters a fatal error. Historical logging for the service is handled by the system Journal daemon (journalctl
).
Parts to purchase:
Bring your own:
The Raspberry Pi computing platform most commonly runs a distribution of the Linux operating system, written for ARM processor architectures. In this case I am using the standard Debian Linux distribution recommended by the creators of the RPi. This comes in two versions: Desktop (has a GUI interface) and Lite (CLI only). I am using the Lite version to save on system resources and because I intend to run the Pi in "headless" mode, without a keyboard, mouse or video display. Let's get started!
ssh
- there should be NO file extension in the filename. This file tells Debian to enable SSH access permanently on first bootup.wpa_supplicant.conf
and add the text below. MAKE SURE to replace YOURSSID
and YOURPASSWORD
with your actual wireless SSID and PSK (leave the "" surrounding your SSID and PSK). This pre-loads Debian with your wireless network info so it will automatically connect.ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US
network={
ssid="YOURSSID"
psk="YOURPASSWORD"
scan_ssid=1
}
config.txt
file that already exists and add the following lines at the bottom of the file. This setting allows you to use the USB cable for direct console access for emergency troubleshooting.# Enable UART
enable_uart=1
# Enable Ethernet over USB
dtoverlay=dwc2
cmdline.txt
file that already exists and add the text modules-load=dwc2,g_ether
after rootwait
. This file should contain a single line of text with no line breaks and the text you add should be separated from rootwait
by a single space. The end result should look like this:console=serial0,115200 console=tty1 root=PARTUUID=eabcf7ff-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether
In this step we will install all the necessary components, insert the Pi Zero in the plastic case, install the Pi Traffic Light on the correct GPIO pins and finally, power up your Pi Zero.
PWR IN
connector on the Pi Zero (the connector closest to the corner of the circuit board) and power on the system.The Webex API will require two sets of credentials to utilize in this script. The first is a Webex Bot Token that you will generate when you create a new Webex Bot. The Bot is the actual application that will be checking the status of the Webex user. The second piece of information is the Webex user's Person ID - a unique identifying string assigned to each user. The script passes this Person ID to the Webex Bot to tell it which user to check the status of.
id
key at the top of the output (copy only the characters, not the double quotes "").
In this section we'll begin the installation and setup process. We'll start by verifying that Python 3 is installed (the Debian image comes with Python 2 and 3 pre-installed but this script is not fully backward compatible with Python 2) and the necessary Python modules. Then we will install the Python script and configure the background service. Additionally, in the Testing and Troubleshooting section I've given an explanation of the sudo
command prefix that you'll find in this section.
pi
raspberry
passwd
. Follow the prompts to change the password.sudo apt-get update
python3 --version
pip3 --version
sudo apt-get install python3.7
sudo apt-get install python3-pip
cd
wget -O setup.sh https://raw.githubusercontent.com/miarond/Webex_Status_Light/main/setup.sh
ls -al | grep setup
to view the file and its attributes.
pi@raspberrypi:~ $ ls -al | grep setup
-rw-r--r-- 1 pi pi 1848 Dec 23 12:41 setup.sh
drwxrwxrwx
where the first letter denotes either a file (-
) or a directory (d
). The next groupings of 3 letters denote read (r
), write (w
) and execute (x
) permissions. As you can see, my file is missing the execute permission.chmod +x setup.sh
. Because the pi
user account is the owner of the file, we can run this command without adding the sudo
prefix.sudo ./setup.sh
Wait, you mean it didn't work right the first time??? It's a well known axiom that code rarely works right on the first try...and if it does, you should be suspicious! There are several places where this setup process could go wrong and its always best to watch the SSH console output carefully as the installation progresses. Detailed error messages or warnings will often be displayed on the console.
Some common spots for trouble could be:
sudo
prefix. The sudo
command stands for "Superuser Do" and it is the equivalent of choosing "Run as Administrator" on Windows operating systems.ls -al
command. Running the chmod +x <filename>
command will add execute permissions - using +r
or +w
will add read or write permissions.apt-get
) package manager for installing programs.sudo
because this will install the package at the system level, making it available to all users and Python instances.python3 <script_name>
.sudo nano /etc/systemd/system/webexapp.service
Ctrl + O
to save the file, then Ctrl + X
to exit.sudo systemctl daemon-reload
sudo systemctl start webexapp.service
sudo systemctl status webexapp.service
to view the last few lines of log output. These normally give some indication why the service crashed.sudo journalctl -f -u webexapp.service
to follow the "tail" output of the Journal log for the service.webexapp.py
Python script is the heart of this service and it is stored in the /home/pi
directory. In order to run it directly you will need to edit the file and manually enter the Bot token and Person ID in the code, in place of the environmental variables that are registered by the webexapp.service
config file.
python3 webexapp.py
. To stop the script, press Ctrl + C
.python3 ledclean.py
.If your Pi doesn't come online and connect to your wireless network automatically, you can try connecting a keyboard, mouse and monitor if you have the proper adapters for both Micro USB and Mini HDMI. However, if you don't have those adapters you CAN use the USB data cable to establish an emergency terminal/console session. The process is partially documented on this website The Polyglot Developer. Windows users will need to install Apple's Bonjour Print Services application to communicate with the Pi over USB (this is the only method I have personally tested). Mac users should not need this additional step (as documented here).
Once setup is complete on your computer, connect the Micro USB cable to the USB port on the Pi (NOT the PWR IN port) and to a USB port on your computer. The Pi should power on and establish a network connection to your computer via the USB cable. You can then simply SSH to raspberrypi.local
from your computer and you should be able to connect to the Pi just like you would over a network connection.
The following is a directory tree structure that illustrates the files installed and where they are placed.
/
āāāā home
| āāāā pi
| āāāā setup.sh
| āāāā webexapp.py
| āāāā ledclean.py
| āāāā rgbtest.py
āāāā etc
āāāā systemd
āāāā system
āāāā webexapp.service
Environmental Variables
WEBEX_TEAMS_ACCESS_TOKEN
PERSON
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community