Giter Site home page Giter Site logo

lightd's Introduction

lightd

lightd is a simple HTTP gateway for the lifx binary protocol

Requirements

  • command line PHP binary (>= 5.4)
  • configured lifx bulbs with fixed address or hostname

lightd tries to connect to the lifx gateway bulb using hostname "lifx" and port 56700 and provides its REST API on port 5439, you may change these values at the top of lightd.php

if everything is set up correctly, you should see something like this when you run lightd from the command line :

20140123:204248 lightd/0.9.0 (c) 2014 by sIX / aEGiS
20140123:204248 loaded 5 patterns
20140123:204248 connected to lifx
20140123:204248 API server listening on port 5439
20140123:204248 found gateway bulb at d073d5014736
20140123:204248 new bulb registered: Kitchen
20140123:204249 new bulb registered: Living

you may want to create a startup script and redirect the standard output to a log file if you wish to run it long term.

API methods

Power on/off
/power/(on|off)[/<bulb_label>]

if bulb_label is not given, the command applies to all bulbs in the lifx mesh

examples:

  • /power/on/Kitchen
  • /power/off
Set color
/color/<color>[K<temperature>][/<bulb_label>]

if bulb_label is not given, the color is applied to all bulbs in the lifx mesh

examples:

  • /color/ffffff/Kitchen
  • /color/404040K3500/Living
  • /color/002040
Set pattern
/pattern/<name>[/<transition_time_ms>]

patterns are read from the patterns.ini file if transition_time_ms is not given, the pattern is applied immediately

examples:

  • /pattern/off
  • /pattern/movies/10000
  • /pattern/night/3600000
Dump state
/state

dumps a JSON encoded array of bulb objects with their current state

sample output:

[
    {
        "id": "d073d5014736",
        "label": "Kitchen",
        "tags": 0,
        "state_ts": 1390508260,
        "rgb": "#000000",
        "power": true,
        "extra": {
            "hue": 0,
            "saturation": 0,
            "brightness": 0,
            "dim": 0,
            "kelvin": 3000
        }
    },
    {
        "id": "d073d500bf47",
        "label": "Living",
        "tags": 0,
        "state_ts": 1390508261,
        "rgb": "#191919",
        "power": true,
        "extra": {
            "hue": 0,
            "saturation": 0,
            "brightness": 6425,
            "dim": 0,
            "kelvin": 2800
        }
    }
]

lightd's People

Contributors

six0r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lightd's Issues

Access-Control-Allow-Origin

I'm getting this pesky issue when trying to call the API, from the same box no doubt!

I try added the following lines to the constructor of the API_Server class:
parent::Add_Header("Access-Control-Allow-Origin: *");
parent::Add_Header("Content-Type: application/json");

and I confirm the headers are there when I do a curl:

$ curl -i 192.168.1.221:5439/state
HTTP/1.1 200 OK
Date: Thu, 12 Jun 2014 14:14:02 GMT
Server: nanoserv/2.1.2-dev
Content-Type:
Content-Length: 3941
Connection: Close
Access-Control-Allow-Origin: *
Content-Type: application/json

{
.....

But from the browser i keep getting the JS console error...

Any ideas? Thanks!!

Wrong colors

/color/ffffff seems to display the correct color but /color/fffefe which should be nearly the same color displays a deep red.

namespace

I don't know if I'm using it incorrectly.. but when I run this in PHP i'm getting the error " Namespace declaration statement has to be the very first statement in the script in..." as far as I can see it is.. but I might be reading the script incorrectly too?

Error since the firmware update

Since the Firmware Update 1.2 for the LIFX-Bulbs, I get the following error:

20140605:134428 lightd/0.9.0 (c) 2014 by sIX / aEGiS <[email protected]>
20140605:134428 loaded 7 patterns
20140605:134428 connected to 192.168.1.107
PHP Notice:  fwrite(): send of 36 bytes failed with errno=32 Broken pipe in /Library/WebServer/Websites/lightd/nanoserv/nanoserv.php on line 403
20140605:134428 API server listening on port 5439
20140605:134429 lost connection, trying to reconnect ...

Unable to connect

I have setup PHP 5.4.35 together with lightd on a windows machine. I changed lightd.php to connect to the ip of the gateway on port 56700, but when I run lightd.php from the php command line, I get the error message unable to connect.

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.