README.md in milight-v6-0.1.1 vs README.md in milight-v6-0.2.0

- old
+ new

@@ -2,12 +2,15 @@ [![Gem Version](https://badge.fury.io/rb/milight-v6.svg)](https://badge.fury.io/rb/milight-v6) [![Build Status](https://travis-ci.org/ppostma/milight-v6-api.svg?branch=master)](https://travis-ci.org/ppostma/milight-v6-api) [![Code Climate](https://codeclimate.com/github/ppostma/milight-v6-api/badges/gpa.svg)](https://codeclimate.com/github/ppostma/milight-v6-api) -This gem provides a Ruby API for the Milight Wifi Bridge (or Wifi iBOX controller) version 6. +This gem provides a Ruby API for the Mi-Light Wifi Bridge using protocol version 6. +Supported devices are the Mi-Light WiFi iBox models 1 and 2. The [esp8266_milight_hub](https://github.com/sidoh/esp8266_milight_hub) should also work, but I haven't tested this yet. +The bridges sold under the brand MiBoxer (such as model WL-Box1) are not supported by this gem. + ## Installation Add this line to your application's Gemfile: ```ruby @@ -22,33 +25,62 @@ $ gem install milight-v6 ## Usage +### Connecting to a Mi-Light controller + +Connect to a Mi-Light controller by creating an instance of `Milight::V6::Controller` and supplying the IP address of the Mi-Light Wifi Bridge. If you don't know the IP address, you can use the class method `search` to discover devices on the local network. + ```ruby require "milight/v6" controller = Milight::V6::Controller.new("192.168.178.33") + +controllers = Milight::V6::Controller.search +``` + +### Sending commands + +First select what you want control: the bridge lamp, a specific zone or all zones. Then you can start sending commands. See [Milight::V6::All](lib/milight/v6/all.rb), [Milight::V6::Bridge](lib/milight/v6/bridge.rb) and [Milight::V6::Zone](lib/milight/v6/zone.rb) for the supported commands. + +Some examples: + +```ruby controller.zone(1).on -controller.zone(2).warm_light.brightness(70).on +controller.zone(2).on +controller.zone(2).warm_light.brightness(70) -controller.zone(3).hue(Milight::V6::Color::BLUE).saturation(10).on +controller.zone(3).on +controller.zone(3).hue(Milight::V6::Color::BLUE).saturation(10) +controller.bridge.on +controller.bridge.brightness(50) + controller.all.off ``` -See `Milight::V6::All` and `Milight::V6::Zone` for all supported commands. +The commands will be sent with an interval of 100ms, to prevent commands being dropped by the controller. You can change or disable this by setting the `wait` parameter when creating an instance of `Milight::V6::Controller`, for example: +```ruby +controller = Milight::V6::Controller.new("192.168.178.33", wait: false) # don't delay commands + +controller = Milight::V6::Controller.new("192.168.178.33", wait: 0.05) # delay commands for 50 ms +``` + ## Command line A command line tool is included which can be used to control the lights. Usage: milight <host> <command> [zone] -Supported commands: on, off, link, unlink +Supported commands: search, on, off, link, unlink +Examples: + ```bash +$ milight search # search for devices $ milight 192.168.178.33 on 1 # turn on lights for zone 1 $ milight 192.168.178.33 off # turn off lights for all zones ``` ## Contributing