From 99350853ca0d052617a8fe4f54669f9458a03043 Mon Sep 17 00:00:00 2001 From: sigil-03 Date: Thu, 17 Apr 2025 18:33:09 -0600 Subject: [PATCH] update README to actually be helpful --- README.md | 58 +++++++++++++++++++++++++++++++++++++++++++++++++---- config.toml | 8 +++++--- 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d4dd52e..09e892f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,57 @@ -CLI application for interfacing with powered devices. +# POWER +this repository provides both +1. modular library for interfacing with powered devices +2. CLI application which uses this library to control powered devices from the command line -in this case, tasmota smart outlets being used on the hydroponics project +**IMPORTANT:** this is a work in progress, and the API will likely have breaking changes as it grows. ADDITIONALLY, currently there is only trait implementations for Tasmota outlets, however other devices can be supported by implementing these traits for your device-specific API. You can use `tasmota.rs` as an example of how to do this. once implemented, your devices will be compatible with this library. +# CLI +## BUILDING THE CLI +with a working rust toolchain on your machine, run the following: -TODO: -* add reqwest support to access the tasmota outlets \ No newline at end of file +`cargo build --release --bin cli` + +once built, the CLI binary will be available at the following path: +`/target/release/cli` + +## CONFIGURING THE SYSTEM DESCRIPTION FILE +a `system` consists of a number of `components` which are defined in a configuration `toml` file. + +an example, `config.toml` has been provided. + +each entry corresponds to a `component` and provides a `name` as well as the `target` IP address of the (in this case tasmota) power device. + +```toml +components = [ + {name="OUTLET 1", target="OUTLET_1_IP"}, # OUTLET 1 + {name="OUTLET 2", target="OUTLET_2_IP"}, # OUTLET 2 + {name="OUTLET 3", target="OUTLET_3_IP"}, # OUTLET 3 ... +] +``` + +## RUNNING THE CLI +the CLI takes as an argument the `config-file` (described above) as well as a subcommand. + +more usage information about the CLI can be obtained by running + +`./cli help` + +## COMMANDS +### MONITOR +the `monitor` command will output the power consumption of the components listed in the config file. + +example: +```log +OUTLET_1 +* POWER: 31W +------------------ +OUTLET_2 +* POWER: 0W +------------------ +OUTLET_3 +* POWER: 0W +------------------ +``` + +### SET +the `set` command allows a user to set the power state of a `component` at a given `index`. `component`s are indexed starting at 0 in the order they are defined in your configuration file. \ No newline at end of file diff --git a/config.toml b/config.toml index 43620fe..a3605da 100644 --- a/config.toml +++ b/config.toml @@ -1,3 +1,5 @@ -target = [ - "YOUR IP HERE" - ] \ No newline at end of file +components = [ + {name="OUTLET 1", target="OUTLET_1_IP"}, # OUTLET 1 + {name="OUTLET 2", target="OUTLET_2_IP"}, # OUTLET 2 + {name="OUTLET 3", target="OUTLET_3_IP"}, # OUTLET 3 ... +] \ No newline at end of file