|
1 | 1 | # OpenClash Manager |
2 | 2 |
|
3 | | -Home Assistant custom integration for managing and switching OpenClash configurations on OpenWrt routers via SSH. |
| 3 | +[](https://github.com/hacs/integration) |
| 4 | + |
4 | 5 |
|
5 | | -## Features |
6 | | - |
7 | | -- **Config Switching**: Select and apply different Clash YAML configurations. |
8 | | -- **Master Switch**: Enable or disable OpenClash globally. |
9 | | -- **Operation Mode**: Quickly switch between `rule`, `global`, and `direct` modes. |
10 | | -- **Service Control**: Restart OpenClash directly from Home Assistant. |
11 | | -- **Updates**: Trigger subscription and core updates. |
12 | | -- **Status Monitoring**: Real-time status sensor (running/stopped) and version information. |
13 | | -- **HomeKit Friendly**: Automatically creates individual switches for each configuration file, making it easy to expose specific configs to Apple Home. |
14 | | - |
15 | | -## How it works |
| 6 | +OpenClash Manager is a powerful Home Assistant custom integration designed to give you full control over your OpenClash configuration on OpenWrt routers via SSH. |
16 | 7 |
|
17 | | -The integration connects to your OpenWrt router over SSH and uses `uci` commands and service scripts to manage OpenClash. |
18 | | - |
19 | | -- **Config Switching**: Sets `openclash.config.config_path` and restarts the service. |
20 | | -- **Mode Switching**: Sets `openclash.config.operation_mode`. |
21 | | -- **Master Toggle**: Sets `openclash.config.enable`. |
22 | | - |
23 | | -## Install |
| 8 | +## Features |
24 | 9 |
|
25 | | -Copy `custom_components/openclash_manager` into your Home Assistant `custom_components` directory, then restart Home Assistant. |
| 10 | +- **🚀 Smart Config Switching**: Select and apply different Clash YAML configurations. Switch names are automatically cleaned up (removing `.yaml`) for a polished look. |
| 11 | +- **🛡️ Enable Toggle**: Turn OpenClash on or off globally with a simple switch. |
| 12 | +- **📡 Operation Modes**: Quickly switch between `Rule`, `Global`, and `Direct` modes. |
| 13 | +- **🔄 Service Control**: Restart OpenClash directly from Home Assistant buttons. |
| 14 | +- **🆙 Automatic Updates**: Trigger subscription updates and core updates from your dashboard. |
| 15 | +- **📶 Status Monitoring**: Real-time status sensor using the `CONNECTIVITY` class (perfect for HomeKit). |
| 16 | +- **🍏 Apple Home (HomeKit) Optimized**: |
| 17 | + - Entities are named and categorized for the best Apple Home experience. |
| 18 | + - Group multiple config switches into a single tile for a "Pro" device feel. |
| 19 | + - Includes a **Configuration URL** link directly to your router's OpenClash Luci dashboard. |
26 | 20 |
|
27 | | -## Setup |
| 21 | +## Installation |
28 | 22 |
|
29 | | -In Home Assistant, go to **Settings > Devices & services > Add integration** and search for **OpenClash Manager**. |
| 23 | +### Method 1: HACS (Recommended) |
30 | 24 |
|
31 | | -Default settings: |
| 25 | +1. Open **HACS** in Home Assistant. |
| 26 | +2. Click the three dots in the top right and select **Custom repositories**. |
| 27 | +3. Add `https://github.com/soulripper13/openclash_manager` with the category **Integration**. |
| 28 | +4. Click **Install**. |
| 29 | +5. Restart Home Assistant. |
32 | 30 |
|
33 | | -- SSH port: `22` |
34 | | -- SSH username: `root` |
35 | | -- Config directory: `/etc/openclash/config` |
36 | | -- Restart command: `/etc/init.d/openclash restart` |
| 31 | +### Method 2: Manual |
37 | 32 |
|
38 | | -The SSH user needs permission to run `uci`, read the config directory, and restart OpenClash. |
| 33 | +1. Download the latest release. |
| 34 | +2. Copy the `custom_components/openclash_manager` folder to your HA `custom_components` directory. |
| 35 | +3. Restart Home Assistant. |
39 | 36 |
|
40 | | -## Dashboard |
| 37 | +## Configuration |
41 | 38 |
|
42 | | -After setup, you can use the built-in entities in your dashboard. The integration also auto-registers a custom dashboard card resource (if available in `www/`) at: |
| 39 | +1. Go to **Settings > Devices & Services**. |
| 40 | +2. Click **Add Integration** and search for **OpenClash Manager**. |
| 41 | +3. Enter your router's SSH details: |
| 42 | + - **Host**: Your router's IP address. |
| 43 | + - **Port**: SSH port (default `22`). |
| 44 | + - **Username**: SSH username (usually `root`). |
| 45 | + - **Password**: SSH password. |
| 46 | + - **Config Directory**: Path to your Clash configs (default `/etc/openclash/config`). |
| 47 | + - **Restart Command**: The command used to restart OpenClash (default `/etc/init.d/openclash restart`). |
43 | 48 |
|
44 | | -```text |
45 | | -/openclash_manager/openclash-config-card.js |
46 | | -``` |
| 49 | +## Usage in Apple Home |
47 | 50 |
|
48 | | -## Apple Home (HomeKit) |
| 51 | +To get the best experience in Apple Home: |
| 52 | +1. Add the **HomeKit Bridge** integration in Home Assistant. |
| 53 | +2. Include the `switch.enable` and all `switch.*_config` entities. |
| 54 | +3. In the Apple Home app, long-press the **Enable** tile and select **Group with Other Accessories**. |
| 55 | +4. Group all OpenClash-related switches together. This creates a single professional-looking tile that expands to show all controls. |
49 | 56 |
|
50 | | -The integration creates one `switch` entity for each Clash config file. In the HomeKit Bridge options, include these generated switch entities to allow easy switching from Apple Home. |
| 57 | +## License |
51 | 58 |
|
52 | | -Turn on a config switch in Apple Home to apply that config. Turning off the active config switch is ignored because Clash requires one active config. |
| 59 | +MIT License. See [LICENSE](LICENSE) for details. |
0 commit comments