Skip to content

Latest commit

 

History

History
71 lines (52 loc) · 1.65 KB

README.md

File metadata and controls

71 lines (52 loc) · 1.65 KB

tplink-rs

CI

A simple library to control TP-Link Smart Home devices.

Examples

Discover

Discover existing TP-Link devices on your network.

use tplink::DeviceKind;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let devices = tplink::discover()?;

    for (ip, device) in devices {
        match device {
            DeviceKind::Plug(mut plug) => {
                plug.turn_off()?;
                assert_eq!(plug.is_on()?, false);
            }
            DeviceKind::Bulb(mut bulb) => {
                bulb.set_brightness(50)?;
                assert_eq!(bulb.brightness()?, 50);
            }
            _ => eprintln!("unrecognised device found on the network: {}", ip),
        }
    }

    Ok(())
}

More examples can be found here.

Supported Devices

Device Model
Plug HS100
Bulb LB100, LB110

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.