KlafsClient

Struct KlafsClient 

Source
pub struct KlafsClient { /* private fields */ }
Expand description

Klafs API client

Handles authentication and maintains session state for communicating with the Klafs sauna control API.

§Example

use klafs_api::KlafsClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = KlafsClient::new()?;
    client.login("user@example.com", "password").await?;

    let status = client.get_status("sauna-uuid").await?;
    println!("Temperature: {}°C", status.current_temperature);
    Ok(())
}

Implementations§

Source§

impl KlafsClient

Source

pub fn new() -> Result<Self>

Create a new Klafs client with default configuration

Source

pub fn with_config(config: ClientConfig) -> Result<Self>

Create a new Klafs client with custom configuration

Source

pub fn debugger(&self) -> &HttpDebugger

Get the debugger for accessing traffic logs

Source

pub fn enable_debug(&self)

Enable debug logging at runtime

Source

pub fn disable_debug(&self)

Disable debug logging at runtime

Source

pub async fn login(&self, username: &str, password: &str) -> Result<()>

Login to the Klafs API

This authenticates with the Klafs server and establishes a session. The session cookie is stored automatically for subsequent requests.

§Arguments
  • username - Email address for the Klafs account
  • password - Password for the Klafs account
§Errors

Returns KlafsError::AuthenticationFailed if credentials are invalid. Returns KlafsError::AccountLocked if too many failed attempts.

§Warning

Klafs locks accounts after 3 failed login attempts!

Source

pub async fn get_status(&self, sauna_id: &str) -> Result<SaunaStatus>

Get the current status of a sauna

Source

pub async fn list_saunas(&self) -> Result<Vec<SaunaInfo>>

List all saunas registered to the account

Source

pub async fn power_on( &self, sauna_id: &str, pin: &str, schedule: Option<(i32, i32)>, ) -> Result<()>

Power on the sauna immediately or at a scheduled time

§Arguments
  • sauna_id - UUID of the sauna
  • pin - PIN code for power control
  • schedule - Optional (hour, minute) to schedule start instead of immediate
Source

pub async fn power_off(&self, sauna_id: &str) -> Result<()>

Power off the sauna

Note: PIN is not required for power off

§Arguments
  • sauna_id - UUID of the sauna
Source

pub async fn set_mode(&self, sauna_id: &str, mode: SaunaMode) -> Result<()>

Set the operating mode

§Arguments
  • sauna_id - UUID of the sauna
  • mode - The mode to set (Sauna, Sanarium, or Infrared)
Source

pub async fn set_temperature( &self, sauna_id: &str, temperature: i32, ) -> Result<()>

Set the target temperature

§Arguments
  • sauna_id - UUID of the sauna
  • temperature - Target temperature in °C
    • Sauna mode: 10-100°C
    • Sanarium mode: 40-75°C
Source

pub async fn set_humidity(&self, sauna_id: &str, level: i32) -> Result<()>

Set the humidity level (Sanarium mode only)

§Arguments
  • sauna_id - UUID of the sauna
  • level - Humidity level (1-10)
Source

pub async fn set_start_time( &self, sauna_id: &str, hour: i32, minute: i32, ) -> Result<()>

Set the scheduled start time

§Arguments
  • sauna_id - UUID of the sauna
  • hour - Start hour (0-23)
  • minute - Start minute (0-59)
Source

pub async fn set_selected_time( &self, sauna_id: &str, time: Option<(i32, i32)>, ) -> Result<()>

Set or clear the scheduled start time without starting the sauna

This uses the SetSelectedTime endpoint to configure scheduling without immediately powering on the sauna.

§Arguments
  • sauna_id - UUID of the sauna
  • time - Some((hour, minute)) to set schedule, None to clear
Source

pub async fn set_light( &self, sauna_id: &str, on: bool, brightness: Option<i32>, ) -> Result<()>

Control the main cabin light

§Arguments
  • sauna_id - UUID of the sauna
  • on - Whether to turn the light on or off
  • brightness - Brightness level (1-10), only used when turning on
Source

pub async fn set_sunset( &self, sauna_id: &str, on: bool, brightness: Option<i32>, ) -> Result<()>

Control the sunset light

§Arguments
  • sauna_id - UUID of the sauna
  • on - Whether to turn the light on or off
  • brightness - Brightness level (1-10), only used when turning on
Source

pub async fn configure( &self, sauna_id: &str, sauna_temperature: Option<i32>, sanarium_temperature: Option<i32>, humidity_level: Option<i32>, hour: Option<i32>, minute: Option<i32>, ) -> Result<()>

Configure multiple settings in a single API call

This uses the PostConfigChange endpoint to set multiple parameters at once. Only the parameters that are Some will be included in the request.

§Arguments
  • sauna_id - UUID of the sauna
  • sauna_temperature - Target temperature for sauna mode (10-100°C)
  • sanarium_temperature - Target temperature for sanarium mode (40-75°C)
  • humidity_level - Humidity level for sanarium mode (1-10)
  • hour - Scheduled start hour (0-23)
  • minute - Scheduled start minute (0-59)
Source

pub fn is_logged_in(&self) -> bool

Check if the client has an active session

Trait Implementations§

Source§

impl Debug for KlafsClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more