<commit_before># LIFX

This gem allows you to control your [LIFX](http://lifx.co) lights.

It handles discovery, gateway connections, tags, and provides a object-based API
for talking to Lights.

Due to the nature of the current protocol, some methods are asynchronous.

This gem is in an early beta state. Expect breaking API changes.

## Requirements

* Ruby 2.1.1
* Bundler

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'lifx'
```

And then execute:

```shell
$ bundle
```

Or install the gem with:

```shell
gem install lifx
```

## Usage

```ruby
client = LIFX::Client.lan                  # Talk to bulbs on the LAN
client.discover! do |c|                    # Discover lights. Blocks until a light with the label 'Office' is found
  c.lights.with_label('Office')
end
                                           # Blocks for a default of 10 seconds or until a light is found
client.lights.turn_on                      # Tell all lights to turn on
light = client.lights.with_label('Office') # Get light with label 'Office'

# Set the Office light to pale green over 5 seconds
green = LIFX::Color.green(saturation: 0.5)
light.set_color(green, duration: 5)        # Light#set_color is asynchronous

sleep 5                                    # Wait for light to finish changing
light.set_label('My Office')

light.add_tag('Offices')                   # Add tag to light

client.lights.with_tag('Offices').turn_off

client.flush                               # Wait until all the packets have been sent
```

## Documentation

Documentation is available at http://rubydoc.info/gems/lifx. Please note that undocumented classes/methods and classes/methods marked private are not intended for public use.

## Examples

Examples are located in the `examples/` folder.

* [travis-build-light](examples/travis-build-light/build-light.rb): Changes the colour of a light based on the build status of a project on Travis.
* [auto-off](examples/auto-off/auto-off.rb): Turns a light off after X seconds of it being detected turned on.
* [identify](examples/identify/identify.rb): Use divide-and-conquer search algorithm to identify a light visually.

## Useful utilities

* [lifx-console](http://github.com/chendo/lifx-console): A Pry-enabled REPL to play with LIFX easily.
* [lifx-http](http://github.com/chendo/lifx-http): A HTTP API for LIFX.

## Testing

Run with `bundle exec rspec`.<commit_msg>Add info about HSBK to README<commit_after># LIFX

This gem allows you to control your [LIFX](http://lifx.co) lights.

It handles discovery, gateway connections, tags, and provides a object-based API
for talking to Lights.

Due to the nature of the current protocol, some methods are asynchronous.

This gem is in an early beta state. Expect breaking API changes.

## Requirements

* Ruby 2.1.1
* Bundler

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'lifx'
```

And then execute:

```shell
$ bundle
```

Or install the gem with:

```shell
gem install lifx
```

## Usage

```ruby
client = LIFX::Client.lan                  # Talk to bulbs on the LAN
client.discover! do |c|                    # Discover lights. Blocks until a light with the label 'Office' is found
  c.lights.with_label('Office')
end
                                           # Blocks for a default of 10 seconds or until a light is found
client.lights.turn_on                      # Tell all lights to turn on
light = client.lights.with_label('Office') # Get light with label 'Office'

# Set the Office light to pale green over 5 seconds
green = LIFX::Color.green(saturation: 0.5)
light.set_color(green, duration: 5)        # Light#set_color is asynchronous

sleep 5                                    # Wait for light to finish changing
light.set_label('My Office')

light.add_tag('Offices')                   # Add tag to light

client.lights.with_tag('Offices').turn_off

client.flush                               # Wait until all the packets have been sent
```

## Documentation

Documentation is available at http://rubydoc.info/gems/lifx. Please note that undocumented classes/methods and classes/methods marked private are not intended for public use.

LIFX uses the `HSBK` colour representation. `HSB` stands for [hue, saturation, brightness](http://en.wikipedia.org/wiki/HSV_color_space), and `K` refers to [kelvin](http://en.wikipedia.org/wiki/Color_temperature).

## Examples

Examples are located in the `examples/` folder.

* [travis-build-light](examples/travis-build-light/build-light.rb): Changes the colour of a light based on the build status of a project on Travis.
* [auto-off](examples/auto-off/auto-off.rb): Turns a light off after X seconds of it being detected turned on.
* [identify](examples/identify/identify.rb): Use divide-and-conquer search algorithm to identify a light visually.

## Useful utilities

* [lifx-console](http://github.com/chendo/lifx-console): A Pry-enabled REPL to play with LIFX easily.
* [lifx-http](http://github.com/chendo/lifx-http): A HTTP API for LIFX.

## Testing

Run with `bundle exec rspec`.
{'fraction_non_alphanumeric': 0.09686328664430854, 'fraction_numerical': 0.0039455513908068654, 'mean_word_length': 3.082125603864734, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5052164', 'n_tokens_mistral': 1544, 'n_tokens_neox': 1435, 'n_words': 561}