Code Monkey home page Code Monkey logo

wiz-lights-manager's Introduction

Wiz Lights Manager

A Typescript library to manage Wiz Smart Lights.

It uses the internal UPD API of the Wiz Lights to control them. This library is not affiliated with Wiz and may not work for all firmware versions, API versions, light models, etc.

Features

  • Discover Wiz Lights on the local network
  • Control Wiz Lights (on/off, brightness, color, etc.)
  • Group Wiz Lights
  • Define custom scenes

Installation

npm install wiz-lights-manager

Usage

import { WizLightManager } from 'wiz-lights-manager';

const manager = new WizLightManager();

/**
 * IMPORTANT: This must be called before any other methods (obviously)
 * 
 * Finds all Wiz Lights on the local network
 * Loads cached lights if available
 * Initializes each light, loading its state
 */
await manager.init();

/**
 * Interact with all lights
 */
await manager.allLights.lightSwitch(true/false);
await manager.allLights.setBrightness(100);
await manager.allLights.setColor({ temp: 2700 });
await manager.allLights.setScene('Romantic');

/**
 * Set the color of all lights
 */
await manager.allLights.setColor({
    // Can use RGB
    r: 255,
    g: 0,
    b: 0,
    // Temperature
    temp: 2700,
    // Or Cold/Warm
    c: 0,
    w: 255
});

/**
 * Interact with groups and set alieses for their IDs
 * Groups are automatically created based on the group they have been assigned to in the Wiz app
 */
manager.lightGroups[ID1]?.setAlias('Living Room');
manager.lightGroups[ID2]?.setAlias('Bedroom');
await manager.getGroupByAlias('Living Room')?.lightSwitch(true);
await manager.getGroupByAlias('Bedroom')?.setColor({ temp: 2700 });

/**
 * Create a custom scene by defining a procedure to run
 */
manager.createScene('Custom Name', async (manager) => {
    await manager.allLights.lightSwitch(true);
    await manager.allLights.setColor({ temp: 2700 });
    ...
});

await manager.runCustomScene('Custom Name');

wiz-lights-manager's People

Contributors

jlannoo avatar

Stargazers

Aiden Vandekerckhove 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.