Fix extra button to only work when OFF-hook and add greeting delay
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>
This commit is contained in:
@@ -305,13 +305,13 @@ class RotaryPhone:
|
||||
}
|
||||
|
||||
def play_extra_button_sound(self):
|
||||
"""Play sound when extra button is pressed (only when on-hook)"""
|
||||
"""Play sound when extra button is pressed (only when off-hook/in call)"""
|
||||
if not EXTRA_BUTTON_ENABLED:
|
||||
return
|
||||
|
||||
# Only play if phone is on hook (not in use)
|
||||
if self.phone_status != "on_hook":
|
||||
print("Extra button ignored - phone is off hook")
|
||||
# Only play if phone is OFF hook (during a call)
|
||||
if self.phone_status != "off_hook":
|
||||
print("Extra button ignored - phone is on hook")
|
||||
return
|
||||
|
||||
button_sound = self.get_extra_button_sound_path()
|
||||
@@ -348,6 +348,12 @@ class RotaryPhone:
|
||||
self.phone_status = "off_hook"
|
||||
print("\n=== Handset picked up ===")
|
||||
|
||||
# Apply greeting delay if configured
|
||||
greeting_delay = SYS_CONFIG['system'].get('greeting_delay_seconds', 0)
|
||||
if greeting_delay > 0:
|
||||
print(f"Waiting {greeting_delay} seconds before greeting...")
|
||||
time.sleep(greeting_delay)
|
||||
|
||||
# Play active greeting message
|
||||
greeting_file = self.get_active_greeting_path()
|
||||
self.play_sound_file(greeting_file)
|
||||
|
||||
Reference in New Issue
Block a user