Expand description
Klafs Sauna Control Library
This crate provides a Rust client for interacting with the Klafs sauna control API. It handles authentication, session management, and provides typed access to sauna status and control functions.
§Features
- Async API using tokio
- Automatic cookie/session management
- Strongly typed request/response models
- Comprehensive error handling
- HTTP traffic debugging
§Example
use klafs_api::{KlafsClient, SaunaMode};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create client and authenticate
let client = KlafsClient::new()?;
client.login("user@example.com", "password").await?;
// Get sauna status
let status = client.get_status("your-sauna-uuid").await?;
println!("Connected: {}", status.is_connected);
println!("Powered On: {}", status.is_powered_on);
println!("Current Temperature: {}°C", status.current_temperature);
println!("Target Temperature: {}°C", status.target_temperature());
if let Some(mode) = status.current_mode() {
println!("Mode: {}", mode);
}
Ok(())
}§Debug Logging
Enable HTTP traffic logging for debugging:
use klafs_api::{KlafsClient, ClientConfig, DebugConfig};
use std::path::PathBuf;
let config = ClientConfig {
debug: DebugConfig::enabled().with_log_file(PathBuf::from("klafs-debug.log")),
..Default::default()
};
let client = KlafsClient::with_config(config)?;
// All HTTP traffic will be logged to klafs-debug.log§Security Warning
Klafs locks accounts after 3 failed login attempts!
Be careful with automated login attempts and ensure credentials are correct before attempting to authenticate.
Re-exports§
pub use debug::DebugConfig;
Modules§
- debug
- Debug logging for HTTP traffic
Structs§
- Client
Config - Configuration for the Klafs client
- Klafs
Client - Klafs API client
- Sauna
Info - Information about a registered sauna
- Sauna
Status - Full sauna status as returned by the GetSaunaStatus API
Enums§
- Klafs
Error - Errors that can occur when interacting with the Klafs API
- Light
Type - Light types for the LightChange endpoint
- OpStatus
- Operational status of the sauna (from opStatus field)
- Sauna
Mode - Operating mode for the sauna
- Status
Code - Status code returned by the API
Constants§
- DEFAULT_
BASE_ URL - Default base URL for the Klafs API
Type Aliases§
- Result
- Result type for Klafs operations