2 releases

0.1.2 Oct 12, 2023
0.1.1 Oct 11, 2023
0.1.0 Oct 11, 2023

#4 in #r3

MIT license

18KB
326 lines

Sonoff mini R3

Build status Downloads API Docs LICENSE

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;

Dependencies

~11–23MB
~347K SLoC