denki 0.2.0

CLI for controlling TP-Link smart home devices — denki (電気) means electricity in Japanese
Documentation
#![allow(dead_code, unused_imports)]

//! Tapo API Client.
//!
//! Tested with light bulbs (L430C, L430P, L510, L520, L530, L535, L610, L630),
//! light strips (L900, L920, L930), plugs (P100, P105, P110, P110M, P115, P125, P125M, TP10),
//! power strips (P300, P304M, P306, P316M), hubs (H100, H110, H200, H500),
//! switches (S200B, S200D, S210), sensors (KE100, T100, T110, T300, T310, T315)
//! and cameras (C120, C210, C220, C225, C325WB, C520WS, TC40, TC70).
//!
//! # Features
//!
//! All features are off by default.
//!
//! - `debug` - exposes additional methods that are valuable in debug scenarios or when investigating new device functionality.
//! - `json-schema` - derives [`schemars::JsonSchema`](https://docs.rs/schemars) on public types so they can be serialized into a JSON Schema.
//! - `python` - enables [PyO3](https://pyo3.rs) bindings used by the `tapo-py` crate. Not intended for direct use from Rust.
//!
//! # Example with L530
//! ```ignore
//! use std::{env, thread, time::Duration};
//!
//! use tapo::{requests::Color, ApiClient};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//!     let tapo_username = env::var("TAPO_USERNAME")?;
//!     let tapo_password = env::var("TAPO_PASSWORD")?;
//!     let ip_address = env::var("IP_ADDRESS")?;
//!
//!     let device = ApiClient::new(tapo_username, tapo_password)
//!         .l530(ip_address)
//!         .await?;
//!
//!     println!("Turning device on...");
//!     device.on().await?;
//!
//!     println!("Setting the brightness to 30%...");
//!     device.set_brightness(30).await?;
//!
//!     println!("Setting the color to `Chocolate`...");
//!     device.set_color(Color::Chocolate).await?;
//!
//!     println!("Waiting 2 seconds...");
//!     thread::sleep(Duration::from_secs(2));
//!
//!     println!("Setting the color to `Deep Sky Blue` using the `hue` and `saturation`...");
//!     device.set_hue_saturation(195, 100).await?;
//!
//!     println!("Waiting 2 seconds...");
//!     thread::sleep(Duration::from_secs(2));
//!
//!     println!("Setting the color to `Incandescent` using the `color temperature`...");
//!     device.set_color_temperature(2700).await?;
//!
//!     println!("Waiting 2 seconds...");
//!     thread::sleep(Duration::from_secs(2));
//!
//!     println!("Using the `set` API to change multiple properties in a single request...");
//!     device
//!         .set()
//!         .brightness(50)
//!         .color(Color::HotPink)
//!         .send(&device)
//!         .await?;
//!
//!     println!("Waiting 2 seconds...");
//!     thread::sleep(Duration::from_secs(2));
//!
//!     println!("Turning device off...");
//!     device.off().await?;
//!
//!     let device_info = device.get_device_info().await?;
//!     println!("Device info: {device_info:?}");
//!
//!     let device_usage = device.get_device_usage().await?;
//!     println!("Device usage: {device_usage:?}");
//!
//!     Ok(())
//! }
//! ```
//!
//! See [more examples](https://github.com/mihai-dinculescu/tapo/tree/main/tapo/examples).

mod api;
mod error;
mod utils;

#[cfg(any())]
pub mod python;

pub mod requests;
pub mod responses;

pub use api::*;
pub use error::*;

#[cfg(test)]
mod logging_tests;