Crates.io | vesync |
lib.rs | vesync |
version | 0.1.0 |
source | src |
created_at | 2021-02-28 00:42:13.632339 |
updated_at | 2021-02-28 00:42:13.632339 |
description | Interfaces with VeSync smart outlets |
homepage | https://github.com/aeshirey/vesync-rs/ |
repository | https://github.com/aeshirey/vesync-rs/ |
max_upload_size | |
id | 361633 |
size | 24,687 |
This crate lets you access and control your VeSync smart outlets including, for example, Etekcity smart plugs. You must have a VeSync account (which requires you install their iOS or Android app) in order to use this crate.
[depenencies]
vesync = "0.1"
use vesync_rs::{VeSyncAccount, VeSyncdevice, DeviceStatus};
const VESYNC_ACCOUNT: &str = "me@example.com";
const VESYNC_KEY: &str = "my-secret-password";
fn main() -> Result<(), ()> {
let account = VeSyncAccount::login(VESYNC_ACCOUNT, VESYNC_KEY)?;
let devices = account.devices()?;
let outside_light = devices
.iter()
.find(|device| device.cid == "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
.unwrap();
// Toggle the state of the device
outside_light.device_toggle()?;
match outside_light.deviceStatus {
DeviceStatus::On => println!("Outside light is on"),
DeviceStatus::Off => println!("Outside light is off"),
DeviceStatus::Unknown => println!("🤷♂️"), // toggle will update state, so this *should* be unreachable
};
Ok(())
}
nanoserde
vesync-rs
APIattohttpc
. This dropped the number of crates to build from 106 to 62 and the build time from about 1min30sec to 55sec.VeSyncAccount
using the accountID
and tk
directly (ie, without logging in). This lets you add those values to your source code instead of the raw credentials:let account = VeSyncAccount { accountID: "1234".to_string(), tk: "ABCXYZ==".to_string() };
VeSyncDevice
from the account and cid
:let mut inside_light = VeSyncDevice::from_id(&account, "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee");
inside_light.update();