Add /notify endpoint for Home Assistant integration
- New /notify endpoint: simple {"message": "", "duration": 5} API
- Uses Priority 3 (Notify) with auto-expiring TTL
- Updated CLAUDE.md with HA integration examples
- Updated README.md with new features and endpoints
- Added Docker detector to documentation
- Removed completed TODO items
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -223,6 +223,34 @@ def clear_event():
|
||||
return jsonify({"error": "Event not found"}), 404
|
||||
|
||||
|
||||
@app.route("/notify", methods=["POST"])
|
||||
def notify():
|
||||
"""
|
||||
Simple notification endpoint for Home Assistant.
|
||||
JSON: {"message": "text", "duration": 5}
|
||||
Shows the Notify emote with message, auto-expires after duration.
|
||||
"""
|
||||
data = request.get_json(force=True) if request.data else {}
|
||||
message = data.get("message", "")
|
||||
duration = int(data.get("duration", 5))
|
||||
|
||||
# Generate unique ID to avoid conflicts
|
||||
event_id = f"ha_notify_{int(time.time() * 1000)}"
|
||||
|
||||
event = {
|
||||
"priority": 3, # Notify priority
|
||||
"message": message,
|
||||
"timestamp": time.time(),
|
||||
"ttl": time.time() + duration,
|
||||
}
|
||||
|
||||
with events_lock:
|
||||
active_events[event_id] = event
|
||||
|
||||
state = write_status()
|
||||
return jsonify({"status": "ok", "id": event_id, "current_state": state}), 200
|
||||
|
||||
|
||||
@app.route("/sleep", methods=["POST"])
|
||||
def sleep_mode():
|
||||
"""Enter sleep mode. For Home Assistant webhook."""
|
||||
|
||||
Reference in New Issue
Block a user