Files
homeai/homeai-agent/skills/home-assistant/openclaw_bridge.py
Aodhan Collins 6a0bae2a0b feat(phase-04): Wyoming Satellite integration + OpenClaw HA components
## Voice Pipeline (P3)
- Replace openWakeWord daemon with Wyoming Satellite approach
- Add Wyoming Satellite service on port 10700 for HA voice pipeline
- Update setup.sh with cross-platform sed compatibility (macOS/Linux)
- Add version field to Kokoro TTS voice info
- Update launchd service loader to use Wyoming Satellite

## Home Assistant Integration (P4)
- Add custom conversation agent component (openclaw_conversation)
  - Fix: Use IntentResponse instead of plain strings (HA API requirement)
  - Support both HTTP API and CLI fallback modes
  - Config flow for easy HA UI setup
- Add OpenClaw bridge scripts (Python + Bash)
- Add ha-ctl utility for HA entity control
  - Fix: Use context manager for token file reading
- Add HA configuration examples and documentation

## Infrastructure
- Add mem0 backup automation (launchd + script)
- Add n8n workflow templates (morning briefing, notification router)
- Add VS Code workspace configuration
- Reorganize model files into categorized folders:
  - lmstudio-community/
  - mlx-community/
  - bartowski/
  - mradermacher/

## Documentation
- Update PROJECT_PLAN.md with Wyoming Satellite architecture
- Update TODO.md with completed Wyoming integration tasks
- Add OPENCLAW_INTEGRATION.md for HA setup guide

## Testing
- Verified Wyoming services running (STT:10300, TTS:10301, Satellite:10700)
- Verified OpenClaw CLI accessibility
- Confirmed cross-platform compatibility fixes
2026-03-08 02:06:37 +00:00

75 lines
2.0 KiB
Python

#!/usr/bin/env python3
"""OpenClaw Bridge for Home Assistant
This script acts as a bridge between Home Assistant and OpenClaw.
It can be called from HA via shell_command or command_line integration.
Usage:
python openclaw_bridge.py "Your message here"
Output:
{"response": "OpenClaw's response text"}
"""
import argparse
import json
import subprocess
import sys
from pathlib import Path
def call_openclaw(message: str, agent: str = "main", timeout: int = 30) -> str:
"""Call OpenClaw CLI and return the response."""
try:
result = subprocess.run(
["openclaw", "agent", "--message", message, "--agent", agent],
capture_output=True,
text=True,
timeout=timeout,
)
if result.returncode != 0:
return f"Error: OpenClaw failed with code {result.returncode}"
# Return stdout (the response)
return result.stdout.strip()
except subprocess.TimeoutExpired:
return "Error: OpenClaw command timed out"
except FileNotFoundError:
return "Error: openclaw command not found. Is OpenClaw installed?"
except Exception as e:
return f"Error: {str(e)}"
def main():
parser = argparse.ArgumentParser(
description="Bridge between Home Assistant and OpenClaw"
)
parser.add_argument("message", help="Message to send to OpenClaw")
parser.add_argument(
"--agent", default="main", help="Agent to use (default: main)"
)
parser.add_argument(
"--timeout", type=int, default=30, help="Timeout in seconds (default: 30)"
)
parser.add_argument(
"--raw", action="store_true", help="Output raw text instead of JSON"
)
args = parser.parse_args()
# Call OpenClaw
response = call_openclaw(args.message, args.agent, args.timeout)
if args.raw:
print(response)
else:
# Output as JSON for HA
output = {"response": response}
print(json.dumps(output))
if __name__ == "__main__":
main()