commit 9a1c697afa64267c322b07dedbb18d97d1216372 Author: xiaoou Date: Fri Jul 10 11:06:02 2026 +0800 v1.0.0: 朴小护智慧家居初版 diff --git a/deps.txt b/deps.txt new file mode 100644 index 0000000..175aab5 --- /dev/null +++ b/deps.txt @@ -0,0 +1,46 @@ +__TOTAL:45 +aiodns==4.0.4 +aiohttp==3.14.1 +aiohttp_cors==0.8.1 +aiohttp-fast-zlib==0.3.0 +aiohttp-asyncmdnsresolver==0.2.0 +aiozoneinfo==0.2.3 +annotatedyaml==1.0.2 +astral==2.2 +async-interrupt==1.2.2 +attrs==26.1.0 +atomicwrites-homeassistant==1.4.1 +audioop-lts==0.2.2 +awesomeversion==25.8.0 +bcrypt==5.0.0 +ciso8601==2.3.3 +cronsim==2.7 +fnv-hash-fast==2.0.3 +hass-nabucasa==2.2.0 +httpx==0.28.1 +home-assistant-bluetooth==2.0.0 +ifaddr==0.2.0 +Jinja2==3.1.6 +lru-dict==1.4.1 +PyJWT==2.12.1 +cryptography==48.0.1 +Pillow==12.2.0 +propcache==0.5.2 +pyOpenSSL==26.2.0 +orjson==3.11.9 +psutil-home-assistant==0.0.1 +python-slugify==8.0.4 +PyYAML==6.0.3 +requests==2.34.2 +securetar==2026.4.1 +SQLAlchemy==2.0.51 +standard-aifc==3.13.0 +standard-telnetlib==3.13.0 +ulid-transform==2.2.9 +uv==0.11.26 +voluptuous==0.15.2 +voluptuous-serialize==2.7.0 +voluptuous-openapi==0.4.1 +yarl==1.24.2 +webrtc-models==0.3.0 +zeroconf==0.150.0 diff --git a/hermes-prod.tar.gz b/hermes-prod.tar.gz new file mode 100644 index 0000000..2f07451 Binary files /dev/null and b/hermes-prod.tar.gz differ diff --git a/install-mac.sh b/install-mac.sh new file mode 100644 index 0000000..bcaf142 --- /dev/null +++ b/install-mac.sh @@ -0,0 +1,183 @@ +#!/bin/bash +# ============================================================ +# 朴小护智慧家居 v1.0.0 — Mac 一键安装脚本 +# ============================================================ +set -e + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' + +INSTALL_DIR="$HOME/.puxiaohu-smarthome" +HA_SRC="$INSTALL_DIR/ha-core" +HERMES_SRC="$INSTALL_DIR/hermes-prod" + +echo -e "${GREEN}========================================${NC}" +echo -e "${GREEN} 朴小护智慧家居 v1.0.0 — Mac 安装器${NC}" +echo -e "${GREEN}========================================${NC}" +echo "" + +# ---- 1. 检查系统 ---- +echo -e "${YELLOW}[1/6] 检查系统环境...${NC}" + +if [[ "$(uname)" != "Darwin" ]]; then + echo -e "${RED}错误: 此安装器仅支持 macOS${NC}" + exit 1 +fi + +ARCH=$(uname -m) +echo " 架构: $ARCH" + +# 检查 Homebrew +if ! command -v brew &>/dev/null; then + echo -e "${YELLOW} 安装 Homebrew...${NC}" + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +fi + +# ---- 2. 安装运行时 ---- +echo -e "${YELLOW}[2/6] 安装运行时依赖...${NC}" + +# Python 3.14 +if ! python3.14 --version &>/dev/null; then + echo " 安装 Python 3.14..." + brew install python@3.14 +fi +echo " Python: $(python3.14 --version)" + +# Node.js 20+ +if ! command -v node &>/dev/null || [[ $(node -v | cut -d. -f1 | tr -d 'v') -lt 20 ]]; then + echo " 安装 Node.js 22..." + brew install node@22 +fi +echo " Node.js: $(node --version)" +echo " npm: $(npm --version)" + +# ---- 3. 创建目录结构 ---- +echo -e "${YELLOW}[3/6] 创建安装目录...${NC}" +mkdir -p "$INSTALL_DIR" +mkdir -p "$INSTALL_DIR/config/custom_components" +mkdir -p "$INSTALL_DIR/config/www" + +# ---- 4. 安装 HomeAssistant (精简版) ---- +echo -e "${YELLOW}[4/6] 安装 HomeAssistant (朴小护精简版)...${NC}" + +# 解压源码 +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +tar xzf "$SCRIPT_DIR/puxiaohu-homeassistant-1.0.0.tar.gz" -C "$INSTALL_DIR/" +mv "$INSTALL_DIR/homeassistant" "$INSTALL_DIR/ha-core/" 2>/dev/null || true +# tar may have created ha-core structure already +if [ ! -d "$HA_SRC" ]; then + # tar extracted to current dir + mv "$INSTALL_DIR/pyproject.toml" "$INSTALL_DIR/ha-core/" 2>/dev/null || true +fi + +# 创建 venv +python3.14 -m venv "$INSTALL_DIR/venv" +source "$INSTALL_DIR/venv/bin/activate" + +# 安装 pip 依赖 +pip install --upgrade pip +pip install -r "$INSTALL_DIR/deps.txt" + +# 安装 HA +cd "$HA_SRC" 2>/dev/null || cd "$INSTALL_DIR" +pip install -e "$HA_SRC" 2>/dev/null || pip install "$HA_SRC" + +# 创建默认配置 +cat > "$INSTALL_DIR/config/configuration.yaml" << 'YAMLEOF' +# 朴小护智慧家居 — 精简配置 +homeassistant: + name: 朴小护智慧家居 + auth_providers: + - type: trusted_networks + trusted_networks: + - 127.0.0.1 + - 192.168.0.0/24 + allow_bypass_login: true + +default_config: + +http: + server_port: 8123 + +logger: + default: warning + +recorder: + db_url: sqlite:///config/home-assistant_v2.db + +# 小米设备 (安装后自动通过 MIoT 云发现) +# xiaomi_miio: 通过 config_entries API 添加 + +# TTS +tts: + - platform: edge_tts + language: zh-cn +YAMLEOF + +deactivate + +# ---- 5. 安装 Hermes Agent (精简版) ---- +echo -e "${YELLOW}[5/6] 安装 Hermes Agent...${NC}" + +tar xzf "$SCRIPT_DIR/hermes-prod.tar.gz" -C "$INSTALL_DIR/" + +# Hermes Python 依赖 +source "$INSTALL_DIR/venv/bin/activate" +pip install -r "$HERMES_SRC/pyproject.toml" 2>/dev/null || true +deactivate + +# Hermes Node.js 依赖 (仅 production, 无 workspace) +cd "$HERMES_SRC" +npm install --production --workspaces=false 2>&1 | tail -3 + +echo -e "${GREEN} Hermes 安装完成${NC}" + +# ---- 6. 创建启动服务 ---- +echo -e "${YELLOW}[6/6] 创建启动服务...${NC}" + +# HA launchd plist +cat > ~/Library/LaunchAgents/com.puxiaohu.homeassistant.plist << PLISTEOF + + + + + Label + com.puxiaohu.homeassistant + ProgramArguments + + $INSTALL_DIR/venv/bin/hass + -c + $INSTALL_DIR/config + + RunAtLoad + + KeepAlive + + StandardOutPath + $INSTALL_DIR/logs/ha.log + StandardErrorPath + $INSTALL_DIR/logs/ha-error.log + + +PLISTEOF + +mkdir -p "$INSTALL_DIR/logs" +launchctl load ~/Library/LaunchAgents/com.puxiaohu.homeassistant.plist 2>/dev/null || true + +echo "" +echo -e "${GREEN}========================================${NC}" +echo -e "${GREEN} 安装完成!${NC}" +echo -e "${GREEN}========================================${NC}" +echo "" +echo " 🏠 HomeAssistant: http://localhost:8123" +echo " 📁 配置目录: $INSTALL_DIR/config" +echo " 📁 www 目录: $INSTALL_DIR/config/www (放自定义前端)" +echo " 📝 日志: $INSTALL_DIR/logs/" +echo "" +echo " 下一步:" +echo " 1. 在浏览器打开 http://localhost:8123" +echo " 2. 将朴小护前端放入 $INSTALL_DIR/config/www/" +echo " 3. 启动 Hermes: cd $HERMES_SRC && python run_agent.py" +echo "" diff --git a/puxiaohu-homeassistant-1.0.0.tar.gz b/puxiaohu-homeassistant-1.0.0.tar.gz new file mode 100644 index 0000000..7cedb69 Binary files /dev/null and b/puxiaohu-homeassistant-1.0.0.tar.gz differ