- Split template writing into two parts to avoid f-string parsing issues
- Write version comment separately using f-string
- Write rest of template using regular string (avoids escaping CSS/JS braces)
- Fixes SyntaxError: f-string: expecting '=', or '!', or ':', or '}'
The issue occurred because CSS contains { } braces and % characters that
f-strings try to interpret. Now only the version comment uses f-string.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add TEMPLATE_VERSION constant (1.3.0) to track UI changes
- Create check_template_version() to compare embedded vs current version
- Embed version marker as HTML comment in generated template
- Auto-regenerate template when version mismatch detected
- Show clear status messages: "Template up-to-date" or "regenerating"
- Document versioning system in CLAUDE.md with usage guidelines
Benefits:
- No manual template deletion required when code updates
- Users automatically get latest UI features on restart
- Clear version tracking for template changes
- Prevents stale template issues
To update template: increment TEMPLATE_VERSION when HTML/CSS/JS changes.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add /download_all endpoint to create in-memory ZIP archive
- Include zipfile and io imports for ZIP creation
- Add "Download All as ZIP" button in web interface (only shows when recordings exist)
- ZIP filename includes timestamp: wedding_recordings_YYYYMMDD_HHMMSS.zip
- Only includes .wav files from recordings directory
- Update API documentation in README.md
- Document feature in CLAUDE.md
Allows users to quickly backup all guest recordings in a single download.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Replace Flask development server with Waitress production WSGI server
- Add waitress>=2.1.0 dependency to pyproject.toml and Makefile
- Configure 4-thread server for better performance and stability
- Create comprehensive CLAUDE.md guide for future development
- Document architecture, deployment, testing, and common patterns
- Update README.md with production-ready feature and dependencies
Eliminates Flask development server warning and provides production-grade
web serving suitable for Raspberry Pi deployment.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
**Problem:**
- USB drives mounted as root were not writable by regular user
- Caused "Permission denied" errors on backup
- Required running application as root (not secure)
**Solution:**
- Better permission error messages with fix suggestions
- Try to create backup directory first (more flexible)
- Show helpful error: "run sudo chown -R \$USER /media/usb0"
**USB Setup Script (setup_usb.sh):**
- Interactive USB drive mounting
- Automatically detects USB devices
- Mounts with user ownership (uid/gid)
- Tests write permissions
- Shows free space
- Offers to add to /etc/fstab
- Color-coded output
**Documentation Updates:**
- Added 3 methods for mounting with permissions
- Recommended method: mount with uid/gid options
- Added fstab auto-mount example
- Added quick setup script example
- Clear instructions for each method
**Usage:**
```bash
# Easiest method
sudo ./setup_usb.sh
# Or manual mounting
sudo mount -o uid=$(id -u),gid=$(id -g) /dev/sda1 /media/usb0
# Or fix existing mount
sudo chown -R $USER /media/usb0
```
**Security:**
- No need to run wedding phone as root
- User-owned USB mount points
- Proper permission checking
- Clear error messages
**Web Interface:**
- Shows helpful permission error messages
- Includes fix command in error text
- Better UX for permission issues
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
**UV Integration:**
- Updated pyproject.toml with [tool.uv.scripts]
- Added 'uv run start' to launch wedding phone
- Added 'uv run test' to run audio tests
- Refactored main code into main() function
- Added proper entry point for package installation
**Systemd Service:**
- Created wedding-phone.service template
- Service runs with UV for dependency management
- Automatic restart on failure
- Proper security hardening (NoNewPrivileges, PrivateTmp)
- GPIO and audio group access configured
**Service Installer:**
- Created install_service.sh automated installer
- Auto-detects project path and user
- Checks for UV installation and dependencies
- Configures service file with correct paths
- Option to enable and start immediately
- Provides helpful command reference
**Installer Features:**
- Validates config.json exists (creates from example if missing)
- Installs UV dependencies automatically
- Updates service file paths dynamically
- Color-coded output for clarity
- Error checking at each step
- Clean installation process
**Usage:**
```bash
# Run directly with UV
uv run start
# Install as system service
./install_service.sh
# Service management
sudo systemctl start wedding-phone
sudo systemctl stop wedding-phone
sudo journalctl -u wedding-phone -f
```
**Documentation:**
- Updated README with UV commands
- Added service installation guide
- Removed old manual systemd instructions
- Added service management commands
- Updated file structure documentation
**Benefits:**
- Easier to run (single command)
- Automatic startup on boot
- Better dependency management
- Professional service integration
- Simplified installation process
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
**USB Backup Features:**
- Automatic backup to multiple USB drives
- CRC32 checksum verification for data integrity
- Configurable backup paths in config.json
- Backup on write (recordings and greeting uploads)
- Corrupted backups automatically deleted
- Web interface for monitoring and testing
**Configuration:**
- Added backup section to config.example.json
- enabled: Enable/disable USB backup
- usb_paths: Array of USB mount points
- verify_crc: Enable CRC32 verification
- backup_on_write: Backup immediately after file write
**CRC32 Implementation:**
- calculate_crc32(): Compute file checksum
- 64KB chunk reading for memory efficiency
- Source and destination file verification
- Automatic cleanup of failed copies
**Backup Functions:**
- backup_file_to_usb(): Backup with verification
- get_usb_backup_status(): Check drive status
- Mount detection, write test, free space check
- Preserves directory structure on USB
**Web Interface:**
- USB Backup card with drive status display
- Green/Yellow/Red status indicators
- Free space monitoring
- Test backup button
- Real-time status refresh
- Detailed error reporting
**Integration:**
- Recordings backed up after save
- Greetings backed up after upload
- Backup results logged to console
- Non-blocking backup execution
**API Endpoints:**
- GET /api/backup/status - Drive status
- POST /api/backup/test - Test backup
**Documentation:**
- Complete USB backup guide in README
- Mount instructions for USB drives
- CRC verification explanation
- Backup directory structure
- Web interface usage guide
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
**Immediate Hook Detection:**
- Playback now checks GPIO pin directly instead of status variable
- Recording checks GPIO pin in every loop iteration
- Both stop immediately when handset is placed back on hook
- No delays or waiting for status updates
**Abort Incomplete Recordings:**
- Added minimum recording duration (1 second)
- Recordings shorter than 1 second are automatically deleted
- Aborted recordings (hook hung up during recording) are not saved
- Failed recordings are cleaned up automatically
- Prevents saving empty or accidental recordings
**Behavior:**
- Pick up handset → Greeting plays
- Hang up during greeting → Greeting stops immediately, no recording
- Hang up during recording < 1s → Recording aborted, file deleted
- Hang up during recording > 1s → Recording saved normally
- Clean state after each hang up, ready for next call
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
**Button Sound Playback Fix:**
- Use separate PyAudio instance for button sound during recording
- Allows simultaneous audio input (recording) and output (button sound)
- Button sound plays through speaker/handset for guest to hear
- Button sound is NOT captured in the recording file
- Only works during recording phase (not during greeting)
**Button Status Indicator:**
- Added button status display in Phone Status card
- Shows "Button ready" or "Button sound playing..."
- Yellow highlight when button sound is playing
- Status updates dynamically via refresh
- Only visible when extra button is enabled
**Technical Details:**
- Separate audio_playback instance prevents stream conflicts
- Recording uses input stream, button uses output stream
- Both operate on same HiFiBerry device simultaneously
- Status API now includes extra_button_playing flag
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Extra button now only responds during actual recording
- Does not work during greeting playback or when on-hook
- Updated logic from checking off-hook status to checking recording status
- Updated README to reflect recording-only behavior
This allows guests to add sound effects to their recorded message
without interrupting the initial greeting.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Move greeting_delay from system config to user runtime config
- Add GET/POST API endpoints at /api/greeting_delay
- Add delay slider to web interface (0-10 seconds range)
- Implement debounced slider updates (300ms delay)
- Update visual gradient on slider movement
- Display current delay value in seconds
- Allow greeting delay adjustment without editing config files
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Breaking Behavior Change:
- Extra button NOW only works when handset is OFF-hook (during call)
- Previous: worked when on-hook (idle) - REVERSED
- Reason: Button is for guests to trigger during their call/recording
New Feature - Greeting Delay:
- Add greeting_delay_seconds to config.json (0-10 seconds)
- Delays greeting playback after handset pickup
- Gives guests time to position phone comfortably
- Default: 0 (plays immediately, backward compatible)
Extra Button Logic:
- Only responds when phone_status == "off_hook"
- Ignored when phone is on-hook (idle)
- Can be pressed during greeting or recording
- Plays entire sound without interruption
- Useful for: "Press button to hear special message"
Greeting Delay Use Cases:
- Wedding: Give guests moment to settle in
- Events: Time to position phone comfortably
- Accessibility: Extra time for elderly guests
- Professional: Pause before message delivery
Configuration:
{
"system": {
"greeting_delay_seconds": 2, // 2 second pause
"extra_button_sound": "surprise.wav"
}
}
Console Output:
- "Extra button ignored - phone is on hook" (when idle)
- "Waiting X seconds before greeting..." (delay active)
- "=== Extra button pressed ===" (during call)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Bug Fixes:
- Extra button now plays sound completely (was stopping immediately)
- Added check_hook_status parameter to play_sound_file()
- Button sounds play with check_hook_status=False (always complete)
- Greeting sounds play with check_hook_status=True (stop if hung up)
Behavior Changes:
- Extra button ONLY works when phone is on-hook (not in use)
- Prevents button from interfering with active calls
- Clear console message when button pressed during call
- Sound plays completely without hook status interruption
Technical Details:
- Modified play_sound_file() to accept check_hook_status parameter
- Changed while loop condition from "and" to conditional break
- Added on-hook check in play_extra_button_sound()
- Greeting playback still stops if handset hung up mid-message
This ensures:
✓ Button sounds always play completely
✓ Button only works when phone not in use
✓ Greeting playback can still be interrupted by hanging up
✓ No audio conflicts between button and phone calls
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Features:
- Configurable extra button on any GPIO pin
- Upload and select custom sound for button press
- Non-blocking button operation (separate thread)
- Debounced to prevent double-triggers (0.5s)
- Works independently from phone handset
- Can be pressed anytime, even during recording
Configuration:
- gpio.extra_button_enabled: Enable/disable feature
- gpio.extra_button_pin: GPIO pin number (default: 27)
- gpio.extra_button_pressed_state: "LOW" or "HIGH"
- system.extra_button_sound: Default sound file
Web Interface:
- Display active button sound in alert
- "🔘 Set Button" action on greeting items
- Visual indicator (🔘) for active button sound
- Upload any WAV file and assign to button
- Play/preview button sounds in browser
Backend:
- RotaryPhone.play_extra_button_sound() method
- RotaryPhone.set_extra_button_sound() method
- Thread-based playback to not block main loop
- /set_extra_button_sound API endpoint
- Extra button sound tracked in user_config.json
Documentation:
- Extra button setup in README
- Configuration examples
- GPIO pin configuration
- Operation workflow
Use Cases:
- Play special message on button press
- Sound effects for wedding games
- Multiple interaction points
- Custom audio triggers
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Breaking Changes:
- Configuration now via config.json instead of editing Python code
- Remove all hardcoded paths (no more /home/berwn)
- Separate system config (config.json) from runtime config (user_config.json)
Features:
- config.example.json with all configurable options
- GPIO pin and state configuration
- Audio device index configuration
- Customizable paths (relative or absolute)
- Web port and upload size settings
- No code editing required for deployment
Configuration Structure:
- gpio: hook_pin, hook_pressed_state
- audio: device_index, chunk_size, channels, sample_rate, max_record_seconds
- paths: base_dir, recordings_dir, sounds_dir
- web: port, max_upload_size_mb
- system: active_greeting, default_volume
Script automatically:
- Checks for config.json on startup
- Provides helpful error if missing
- Uses relative paths by default
- Loads test_complete.py config from same file
Updated Documentation:
- Complete configuration guide in README
- Setup instructions without hardcoded paths
- Troubleshooting for config errors
- Device index discovery command
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Features:
- Add pyproject.toml for UV package management
- Volume control with real-time slider (0-100%)
- Backend volume adjustment with numpy audio scaling
- Volume setting persists in config.json
- Debounced API calls for smooth slider interaction
- Enhanced audio playback with volume multiplier
- Update README with UV installation instructions
- Add volume control documentation
API Changes:
- GET /api/volume - Get current volume setting
- POST /api/volume - Set volume level
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Features:
- Web interface for managing rotary phone system
- Support for multiple greeting messages with selector
- Direct audio playback in browser for recordings and greetings
- Upload multiple WAV files at once
- Set active greeting that plays when phone is picked up
- HiFiBerry DAC+ADC Pro audio configuration
- GPIO-based handset detection and audio recording
- Real-time status monitoring with auto-refresh
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>