Giter VIP home page Giter VIP logo

dphue's Introduction

DPHue

DPHue is an Objective-C library for controlling the Philips Hue lighting system. It allows you to read and write the entire state of a Philips Hue controller and all of the lights it manages, including changing individual lamp color, power state and other settings.

DPHue works equally well on OS X and iOS.

Features

  • Complete and granular management of the entire Philips Hue lighting system
  • Robust autodiscovery of Hue controller (via meethue.com API and also SSDP)
  • Completely asynchronous - the Hue API requires separate requests for each lamp which some control software implement in a blocking, serial fashion. DPHue executes multiple requests simultaneously and asynchronously, effecting rapid and reliable state changes.

Caveats

  • The Hue controller can only handle about 30 requests in rapid succession before it starts rate limiting, which it does by responding to all requests with HTTP 503. Additionally, each lamp requires a separate request. This means that if you make many API requests lamps may take a while to change, and the Hue controller may start ignoring you. So if you try to make a change and it doesn't work, wait a little bit and try again.

Examples

Turn on all lights:

DPHue *someHue = [[DPHue alloc] initWithHueHost:@"192.168.0.53" username:@"088CA87723B99CBC38C44DDD0E7875A2";
[someHue readWithCompletion:^(DPHue *hue, NSError *err) {
     [hue allLightsOn];
}];

Set light 2 to half brightness:

DPHue *someHue = [[DPHue alloc] initWithHueHost:@"192.168.0.53" username:@"088CA87723B99CBC38C44DDD0E7875A2";
[someHue readWithCompletion:^(DPHue *hue, NSError *err) {
     DPHueLight *light = hue.lights[1];
     light.brightness = @128;
     [light write];
}];

dphue's People

Contributors

danparsons avatar jhurliman avatar m0rph3v5 avatar

Watchers

 avatar  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.