BitFocus Companion
Been working on a Companion on Raspberry Pi-driven Stream Deck for a A/V system control. It’s a incredible system with a great programmable interface. I’m working with the Stream Deck+ (4×4, bottom row are rotary knobs)
Getting Started
Great guide for getting started with a Companion Setup: https://www.youtube.com/watch?v=esh6cewbyO8
Companion
https://bitfocus.io/companion
Raspberry Pi Imager
https://www.raspberrypi.com/software/
Installed app (on Mac): Raspberry Pi Imager
Companion – from bit focus for emulation and control of Legato Stream Decks
https://user.bitfocus.io/download
https://user.bitfocus.io/docs
1. Update the Linux System:
* Open a terminal (GNOME Terminal, Xterm, etc.).
* Run the following commands:
* sudo apt update (or sudo apt-get update)
* sudo apt upgrade (or sudo apt-get upgrade)
* You may be prompted for your admin password.
* Follow any on-screen prompts, and usually, you’ll be asked if you want to continue with the updates (type ‘y’ and press Enter).
2. Update Companion (if applicable):
* If you are running CompanionPi, use the following command in a terminal: sudo companion-update.
Other things I’ve worked out
Corrupted Database
My Companion database on a Companion PI installation, v3.5.4 on Pi 4B became corrupted. The Pi wouldn’t boot. I got it to boot and run companion by running fsck -a manually,, but my buttons and triggers were missing and the log had this error:
Data/Database: Error getting controls: database disk image is malformed
I spent a while poking around trying to reset the database with no luck. I ran companion-update and reinstalled the latest stable (which is what I had to start) but nothing repaired the database.
Companion would run perfectly if I imported my backed up configuration, but after a restart, it would look to the database for its config and fail to load the buttons and triggers.
Eventually I found the database in a hidden directory in the companion user home directory.
/home/companion/.config/companion-nodejs/v3.5/ has the SQLite3 databases.
I stopped Companion, renamed the v3.5 folder, created a new empty v3.5 folder, started Companion and it did a full initialization, creating a new database.
I imported my configuration and am fully restored/functional without database errors and the system can be rebooted safely.
I’m bothering to post this because I could find no information on this while googling.
Adding/Updating Dev Modules
BitFocus Connection List with versions and links:
https://bitfocus.io/connections
Installing an Updated Module
– Prep Companion OS installation (on a Pi in my case)
– Install NPM and yarn
– https://www.geeksforgeeks.org/how-to-install-yarn-on-debian-12/
– sudo apt install nodejs npm -y
– npm -v
– sudo npm install –global yarn
– yarn –version
– Download tar.gz from GitHub (latest Reaper connector in this case)
– Explode in home directory (or anywhere)
– Switch into exploded module dir, run yarn install and/or build
– Install and/or build is necessary. I ended up doing both but not sure which mattered in the end.
– Copy modified folder into /opt/companion-module-dev/
– Change owner to ‘companion’ – sudo chown companion {folder name}
– Shutdown and restart companion Pi
– New dev module will load in place of bundled module.
QLab module didn’t need yarn install or build – just copy into the folder, turn off connection, turn back on and good to go.
Scripts via Stream Deck
Need to put the script in a folder accessible by user, companion:
– I made /home/shared (chmod 777)
– Any script in this folder needs executable permissions (chmod 777)
Shutdown Pi
/home/shared/shutdown.sh
#!/bin/sh
/bin/sudo shutdown -h now
Reboot Pi
/home/shared/reboot.sh
#!/bin/sh
/bin/sudo reboot
Restart Companion
/home/shared/restartcompi.sh
#!/bin/sh
/bin/sudo systemctl restart companion
Start scripts in Companion with the action, internal: System: Run shell path (local)
Variables
There aren’t arrays per se, but many system variables get enumerated in the variable name. I found you can nest a variable within another variable’s name to dynamically change which variable you are calling.
Example:
A button that has the name of the current page but has two press functions:
– Short press goes to next page
– Long press goes to home page
Button Name – $(internal:page_number_$(internal:surface_streamdeck_A00WA5031JC2N3_page)_name)
Original variable names:
$(internal:page_number_1_name)
$(internal:surface_streamdeck_A00WA5031JC2N3_page)
The “1” is swapped out for the current page number so the button title always shows the current page.
I had to do this because the current page number is a predefined variable, but not the current page name.
The drawback in this case is that the emulator shows the page name on the Stream Deck. Need to work out a way for each surface to show its own name. At the moment, I have the emulator showing a 5th row with it’s name and correct “next” page.
Other
Text fields also accept \n for a line break to format button text.
Cloning Instance (SD Card)
On Mac
sudo dd if /dev/DISKDEVICE bs=1M | gzip > PATH/FILENAME.img.gz
Example:
sudo dd if /dev/disk2 bs=1M | gzip > Downloads/Compi354Dev.img.gz
Use Raspberry Pi Imager to write the image (Choose Custom and select image) to a new SD card.