DoorBot 1.3 consisting of a Raspberry Pi 2 and custom made DoorBot v1.3 shield
Install this package for TTS:
sudo apt-get install espeakCreate virtual environment
python3 -m venv .venvActivate the python virtual environment:
source .venv/bin/activateInstall requirements:
pip install -r requirements.txtCopy config template
cp config.json.template config.jsonFill config:
- TidyAuth token: See Fletcher.
- Slack tokens: Create a new bot and generate the tokens. Bots cannot be transferred and there isn't really any downside to creating a new one. You need to give it the appropriate permissions (TODO - list them). You need to add the bot to channels you want it to interact with.
- Update slack channels for user tracking and app logging.
Setup udev rules for blinkstick
- create udev file
sudo nano /etc/udev/rules.d/85-blinkstick.rules - udev file contents:
SUBSYSTEM=="usb", MODE:="0666"
Copy service files in and load them:
sudo cp speaker_server.service /etc/systemd/system
sudo cp doorbot.service /etc/systemd/system
sudo systemctl daemon-reloadReboot the pi and your app is now live
The app will run as a service doorbot. The usual systemctl commands apply:
sudo systemctl start doorbot
sudo systemctl stop doorbot
sudo systemctl restart doorbotInspecting logging and status via systemctl and journald:
sudo systemctl status doorbot
journalctl -xe -u doorbot -fLogs also go to file doorbot.log and to Slack (INFO and above).
The blinkstick will report colours like so:
- Startup: blue
- Normal Operation: white
- Liveliness Check (from Slack): dim white (1s)
- Restart App (from Slack): light purple (1s), dark blue
- Reboot Pi (from Slack): dark purple (1s), dark blue
- Access Granted (door unlock): green (while unlocked)
- Access Denied (tag not in allowed list): red (5s)
- Bad Read (tag not valid length) or Tag Code Exception: dark red (5s)
- Keys Updated: aqua (1s)
This project includes a comprehensive test suite to ensure reliability and functionality.
Tests are located in doorbot/tests/ and are organized as follows:
- Unit Tests:
test_*.pyfiles that test individual components with mocked dependencies - Integration Tests: Tests marked with
@pytest.mark.integrationthat test against real services - Legacy Tests:
*_test.pyfiles (older standalone scripts, excluded from pytest)
Activate the virtual environment:
source .venv/bin/activate# Run all unit tests
python -m pytest -v
# Run only unit tests (exclude integration tests)
python -m pytest -v -m "not integration"
# Run tests for specific module
python -m pytest doorbot/tests/test_slack_app.py -v
# Run with coverage reporting
python -m pytest --cov=doorbot --cov-report=htmlIntegration tests require real Slack tokens and should be run manually when testing against live services:
# Set required environment variables
export SLACK_BOT_TOKEN="xoxb-your-bot-token"
export SLACK_APP_TOKEN="xapp-your-app-token"
export TEST_USER_ID="U12345"
# Run integration tests
python -m pytest doorbot/tests/test_slack_integration.py -vFor manual testing of Slack functionality with real handlers but mock hardware:
# Run the interactive testing script
python tools/interactive_slack_testing.pyThis script:
- Uses real Slack handlers from the main app
- Mocks all hardware interfaces (GPIO, BlinkStick, etc.)
- Connects to Slack Socket Mode for real-time testing
- Logs hardware actions without executing them
The project includes several development and testing utilities:
tools/interactive_slack_testing.py: Interactive testing with real Slack handlers and mock hardwareexperiments/tools/: Various utility scripts for development (card conversion, manual unlock, etc.)experiments/: Development experiments and prototypes for new features
The current test suite covers:
- ✅ Slack Loading Buttons: Visual feedback with spinning icons and success states
- ✅ Block Patching: UI modification logic for dynamic button updates
- ✅ Error Handling: Graceful handling of API failures
- ✅ Integration: End-to-end testing with real Slack API
- ✅ Hardware Interfaces: Unit tests for GPIO, sound, TTS, and authentication components
Tests ensure proper visual feedback when users interact with Slack buttons:
- Loading State: Button shows
:spinthinking:emoji immediately - Success State: Brief success message with ✓ after completion
- Reset State: Return to original button text after delay
Tests mock hardware dependencies to run without physical devices:
- GPIO operations (door locks, sensors)
- BlinkStick LED control
- Sound playback
- RFID/NFC readers
Run this in commandline to activate the python virtual environment:
source .venv/bin/activateRun the app for development
python -m doorbot