ember_mug 0.4.0

Control and retrieve data from an Ember Ceramic Mug using Bluetooth Low Energy (BLE)
Documentation

ember_mug | Rust crate for controlling and retrieving data from an Ember Ceramic Mug using Bluetooth Low Energy (BLE)

githubcrates-iodocs-rs-big

You can see current unpublished docs here: local-docs

Provides a Rust interface for interacting with Ember Mug devices through the btleplug crate. Used to create applications that can control and monitor Ember Mug devices; retrieving the current temperature or battery level, setting the target temperature or mug color and accessing device metadata.

Example

use ember_mug::{mug::Temperature, EmberMug};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mug = EmberMug::find_and_connect().await?;
    let name = mug.get_name().await?;
    println!("Connected to an Ember Mug with the name '{}'", name);

    let battery = mug.get_battery().await?;
    println!("Battery level: {}%", battery.battery);

    let current_temp = mug.get_current_temperature().await?;
    let target_temp = mug.get_target_temperature().await?;
    let unit = mug.get_temperature_unit().await?;
    println!("Current temperature: {}{}", current_temp, unit);
    println!("Target temperature: {}{}", target_temp, unit);

    mug.set_target_temperature(&Temperature::from_degree(60.0))
        .await?;

    let target_temp = mug.get_target_temperature().await?;
    println!("Changed target temperature to {}{}", target_temp, unit);

    Ok(())
}

Results in

Connected to an Ember Mug with the name 'EMBER'
Battery level: 100%
Current temperature: 20.5°C
Target temperature: 54°C
Changed target temperature to 60°C

Kudos

Thanks to orlopau/ember-mug and sopelj/python-ember-mug for providing hints towards the various BLE characteristics