remo

Crates.ioremo
lib.rsremo
version0.1.2
sourcesrc
created_at2019-09-06 16:14:16.254419
updated_at2019-09-07 04:46:29.057546
descriptionNature Remo API client
homepagehttps://github.com/uetchy/nature-remo-rs
repositoryhttps://github.com/uetchy/nature-remo-rs
max_upload_size
id162819
size16,340
uetchy (uetchy)

documentation

https://github.com/uetchy/nature-remo-rs/blob/master/README.md

README

Nature Remo for Rust

Crates.io Docs.rs Travis (.com)

Nature Remo API client for Rust.

WARNING: This project is in heavily development state and not intended for production use.

Installation

cargo add remo

Usage

extern crate remo;

use remo::cloud;
use std::env;

fn main() {
  let token = env::var("NATURE_REMO_CLOUD_API_TOKEN");

  let client = cloud::Client::new(token);

  // get user's nickname
  let user = client.get_user().unwrap();
  println!("Name: {}", user.nickname);

  // get room temperature
  let sensor_value = client.get_sensor_value().unwrap();
  println!("Temperature: {}", sensor_value.temperature);

  // update aircon settings
  let appliances = client.get_appliances().unwrap();
  let aircon = appliances.iter().find(|&app| app.r#type == "AC").unwrap();

  let mut params = cloud::RequestBody::new();
  params.insert("operation_mode", "warm");
  params.insert("temperature", "26");
  client.update_aircon_settings(&aircon.id, &params);
  println!("Aircon settings updated: mode(warm), temperature(26)");
}
Commit count: 18

cargo fmt