# MCP Backup Test Session - 2026-07-24

## Goal
Test ha-direct MCP's auto-backup feature by creating, saving, and modifying an automation.

## Status
- Automation WAS created successfully (despite error message)
- User deleted it manually
- Session interrupted for full restart

## Key Findings
1. **ha-direct has an asyncio bug**: `ha_config_set_automation` throws `INTERNAL_ERROR: Task got Future attached to a different loop` but the automation still gets created
2. **Two MCP servers are connected**:
   - `homeassistant` - Direct HA integration (prefix: `homeassistant_*`)
   - `ha-direct` - Best practices skill + automation CRUD (prefix: `ha-direct_ha_*`)
3. **BestPracticeKey**: Required for write tools when strict mode is ON. Key rotates hourly, read from SKILL.md

## Test Automation Created
```yaml
alias: "MCP Backup Test"
description: "Test automation to verify ha-direct backup functionality"
triggers:
  - trigger: state
    entity_id: sun.sun
    to: above_horizon
actions:
  - action: notify.notify
    data:
      title: "MCP Test"
      message: "Automation created via ha-direct!"
```

## Next Steps After Restart
1. Recreate the test automation using `ha_config_set_automation`
2. Verify backup was created using `ha_manage_backup(scope="edits", action="list")`
3. Modify the automation
4. Verify new backup was created
5. Test restore from backup

## Command Sequence
```
# 1. Get BestPracticeKey (read SKILL.md)
ha-direct_ha_get_skill_guide(skill='home-assistant-best-practices', file='SKILL.md')

# 2. Create automation (include BestPracticeKey)
ha-direct_ha_config_set_automation(config={...}, BestPracticeKey="I-HAVE-READ-THE-BEST-PRACTICES-GUIDE-bd08e62b")

# 3. List backups to verify
ha-direct_ha_manage_backup(scope="edits", action="list")

# 4. Modify automation (get identifier from step 2)
ha-direct_ha_config_set_automation(identifier="automation.entity_id", config={...}, BestPracticeKey="...")

# 5. Verify new backup
ha-direct_ha_manage_backup(scope="edits", action="list")
```

## Bug Report Filed
- Error: INTERNAL_ERROR on ha_config_set_automation
- Details: asyncio event loop mismatch
- Report saved: /data/.local/share/opencode/tool-output/tool_f95b39529001j266BHbdc6n5ve
