5.8 KiB
5.8 KiB
## Mission Control Dashboard (Python) — Consolidating
Status: 🔄 Combined with Next.js version — See TLC project
Location:
Tech: Python/Flask + MySQL + Home Assistant API
Location:
C:\web\htdocs\mission-control-py
URL: http://localhost:5050
URL (network): http://192.168.0.34:5050Tech: Python/Flask + MySQL + Home Assistant API
Quick Reference
| Command | Where |
|---|---|
| Run server | cd C:\web\htdocs\mission-control-py && python app.py |
| Restart | Server auto-reloads on file changes |
| Port | 5050 (Frigate-safe) |
Pages
| Route | File | Purpose |
|---|---|---|
/ |
dashboard.html |
Home: Gateway status, Cron jobs, Weather, Projects, Tasks |
/admin |
admin.html |
CRUD for Projects/Tasks in MySQL |
/news |
news.html |
Last 10 news briefs (JSON archive) |
/alerts |
alerts.html |
System alerts from Job Verifier cron |
/calendar |
calendar.html |
HA calendar + 24 F1 races |
/memory |
memory.html |
Memory file stats, cleanup candidates |
File Structure
mission-control-py/
├── app.py # Main Flask app, routes
├── api/
│ ├── gateway.py # get_gateway_status(), get_cron_jobs()
│ ├── ha_calendar.py # HA calendar API wrapper
│ └── memory_files.py # Memory file scanner
├── templates/
│ ├── base.html # Master template
│ ├── dashboard.html # Home page
│ ├── admin.html # Admin CRUD
│ ├── news.html # News briefs archive
│ ├── alerts.html # System alerts
│ ├── calendar.html # HA calendar
│ └── memory.html # Memory file stats
├── static/
│ └── style.css # All styles
├── outputs/
│ ├── news/ # YYYY-MM-DD.json, latest.json
│ └── alerts/ # latest.json
└── models/
└── models.py # Project, Task (MySQL)
Features
Caching (5-minute TTL)
- Gateway status cached in
_cachedict - Cron jobs cached
- Weather cached
- Location:
app.py→_CACHE_TTL = timedelta(minutes=5)
Weather
- Source:
weather.homeHA entity - API:
GET /api/states/weather.home - Location:
get_weather()inapp.py - Fallback: Shows "--" if HA unavailable
Calendar
- Source: HA
calendar.appointmentsentity - Fetch API:
GET /api/calendars/calendar.appointments?start=...&end=... - Add API:
POST /api/services/calendar/create_event - Location:
api/ha_calendar.py - Known Issue: Date range filter may not work correctly (March 3 event not showing)
News Briefs
- Source: Cron job output JSON
- Files:
outputs/news/latest.json+outputs/news/YYYY-MM-DD.json - Format:
{title, date, generated_at, content, sources, summary} - Crontab: Daily 8 AM →
openclaw cron run 3cf50074-...
Alerts
- Source: Job Verifier cron output JSON
- File:
outputs/alerts/latest.json - Format:
{date, generated_at, alerts: [{level, message, time, ...}]} - Crontab: Daily 9 AM →
openclaw cron run 8e2b06ee-...
Memory Files
- Source:
C:\Users\admin\.openclaw\workspace\memory\*.md - Features: Line count, TODO count, cleanup scoring
- Location:
api/memory_files.py
Known Issues & Fixes
| Issue | Status | Fix |
|---|---|---|
| Calendar events beyond 10 days not showing | KNOWN | Date range filter bug — March 3 event (11 days out) not displaying |
| Double "°F" in weather | FIXED | Strip HA unit before adding; get_weather() in app.py |
| Calendar agent creates cron jobs instead of calendar events | KNOWN | Agent using cron.add instead of ha_calendar.add() — needs fix |
HA API Reference
Base URL: http://192.168.0.39:8123
Token: See TOOLS.md or api/ha_calendar.py
| Endpoint | Method | Description |
|---|---|---|
/api/states/weather.home |
GET | Current weather state |
/api/calendars |
GET | List calendars |
/api/calendars/calendar.appointments |
GET | Get appointments (params: start, end) |
/api/services/calendar/create_event |
POST | Add event (body: entity_id, summary, start_date_time, end_date_time) |
Auth: Header Authorization: Bearer <token>
Cron Jobs Integrated
| Job Name | ID | Schedule | Output |
|---|---|---|---|
| Daily News Brief | 3cf50074-8736-423e-ac41-6e6fb807bfee |
0 8 * * * (8 AM) | JSON + Discord + /news |
| Job Verifier Daily | 8e2b06ee-f2ea-4b33-ae39-23cf04b1a657 |
0 9 * * * (9 AM) | JSON + /alerts |
Configuration
MySQL Connection:
- Database:
alexai - Tables:
projects,tasks - Config:
config.py→SQLALCHEMY_DATABASE_URI
HA Token:
- In
api/ha_calendar.pyandapp.py - Falls back to env var
HA_TOKEN
Debugging Tips
-
Check HA directly:
python -c " import requests r = requests.get('http://192.168.0.39:8123/api/calendars/calendar.appointments', params={'start': '2026-03-03T00:00:00', 'end': '2026-03-04T00:00:00'}, headers={'Authorization': 'Bearer <token>'}) print(r.json()) " -
Test API directly:
from api.ha_calendar import get_calendar_events, add_calendar_event events = get_calendar_events('calendar.appointments', days=14) print([e['summary'] for e in events]) -
Clear cache: Restart server (auto-reloads)
-
Check logs: Terminal output shows "Starting Mission Control..."
Changes Log
| Date | Change |
|---|---|
| 2026-02-19 | Initial build, 5 pages |
| 2026-02-20 | Added weather, calendar, memory, F1 races (24 races added) |
| 2026-02-20 | Fixed double °F in weather |
| 2026-02-20 | Calendar agent created (has bug - creates cron instead of events) |
Last Updated: 2026-02-20 Maintainer: Corey's Agent