A command-line interface (CLI) tool written in Rust to control SwitchBot devices using the SwitchBot Web API (v1.1).
SwitchBot Web API(v1.1)を使用してSwitchBotデバイスを操作するための、Rust製コマンドラインツールです。
Retrieve all SwitchBot devices linked to your account, displaying details such as name, device ID, and device type.
アカウントにリンクされているすべてのSwitchBotデバイスを取得し、名前・ID・種類などを表示します。
Send commands to supported devices directly from your terminal.
The following command types are available:
対応デバイスに対して、ターミナルからコマンドを直接送信できます。対応しているコマンドは以下のとおりです:
-
TurnOn/TurnOff:
Power devices on or off
デバイスの電源をオン/オフにします -
SetBrightness:
Set brightness level (numeric value)
明るさを数値で設定します -
SetColor:
Specify RGB color values
RGB値で色を指定します -
SetColorTemperature:
Set color temperature
色温度を設定します -
AcSetAll:
Set air conditioner temperature, mode, fan speed, etc., all at once
エアコンの温度、モード、風量などを一括設定します -
Custom: (⚠️ Experimental feature / 試験的機能)
Send custom commands by specifyingcommandType,command, andparametermanually
commandType・command・parameterを手動で指定し、カスタムコマンドを送信できます
-
Rust 1.75 or higher (stable)
Requires a stable Rust toolchain version 1.75 or later.
本ツールはRust製で、バージョン1.75以上の安定版が必要です。 -
A SwitchBot account with cloud service enabled
You must enable cloud service in the SwitchBot app settings.
SwitchBotアプリでクラウドサービスを有効にしておく必要があります。 -
SwitchBot Open API token
You can obtain the API token from the app under "Profile".
APIトークンはSwitchBotアプリの「プロフィール」から取得できます。
Clone the repository and build the project:
リポジトリをクローンし、Cargoでビルドしてください:
$ git clone https://github.com/show-t/switchbot-cli-tool.git
$ cd switchbot-cli-tool
$ cargo build --releaseThe compiled binary will be located at:
ビルド後の実行ファイルは以下の場所に生成されます:
target/release/switchbot-cliOptionally, move the binary to a directory in your PATH:
必要に応じて、バイナリをPATHの通ったディレクトリに移動してください:
$ mv target/release/switchbot-cli /usr/local/bin/Create a .env file in the project root and add your SwitchBot token:
プロジェクトのルートに .env ファイルを作成し、SwitchBot のトークンを設定してください:
SWITCHBOT_API_HOST='https://api.switch-bot.com/v1.1'
SWITCHBOT_TOKEN=<your_token_here>
SWITCHBOT_SECRET=<your_secret_here>
RUST_LOG=<log_level>$ switchbot-cli-tool list- You can control a device by specifying its device ID or alias.
デバイスIDまたはエイリアスを指定して操作できます。
$ switchbot-cli-tool exec \
--device livingroom-light \
--command on- You can also specify parameters using --values:
--values オプションでパラメータを渡すこともできます:
switchbot-cli-tool exec \
--device <your-device-id> \
--command set_brightness \
--values 128- on / off
- brightness
<1-100> - color
<r:0-255><g:0-255><b:0-255> - color_temp
<2700-6500> - ac
<temperature><mode:1-5><fan_ speed:1-4><power_state:on/off>
To use aliases, create a device_aliases.json file in the working directory with the following format:
エイリアスを使用するには、作業ディレクトリに以下の形式の device_aliases.json ファイルを作成してください。
Each key is the alias name, and each value is the actual device ID.
キーがエイリアス名、値が実際のデバイスIDです。
{
"livingroom-light": "01-xxxxxxxxxxxx-yyyyyyyy",
"bed_light": "02-xxxxxxxxxxxx-yyyyyyyy"
}Use switchbot-cli --help to explore all available options.
すべてのオプションは switchbot-cli --help で確認できます。
This project is licensed under the MIT License.
本プロジェクトは MIT ライセンスのもとで公開されています。
See the LICENSE file for more details.
詳細は LICENSE ファイルをご覧ください。
Created by show-t