Crates.io | sbplug |
lib.rs | sbplug |
version | 0.0.4 |
source | src |
created_at | 2023-06-26 15:29:13.728651 |
updated_at | 2023-07-15 01:02:34.005662 |
description | CLI tool to control SwitchBot Plug. |
homepage | https://github.com/ezotaka/sbplug |
repository | https://github.com/ezotaka/sbplug.git |
max_upload_size | |
id | 900404 |
size | 49,080 |
sbplug is a command line interface (CLI) tool that allows you to control your SwitchBot Plug devices. You can list, turn on/off, and check the status of your devices directly from the command line.
Before you can use sbplug, you need to set the SwitchBot app token as an environment variable named SWITCHBOT_TOKEN
. You can get this token from the SwitchBot app. For details on how to retrieve the token, please refer to the SwitchBot API documentation.
After setting the environment variable, you can use the sbplug
command followed by a subcommand. Use the -h/--help
flag to print help information.
$ sbplug <SUBCOMMAND>
help
: Prints help information for sbplug or its subcommands.list
: Lists all the devices you have.off
: Turns off a device.on
: Turns on a device.status
: Checks the status of a device.Here are some examples of how to use sbplug:
list
subcommand:$ sbplug list
The output will show the device ID, device name, and power status:
1) AAAAAAAAAAAAAA Plug-Mini-AAAA on
2) BBBBBBBBBBBBBB Plug-Mini-BBBB on
on
subcommand followed by the device ID:$ sbplug on AAAAAAAAAAAAAA
or
$ sbplug on 1
The output will show success
if the operation was successful.
off
subcommand followed by the device ID:$ sbplug off BBBBBBBBBBBBBB
Again, the output will show success
if the operation was successful.
status
subcommand followed by the device ID:$ sbplug status AAAAAAAAAAAAAA
The output will display detailed information about the device:
DeviceId: AAAAAAAAAAAAAA
DeviceType: Plug Mini (JP)
ElectricCurrent: 0
ElectricityOfDay: 50
HubDeviceId: CCCCCCCCCCCCCC
Power: on
Voltage: 100.3
Weight: 0
Remember, you can use either the device ID or the device's index number from the list
subcommand when using the on
, off
, and status
subcommands.