Crates.io | ember_mug |
lib.rs | ember_mug |
version | 0.4.0 |
source | src |
created_at | 2023-01-01 02:59:36.19037 |
updated_at | 2023-11-28 11:28:36.31231 |
description | Control and retrieve data from an Ember Ceramic Mug using Bluetooth Low Energy (BLE) |
homepage | |
repository | https://github.com/emilgardis/ember_mug |
max_upload_size | |
id | 748694 |
size | 98,637 |
You can see current unpublished docs here:
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.
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
Thanks to orlopau/ember-mug and sopelj/python-ember-mug for providing hints towards the various BLE characteristics