Project

milight-v6

0.0
No commit activity in last 3 years
No release in over 3 years
Ruby API for the Milight Wifi Bridge (or Wifi iBOX controller) version 6.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 3.0
~> 2.0
~> 13.0
 Project Readme

Milight Wifi Bridge v6 Ruby API

Gem Version Build Status Code Climate

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 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:

gem 'milight-v6'

And then execute:

$ bundle

Or install it yourself as:

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

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, Milight::V6::Bridge and Milight::V6::Zone for the supported commands.

Some examples:

controller.zone(1).on

controller.zone(2).on
controller.zone(2).warm_light.brightness(70)

controller.zone(3).on
controller.zone(3).hue(Milight::V6::Color::BLUE).saturation(10)

controller.bridge.on
controller.bridge.brightness(50)

controller.all.off

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:

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: search, on, off, link, unlink

Examples:

$ 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

Bug reports and pull requests are welcome on GitHub at https://github.com/ppostma/milight-v6-api.

License

The gem is available as open source under the terms of the MIT License.