lifx-api-server

Crates.iolifx-api-server
lib.rslifx-api-server
version0.1.15
sourcesrc
created_at2022-06-25 03:20:45.877625
updated_at2023-05-10 17:46:35.887801
descriptionA library/server that mimicks the official LIFX API using the local LAN protocol.
homepage
repositoryhttps://github.com/PixelCoda/lifx-api-server
max_upload_size
id612752
size100,193
(PixelCoda)

documentation

https://docs.rs/lifx-api-server

README

lifx-api-server

Description

A library/server that mimicks the official LIFX API using the local LAN protocol.

Offline API Supported Methods:

  • List Lights
  • Set State
  • Set States

How to use library

Add the following line to your cargo.toml:

lifx-api-server = "0.1.15"

Example:

extern crate lifx_api_server;

fn main() {

    let config = lifx_api_server::Config { 
        secret_key: format!("xxx"),
        port: 8089
    };

    lifx_api_server::start(config);


    println!("sync");

    loop {
        
    }
}


Now you can use curl to access the api:

curl -X PUT "http://localhost:8089/v1/lights/all/state" -H "Authorization: Bearer xxx" -d "color=kelvin:9000"

Or with rust using lifx-rs:

extern crate lifx_rs as lifx;

fn main() {

    let key = "xxx".to_string();
    let mut api_endpoints: Vec<String> = Vec::new();

    api_endpoints.push(format!("http://localhost:8089"));

    let config = lifx::LifxConfig{
        access_token: key.clone(),
        api_endpoints: api_endpoints
    };
    
    let mut off_state = lifx::State::new();
    off_state.power = Some(format!("off"));

    // Turn off all lights
    lifx::Light::set_state_by_selector(config.clone(), format!("all"), off_state);

}

License

Released under Apache 2.0 or MIT.

Support and follow my work by:

Buying my dope NTFs:

Checking out my Github:

Following my facebook page:

Subscribing to my Patreon:

Or donating crypto:

  • ADA: addr1qyp299a45tgvveh83tcxlf7ds3yaeh969yt3v882lvxfkkv4e0f46qvr4wzj8ty5c05jyffzq8a9pfwz9dl6m0raac7s4rac48

  • ALGO: VQ5EK4GA3IUTGSPNGV64UANBUVFAIVBXVL5UUCNZSDH544XIMF7BAHEDM4

  • ATOM: cosmos1wm7lummcealk0fxn3x9tm8hg7xsyuz06ul5fw9

  • BTC: bc1qh5p3rff4vxnv23vg0hw8pf3gmz3qgc029cekxz

  • ETH: 0x7A66beaebF7D0d17598d37525e63f524CfD23452

  • ERC20: 0x7A66beaebF7D0d17598d37525e63f524CfD23452

  • XLM: GCJAUMCO2L7PTYMXELQ6GHBTF25MCQKEBNSND2C4QMUPTSVCPEN3LCOG

  • XTZ: tz1SgJppPn56whprsDDGcqR4fxqCr2PXvg1R

TODO:

  • Server Application Release for debian linux
  • Ability to automatically update
  • Easy Installer
  • Move to the opensam foundation project
Commit count: 37

cargo fmt