Crates.io | sonoff-minir3 |
lib.rs | sonoff-minir3 |
version | 0.1.2 |
source | src |
created_at | 2023-10-11 20:53:15.747627 |
updated_at | 2023-10-12 23:09:00.059891 |
description | Sonoff mini R3 API client |
homepage | |
repository | https://github.com/sivakov512/sonoff-minir3-rs |
max_upload_size | |
id | 1000677 |
size | 21,783 |
This crate provides a high-level client for official Sonoff mini R3 DIY API.
Note that before using this library you should enter your device into DIY mode. More details on how to do that can be found in official documentation. Also you may need to read API documentation which is used to implement this lib.
Currently library provides limited amount of features:
fetching device info (only few attributes)
setting startup position
setting current switch position
Note that doscovery via mDNS is not supported, so you should know IP address of your device. Port is 8081 by default (just try it, should work).
use sonoff_minir3::Client;
let client = Client::new("192.168.1.75", 8081);
// Fetch device's info
let got = client.fetch_info().await;
assert_eq!(
got.unwrap(),
Info {
switch: SwitchPosition::Off,
startup: StartupPosition::Off
}
)
// Set startup position
client.set_startup_position(StartupPosition::Stay).await;
// Set current switch position
client.set_switch_position(SwitchPosition::On).await;