Crates.io | tradfri-rs |
lib.rs | tradfri-rs |
version | 0.1.0 |
source | src |
created_at | 2022-04-23 17:44:12.210829 |
updated_at | 2022-04-23 17:44:12.210829 |
description | Coap client wrapper for controlling IKEA lightbulbs. |
homepage | |
repository | |
max_upload_size | |
id | 572744 |
size | 14,375 |
coap-client
wrapper for controlling IKEA TRÅDFRI devices.
coap-client
using the install script.use std::net::Ipv4Addr;
use tradfri::gateway::Gateway;
const IP: Ipv4Addr = Ipv4Addr::new(192, 168, 0, 7);
const SECURITY_CODE: &'static str = "<SECURITY_CODE>";
...
let mut gateway = Gateway::new(IP, SECURITY_CODE);
if let Err(err) = gateway.authenticate("<username>") {
println!("Already authenticated.")
}
use std::thread;
use std::time::Duration;
...
let devices = gateway.get_device_ids().unwrap();
println!("{} devices found: {:?}", devices.len(), devices);
let device = gateway.get_device_by_id(devices[1]).unwrap();
device.turn_off().unwrap();
thread::sleep(Duration::from_secs(2));
device.turn_on().unwrap();
Incredibly hacky and a work in progress (:
2022 © MIT License