divoom-cli
Command line tool built on top of divoom APIs for controlling divoom devices, like pixoo (and from how divoom's api/doc organizes, maybe more in the future).
# Check current channel
> divoom-cli 192.168.0.123 channel get
clock
# Set channel to clock with id 100
> divoom-cli 192.168.0.164 channel set-clock 100
# Get clock channel info
> divoom-cli 192.168.0.164 channel get-clock
---
clock-id: 100
brightness: 100
Installation
Cargo
How to use
It is straight forward to use the command line tool. Usually, we do it in 2 steps:
- Use device discovery API to find all devices in the LAN that we are in.
- Use device APIs to control the devices. No login/authentication is needed in the process.
Discover devices in the same LAN
> divoom-cli
Use Devices APIs to control the device
All device APIs are having the same format:
So we can run the commands like below:
# Check current channel
> divoom-cli
# Check current clock
> divoom-cli
# Set channel to clock with id 100
> divoom-cli
# Create a text animation
> divoom-cli
# Play a gif from Internet
> divoom-cli )
# Send a raw request
#
# NOTICE: the double quotes in json string passed into the program needs to escaped with '\',
# otherwise, rust runtime (not structopt) will eat them before reaching main function, even we
# pass the whole string as a string.
> divoom-cli
Parameter/Output format
By default, divoom-cli uses yaml as output format with all field names in kebab-case
. And beside yaml, we support json format too.
To specify the output format, we can use -o
parameter:
> divoom-cli
}
> divoom-cli
For values, divoom-cli always expect camelCase
to be used, both in parameter and output.
> divoom-cli
> divoom-cli
More help
We can find more info in the commmand help like below.
> divoom-cli
<device-address> Device
)
Debugging
To debug and see the logs and the raw request that we send, we can use RUST_LOG
environment variable to change the logging level to debug
to enable the logs:
On windows with powershell:
$env:RUST_LOG="debug"; divoom-cli 192.168.0.123 channel get
On Windows with cmd:
set RUST_LOG=debug && divoom-cli 192.168.0.164 channel get
And on linux:
RUST_LOG=debug
Then we will see the output log like below:
[2022-07-10T00:33:50Z DEBUG divoom::clients::common::divoom_rest_client] Sending request: Url = "http://192.168.0.123/post", Body = "{"Command":"Channel/GetIndex"}"
[2022-07-10T00:33:50Z DEBUG reqwest::connect] starting new connection: http://192.168.0.123/
[2022-07-10T00:33:50Z DEBUG hyper::client::connect::http] connecting to 192.168.0.123:80
[2022-07-10T00:33:50Z DEBUG hyper::client::connect::http] connected to 192.168.0.123:80
[2022-07-10T00:33:50Z DEBUG hyper::proto::h1::io] flushed 107 bytes
[2022-07-10T00:33:50Z DEBUG hyper::proto::h1::io] parsed 2 headers
[2022-07-10T00:33:50Z DEBUG hyper::proto::h1::conn] incoming body is chunked encoding
[2022-07-10T00:33:50Z DEBUG hyper::proto::h1::decode] incoming chunked header: 0x22 (34 bytes)
[2022-07-10T00:33:50Z DEBUG reqwest::async_impl::client] response '200 OK' for http://192.168.0.123/post
[2022-07-10T00:33:50Z DEBUG divoom::clients::common::divoom_rest_client] Response header received: StatusCode = 200
[2022-07-10T00:33:50Z DEBUG hyper::proto::h1::conn] incoming body completed
[2022-07-10T00:33:50Z DEBUG hyper::client::pool] pooling idle connection for ("http", 192.168.0.123)
[2022-07-10T00:33:50Z DEBUG divoom::clients::common::divoom_rest_client] Response received: Body = "{"error_code": 0, "SelectIndex":3}"
---
customPage
To revert it back, we can use the same way to set the RUST_LOG
to warn
level:
> $env:RUST_LOG="warn"; divoom-cli 192.168.0.123 channel get
---
customPage
API && SDK
If you are interested in the APIs that this tool is calling and the rust SDK that it uses, please check it here: https://github.com/r12f/divoom/blob/main/README.md.
License
Apache-2.0: https://www.apache.org/licenses/LICENSE-2.0