#switch-bot #api #swbcli

app swbcli

A simple CLI tool for SwitchBot (v1.1)

1 unstable release

Uses new Rust 2024

new 0.1.0 Apr 22, 2025

#203 in Web programming

MIT license

16KB
120 lines

SwitchBot API CLI Tool

A simple CLI tool for interacting with the SwitchBot API. This tool allows you to list devices, check device statuses, and send commands to devices.

Installation

This project is written in Rust and can be installed using cargo.

Run the following commands to install the tool:

cargo install swbcli

Usage

This CLI tool interacts with the SwitchBot API to perform various actions such as listing devices, checking device statuses, and sending commands. Results will be returned in JSON format.

Command Format

swbcli --token|-t <token> --secret|-s <secret> <action> [options]
  • --token or -t: Your SwitchBot API token (required)
  • --secret or -s: Your SwitchBot API secret (required)
  • <action>: The action to perform (required)
    • list: List all devices
    • status: Get the status of a specific device
    • control: Send a command to a specific device

Action-Specific Options

  • list: No additional options
  • status:
    • --device_id or -i: The ID of the device (required)
  • control:
    • --device_id or -i: The ID of the device (required)
    • --cmd or -c: The command to send (required)
    • --param or -p: The command parameters in JSON format (required)

Examples

List all devices

swbcli -t <TOKEN> -s <SECRET> list

Get the status of a device

swbcli -t <TOKEN> -s <SECRET> status -i <DEVICE_ID>

Send a command to a device

# Bot: Turn on the switch
swbcli -t <TOKEN> -s <SECRET> control -i <DEVICE_ID> -c turnOn -p default

For detailed information about commands and parameters, please refer to https://github.com/OpenWonderLabs/SwitchBotAPI.

License

This project is licensed under the MIT License.

Dependencies

~9–22MB
~296K SLoC