Bump to v2.0.0: daily emote rotation + expanded sound library
- Emote face is now stable all day; /wake picks a fresh random face each morning instead of rotating every 5 minutes. Removes EMOTE_ROTATION_INTERVAL and last_emote_change entirely. - Added 10 new synthesized sounds for /notify: doorbell, knock, ding, blip, siren, tada, ping, bubble, fanfare, and alarm (loops until tapped or TTL expires). stopAlarm() wired into tap handler and handleStateChange(). - openapi.yaml: new sound names added to enum. - CLAUDE.md / README.md updated to reflect both changes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -103,7 +103,7 @@ All detectors support: `AGGREGATOR_URL`, `CHECK_INTERVAL`, `THRESHOLD_WARNING`,
|
||||
| `emote` | No | Custom emote to display |
|
||||
| `color` | No | Custom color (hex, e.g., `#FF9900`) |
|
||||
| `animation` | No | One of: `breathing`, `shaking`, `popping`, `celebrating`, `floating`, `bouncing`, `swaying` |
|
||||
| `sound` | No | One of: `chime`, `alert`, `warning`, `critical`, `success`, `notify`, `none` |
|
||||
| `sound` | No | One of: `chime`, `alert`, `warning`, `critical`, `success`, `notify`, `doorbell`, `knock`, `ding`, `blip`, `siren`, `tada`, `ping`, `bubble`, `fanfare`, `alarm`, `none` |
|
||||
|
||||
## Priority System
|
||||
|
||||
@@ -118,7 +118,7 @@ Lower number = higher priority. Events with a `ttl` auto-expire (heartbeat patte
|
||||
|
||||
## Personality System
|
||||
|
||||
The optimal state cycles through emotes with paired animations every 5 minutes:
|
||||
The optimal state face is set once per day on `/wake` (random pick). Each morning a fresh emote is chosen:
|
||||
|
||||
| Emote | Animation | Vibe |
|
||||
|-------|-----------|------|
|
||||
|
||||
@@ -177,7 +177,7 @@ automation:
|
||||
- `emote`: Any ASCII emote (e.g., `( °o°)`, `\\(^o^)/`)
|
||||
- `color`: Hex color (e.g., `#FF9900`)
|
||||
- `animation`: `breathing`, `shaking`, `popping`, `celebrating`, `floating`, `bouncing`, `swaying`
|
||||
- `sound`: `chime`, `alert`, `warning`, `critical`, `success`, `notify`, `none`
|
||||
- `sound`: `chime`, `alert`, `warning`, `critical`, `success`, `notify`, `doorbell`, `knock`, `ding`, `blip`, `siren`, `tada`, `ping`, `bubble`, `fanfare`, `alarm`, `none`
|
||||
|
||||
## API Reference
|
||||
|
||||
@@ -200,8 +200,8 @@ Full API documentation available at [/docs](http://localhost:5100/docs) or in [o
|
||||
|
||||
The emote has personality! In optimal state it:
|
||||
|
||||
- Rotates through happy faces every 5 minutes
|
||||
- Occasionally winks `( -_^)` or blinks `( ᵕ.ᵕ)` for a second or two
|
||||
- Shows a stable face all day — set fresh each morning when `/wake` is called
|
||||
- Occasionally winks `( -_^)` or blinks `( ᵕ.ᵕ)` for a second or two on wake
|
||||
- Celebrates `\(^o^)/` when recovering from warnings
|
||||
- Each face has its own animation (floating, bouncing, swaying)
|
||||
- Reacts when tapped `( °o°)`, shows version info, and dismisses active alerts
|
||||
@@ -211,6 +211,7 @@ The emote has personality! In optimal state it:
|
||||
- Critical: urgent descending tone
|
||||
- Notify: gentle ping
|
||||
- Recovery: happy ascending chirp
|
||||
- 10 additional synthesized sounds for `/notify`: `doorbell`, `knock`, `ding`, `blip`, `siren`, `tada`, `ping`, `bubble`, `fanfare`, `alarm` (alarm loops until tapped)
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -19,14 +19,12 @@ ROOT_DIR = Path(__file__).parent
|
||||
STATUS_FILE = Path(__file__).parent / "status.json"
|
||||
DEFAULT_NOTIFY_TTL = 10 # Default TTL for Priority 3 (Notify) events
|
||||
CELEBRATION_DURATION = 5 # Seconds to show celebration after recovery
|
||||
EMOTE_ROTATION_INTERVAL = 300 # Seconds between emote rotations
|
||||
IDLE_EXPRESSION_CHANCE = 0.15 # Chance of a brief blink/wink on rotation
|
||||
IDLE_EXPRESSION_CHANCE = 0.15 # Chance of a brief blink/wink on wake
|
||||
DEFAULT_NOTIFY_DURATION = 5 # Default duration for /notify events
|
||||
|
||||
# Emote variations with paired animations
|
||||
OPTIMAL_EMOTES = [
|
||||
("( ^_^)", "breathing"), # calm, content
|
||||
("( ˙▿˙)", "floating"), # content
|
||||
("(◕‿◕)", "bouncing"), # cheerful
|
||||
("( ・ω・)", "swaying"), # curious
|
||||
("( ˘▽˘)", "breathing"), # cozy
|
||||
@@ -56,7 +54,6 @@ celebrating_until = 0
|
||||
blinking_until = 0
|
||||
blink_emote = None
|
||||
blink_animation = None
|
||||
last_emote_change = time.time()
|
||||
current_optimal_emote = OPTIMAL_EMOTES[0][0]
|
||||
current_optimal_animation = OPTIMAL_EMOTES[0][1]
|
||||
|
||||
@@ -73,7 +70,7 @@ SLEEP_ANIMATION = "sleeping"
|
||||
def get_current_state():
|
||||
"""Determine current state based on active events."""
|
||||
global previous_priority, celebrating_until, blinking_until, blink_emote, blink_animation
|
||||
global last_emote_change, current_optimal_emote, current_optimal_animation
|
||||
global current_optimal_emote, current_optimal_animation
|
||||
|
||||
# Sleep mode overrides everything
|
||||
if is_sleeping:
|
||||
@@ -139,14 +136,6 @@ def get_current_state():
|
||||
emote = blink_emote
|
||||
animation = blink_animation
|
||||
else:
|
||||
# Rotate optimal emotes every 5 minutes
|
||||
if now - last_emote_change > EMOTE_ROTATION_INTERVAL:
|
||||
last_emote_change = now
|
||||
current_optimal_emote, current_optimal_animation = random.choice(OPTIMAL_EMOTES)
|
||||
# Brief blink/wink chance on rotation
|
||||
if random.random() < IDLE_EXPRESSION_CHANCE:
|
||||
blink_emote, blink_animation = random.choice(IDLE_EMOTES)
|
||||
blinking_until = now + random.uniform(1, 2)
|
||||
emote = current_optimal_emote
|
||||
animation = current_optimal_animation
|
||||
|
||||
@@ -326,8 +315,13 @@ def sleep_mode():
|
||||
@app.route("/wake", methods=["POST"])
|
||||
def wake_mode():
|
||||
"""Exit sleep mode. For Home Assistant webhook."""
|
||||
global is_sleeping
|
||||
global is_sleeping, current_optimal_emote, current_optimal_animation
|
||||
global blink_emote, blink_animation, blinking_until
|
||||
is_sleeping = False
|
||||
current_optimal_emote, current_optimal_animation = random.choice(OPTIMAL_EMOTES)
|
||||
if random.random() < IDLE_EXPRESSION_CHANCE:
|
||||
blink_emote, blink_animation = random.choice(IDLE_EMOTES)
|
||||
blinking_until = time.time() + random.uniform(1, 2)
|
||||
state = write_status()
|
||||
return jsonify({"status": "awake", "current_state": state}), 200
|
||||
|
||||
|
||||
74
index.html
74
index.html
@@ -217,7 +217,7 @@
|
||||
const emoteEl = document.getElementById("emote");
|
||||
const messageEl = document.getElementById("message");
|
||||
const POLL_INTERVAL = 2000;
|
||||
const VERSION = "v1.5.0";
|
||||
const VERSION = "v2.0.0";
|
||||
|
||||
// Sound system
|
||||
let audioCtx = null;
|
||||
@@ -304,8 +304,69 @@
|
||||
setTimeout(() => playTone(1047, 0.2), 300);
|
||||
}
|
||||
|
||||
function playDoorbellSound() {
|
||||
playTone(880, 0.3, "sine", 0.12);
|
||||
setTimeout(() => playTone(659, 0.4, "sine", 0.12), 350);
|
||||
}
|
||||
function playKnockSound() {
|
||||
playTone(200, 0.08, "square", 0.15);
|
||||
setTimeout(() => playTone(200, 0.08, "square", 0.15), 150);
|
||||
setTimeout(() => playTone(200, 0.08, "square", 0.15), 300);
|
||||
}
|
||||
function playDingSound() {
|
||||
playTone(1046, 0.4, "sine", 0.1);
|
||||
}
|
||||
function playBlipSound() {
|
||||
playTone(1200, 0.05, "sine", 0.07);
|
||||
}
|
||||
function playSirenSound() {
|
||||
playTone(880, 0.15, "sawtooth", 0.12);
|
||||
setTimeout(() => playTone(660, 0.15, "sawtooth", 0.12), 180);
|
||||
setTimeout(() => playTone(880, 0.15, "sawtooth", 0.12), 360);
|
||||
setTimeout(() => playTone(660, 0.15, "sawtooth", 0.12), 540);
|
||||
}
|
||||
function playTadaSound() {
|
||||
playTone(392, 0.08, "sine", 0.1);
|
||||
setTimeout(() => playTone(392, 0.08, "sine", 0.1), 100);
|
||||
setTimeout(() => playTone(784, 0.4, "sine", 0.13), 220);
|
||||
}
|
||||
function playPingSound() {
|
||||
playTone(1047, 0.15, "sine", 0.1);
|
||||
}
|
||||
function playBubbleSound() {
|
||||
playTone(400, 0.06, "sine", 0.06);
|
||||
setTimeout(() => playTone(600, 0.04, "sine", 0.04), 40);
|
||||
}
|
||||
function playFanfareSound() {
|
||||
playTone(523, 0.1, "sine", 0.1);
|
||||
setTimeout(() => playTone(659, 0.1, "sine", 0.1), 120);
|
||||
setTimeout(() => playTone(784, 0.1, "sine", 0.1), 240);
|
||||
setTimeout(() => playTone(1047, 0.15, "sine", 0.12), 360);
|
||||
setTimeout(() => playTone(784, 0.08, "sine", 0.1), 520);
|
||||
setTimeout(() => playTone(1047, 0.3, "sine", 0.15), 620);
|
||||
}
|
||||
|
||||
// Alarm — loops until manually stopped
|
||||
let alarmInterval = null;
|
||||
function playAlarmTick() {
|
||||
playTone(880, 0.15, "square", 0.2);
|
||||
setTimeout(() => playTone(660, 0.15, "square", 0.2), 200);
|
||||
}
|
||||
function startAlarm() {
|
||||
if (alarmInterval) return;
|
||||
playAlarmTick();
|
||||
alarmInterval = setInterval(playAlarmTick, 500);
|
||||
}
|
||||
function stopAlarm() {
|
||||
if (alarmInterval) {
|
||||
clearInterval(alarmInterval);
|
||||
alarmInterval = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Play sound by name
|
||||
function playSoundByName(name) {
|
||||
if (name === "alarm") { startAlarm(); return; }
|
||||
const sounds = {
|
||||
chime: playChimeSound,
|
||||
alert: playAlertSound,
|
||||
@@ -314,6 +375,15 @@
|
||||
success: playSuccessSound,
|
||||
notify: playNotifySound,
|
||||
recovery: playRecoverySound,
|
||||
doorbell: playDoorbellSound,
|
||||
knock: playKnockSound,
|
||||
ding: playDingSound,
|
||||
blip: playBlipSound,
|
||||
siren: playSirenSound,
|
||||
tada: playTadaSound,
|
||||
ping: playPingSound,
|
||||
bubble: playBubbleSound,
|
||||
fanfare: playFanfareSound,
|
||||
};
|
||||
if (sounds[name]) {
|
||||
sounds[name]();
|
||||
@@ -333,6 +403,7 @@
|
||||
playSoundByName(customSound);
|
||||
lastCustomSound = customSound;
|
||||
} else if (!customSound) {
|
||||
stopAlarm(); // stop any looping alarm
|
||||
lastCustomSound = null;
|
||||
}
|
||||
|
||||
@@ -363,6 +434,7 @@
|
||||
|
||||
// Handle tap - enable sound and show reaction
|
||||
document.body.addEventListener("click", () => {
|
||||
stopAlarm(); // stop any looping alarm
|
||||
// Enable sound on first tap (browser autoplay policy)
|
||||
if (!soundEnabled) {
|
||||
soundEnabled = true;
|
||||
|
||||
10
openapi.yaml
10
openapi.yaml
@@ -313,6 +313,16 @@ components:
|
||||
- critical
|
||||
- success
|
||||
- notify
|
||||
- doorbell
|
||||
- knock
|
||||
- ding
|
||||
- blip
|
||||
- siren
|
||||
- tada
|
||||
- ping
|
||||
- bubble
|
||||
- fanfare
|
||||
- alarm
|
||||
- none
|
||||
example: "chime"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user