switchbot_api/
lib.rs

1//! This is a Rust library to interact with the [SwitchBot API]
2//! and control your SwitchBot devices programmatically.
3//!
4//! For a command line tool,
5//! please see the [`switchbot-cli`][cli-crate] crate.
6//!
7//! [SwitchBot API]: https://github.com/OpenWonderLabs/SwitchBotAPI
8//! [cli-crate]: https://crates.io/crates/switchbot-cli
9//!
10//! # Examples
11//! ```no_run
12//! # use switchbot_api::{CommandRequest, SwitchBot};
13//! # async fn test(token: &str, secret: &str) -> anyhow::Result<()> {
14//! let mut switch_bot = SwitchBot::new_with_authentication(token, secret);
15//! switch_bot.load_devices().await?;
16//! let device = &switch_bot.devices()[0];
17//! let command = CommandRequest {
18//!     command: "turnOn".into(),
19//!     ..Default::default()
20//! };
21//! device.command(&command).await?;
22//! # Ok(())
23//! # }
24//! ```
25
26mod command_request;
27pub use command_request::*;
28mod conditional_expression;
29pub(crate) use conditional_expression::*;
30mod device;
31pub use device::*;
32mod device_list;
33pub use device_list::*;
34mod help;
35pub use help::*;
36mod markdown;
37pub use markdown::*;
38mod switch_bot;
39pub use switch_bot::*;
40mod switch_bot_service;
41pub use switch_bot_service::*;