Skip to content

sivakov512/sonoff-minir3-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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;