sonoff-minir3

Crates.iosonoff-minir3
lib.rssonoff-minir3
version0.1.2
sourcesrc
created_at2023-10-11 20:53:15.747627
updated_at2023-10-12 23:09:00.059891
descriptionSonoff mini R3 API client
homepage
repositoryhttps://github.com/sivakov512/sonoff-minir3-rs
max_upload_size
id1000677
size21,783
Nikita Sivakov (sivakov512)

documentation

README

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;
Commit count: 14

cargo fmt