Code Monkey home page Code Monkey logo

wiz-local's Introduction

Wiz Local

js-standard-style

Find Wiz devices and control them with the Wiz Local app. Each method will return a Promise that resolves with the result of the operation.

Installation

Npm

npm install wiz-local

Example

const {discovery, toggle, temperature, getState, rgb, dimm} = require('wiz-local');

// Find Wiz local devices.
async () => {
  const devices = await discovery();
  console.log(devices);
  devices /*
  [
    {
    "id": "00:00:00:00:00:00",
    "mac": "00:00:00:00:00:00",
    "ip": "192.168.0.102",
    "vendor": "wiz",
    "name": "",
    "description": "",
    "type": "",
    "status": "",
    "location": ""
  },
  {
    "id": "00:00:00:00:00:00",
    "mac": "00:00:00:00:00:00",
    "ip": "192.168.0.119",
    "vendor": "wiz",
    "name": "",
    "description": "",
    "type": "",
    "status": "",
    "location": ""
  },
  ]
    */
}

// Get the state of a device.
async () => {
  const devices = await discovery();
  const device = devices[0];
  const state = await getState(device);
  console.log(state);
  state /*
  {
      "mac": "00000000",
      "rssi": -49,
      "src": "",
      "state": false,
      "sceneId": 0,
      "temp": 6500,
      "dimming": 100
    }
    */
}

// Toggle a device.
async () => {
  const devices = await discovery();
  const device = devices[0];
  await toggle(device, true); // true to turn on and false to turn off.(Use boolean, not string)
}

// Change the light temperature of a device.
async () => {
  const devices = await discovery();
  const device = devices[0];
  await temperature(device, 2700); // 2200 to 6500 is the temperature in Kelvin.(Use integer, not string)
}

// Change the color of a device.
async () => {
  const devices = await discovery();
  const device = devices[0];
  await rgb(device, 255, 255, 255); // 0 to 255 is the color value.(Use integer, not string)
}

// Change the intensity of a device.
async () => {
  const devices = await discovery();
  const device = devices[0];
  await dimm(device, 100); // 0 to 100 is the intensity value.(Use integer, not string)
}

    
    ```

wiz-local's People

Contributors

gonreyna85code avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.