#!/usr/bin/env bash # Install OpenClaw Conversation custom component to Home Assistant set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" COMPONENT_NAME="openclaw_conversation" # Detect Home Assistant config directory if [[ -d "/config" ]]; then HA_CONFIG="/config" elif [[ -d "$HOME/.homeassistant" ]]; then HA_CONFIG="$HOME/.homeassistant" elif [[ -d "$HOME/homeassistant" ]]; then HA_CONFIG="$HOME/homeassistant" else echo "Error: Could not find Home Assistant config directory" echo "Please specify manually: ./install.sh /path/to/config" exit 1 fi # Allow override via command line if [[ $# -ge 1 ]]; then HA_CONFIG="$1" fi CUSTOM_COMPONENTS_DIR="$HA_CONFIG/custom_components" TARGET_DIR="$CUSTOM_COMPONENTS_DIR/$COMPONENT_NAME" echo "Installing OpenClaw Conversation custom component..." echo " Source: $SCRIPT_DIR/$COMPONENT_NAME" echo " Target: $TARGET_DIR" echo "" # Create custom_components directory if it doesn't exist mkdir -p "$CUSTOM_COMPONENTS_DIR" # Remove old installation if exists if [[ -d "$TARGET_DIR" ]]; then echo "Removing old installation..." rm -rf "$TARGET_DIR" fi # Copy component files cp -r "$SCRIPT_DIR/$COMPONENT_NAME" "$TARGET_DIR" # Verify installation if [[ -d "$TARGET_DIR" && -f "$TARGET_DIR/manifest.json" ]]; then echo "✓ Installation successful!" echo "" echo "Next steps:" echo " 1. Restart Home Assistant" echo " 2. Go to Settings → Devices & Services → Add Integration" echo " 3. Search for 'OpenClaw Conversation'" echo " 4. Configure the settings (host: localhost, port: 8081)" echo "" echo " Or add to configuration.yaml:" echo " openclaw_conversation:" echo " openclaw_host: localhost" echo " openclaw_port: 8081" echo " agent_name: main" echo " timeout: 30" else echo "✗ Installation failed" exit 1 fi