milight-v6 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +25 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +51 -0
- data/LICENSE.txt +21 -0
- data/README.md +57 -0
- data/Rakefile +10 -0
- data/bin/console +15 -0
- data/bin/milight +32 -0
- data/bin/setup +8 -0
- data/lib/milight/v6.rb +6 -0
- data/lib/milight/v6/all.rb +82 -0
- data/lib/milight/v6/color.rb +16 -0
- data/lib/milight/v6/command.rb +108 -0
- data/lib/milight/v6/controller.rb +25 -0
- data/lib/milight/v6/socket.rb +40 -0
- data/lib/milight/v6/version.rb +7 -0
- data/lib/milight/v6/zone.rb +99 -0
- data/milight-v6.gemspec +27 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3af0d2759af9191fdeec66af91c2d183637470f5
|
4
|
+
data.tar.gz: 7a959f4f8018887a71a187c47321146f61909531
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ab7573061d49cde08b90954fb8329c44358b3bbb58b8f8a2d9a3718d7236aac8ffcf9371abcd14f9790cc20998646af7e0a70de0dc7a8b2ea2f818ec1888e300
|
7
|
+
data.tar.gz: 45a69a1f9f34846cba4d0f96d71eaa716ee8db322c62e71504ee9bd13def67fcb601df81d5b7bf037b3931e606d2cde2428fca1af0686e3dabdc4d7c507cedb2
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.3
|
3
|
+
DisplayCopNames: true
|
4
|
+
DisplayStyleGuide: true
|
5
|
+
Exclude:
|
6
|
+
- 'lib/milight/v6/api/version.rb'
|
7
|
+
|
8
|
+
Metrics/BlockLength:
|
9
|
+
Exclude:
|
10
|
+
- 'spec/**/*.rb'
|
11
|
+
|
12
|
+
Metrics/LineLength:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Style/ConditionalAssignment:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Style/Documentation:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Style/For:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Style/StringLiterals:
|
25
|
+
Enabled: false
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
milight
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.5
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
milight-v6 (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.3.0)
|
10
|
+
diff-lcs (1.3)
|
11
|
+
parallel (1.12.1)
|
12
|
+
parser (2.4.0.2)
|
13
|
+
ast (~> 2.3)
|
14
|
+
powerpack (0.1.1)
|
15
|
+
rainbow (3.0.0)
|
16
|
+
rake (10.5.0)
|
17
|
+
rspec (3.7.0)
|
18
|
+
rspec-core (~> 3.7.0)
|
19
|
+
rspec-expectations (~> 3.7.0)
|
20
|
+
rspec-mocks (~> 3.7.0)
|
21
|
+
rspec-core (3.7.0)
|
22
|
+
rspec-support (~> 3.7.0)
|
23
|
+
rspec-expectations (3.7.0)
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
+
rspec-support (~> 3.7.0)
|
26
|
+
rspec-mocks (3.7.0)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.7.0)
|
29
|
+
rspec-support (3.7.0)
|
30
|
+
rubocop (0.52.1)
|
31
|
+
parallel (~> 1.10)
|
32
|
+
parser (>= 2.4.0.2, < 3.0)
|
33
|
+
powerpack (~> 0.1)
|
34
|
+
rainbow (>= 2.2.2, < 4.0)
|
35
|
+
ruby-progressbar (~> 1.7)
|
36
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
37
|
+
ruby-progressbar (1.9.0)
|
38
|
+
unicode-display_width (1.3.0)
|
39
|
+
|
40
|
+
PLATFORMS
|
41
|
+
ruby
|
42
|
+
|
43
|
+
DEPENDENCIES
|
44
|
+
bundler (~> 1.16)
|
45
|
+
milight-v6!
|
46
|
+
rake (~> 10.0)
|
47
|
+
rspec (~> 3.0)
|
48
|
+
rubocop (~> 0.52.1)
|
49
|
+
|
50
|
+
BUNDLED WITH
|
51
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Peter Postma
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# Milight Wifi Bridge v6 Ruby API
|
2
|
+
|
3
|
+
This gem provides a Ruby API for the Milight Wifi Bridge (or Wifi iBOX controller) version 6.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'milight-v6'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install milight-v6
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require "milight/v6"
|
25
|
+
|
26
|
+
controller = Milight::V6::Controller.new("192.168.178.33")
|
27
|
+
controller.zone(1).on
|
28
|
+
|
29
|
+
controller.zone(2).on.brightness(70).warm_light
|
30
|
+
|
31
|
+
controller.zone(3).on.saturation(80).hue(Milight::V6::Color::BLUE)
|
32
|
+
|
33
|
+
controller.all.off
|
34
|
+
```
|
35
|
+
|
36
|
+
See `Milight::V6::All` and `Milight::V6::Zone` for all supported commands.
|
37
|
+
|
38
|
+
## Command line
|
39
|
+
|
40
|
+
A command line tool is included which can be used to control the lights.
|
41
|
+
|
42
|
+
Usage: milight <host> <command> [zone]
|
43
|
+
|
44
|
+
Supported commands: on, off, link, unlink
|
45
|
+
|
46
|
+
```bash
|
47
|
+
$ milight 192.168.178.33 on 1 # turn on lights for zone 1
|
48
|
+
$ milight 192.168.178.33 off # turn off lights for all zones
|
49
|
+
```
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
|
53
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ppostma/milight-v6-api.
|
54
|
+
|
55
|
+
## License
|
56
|
+
|
57
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "milight/v6"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/milight
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "milight/v6"
|
5
|
+
|
6
|
+
if ARGV.length < 2
|
7
|
+
puts "Usage: #{$PROGRAM_NAME} <host> <command> [zone]"
|
8
|
+
exit 1
|
9
|
+
end
|
10
|
+
|
11
|
+
host = ARGV.shift
|
12
|
+
command = ARGV.shift
|
13
|
+
zone = ARGV.shift
|
14
|
+
|
15
|
+
controller = Milight::V6::Controller.new(host)
|
16
|
+
|
17
|
+
if zone.nil?
|
18
|
+
lights = controller.all
|
19
|
+
else
|
20
|
+
lights = controller.zone(zone.to_i)
|
21
|
+
end
|
22
|
+
|
23
|
+
case command
|
24
|
+
when "link"
|
25
|
+
lights.link
|
26
|
+
when "unlink"
|
27
|
+
lights.unlink
|
28
|
+
when "off"
|
29
|
+
lights.off
|
30
|
+
when "on"
|
31
|
+
lights.on
|
32
|
+
end
|
data/bin/setup
ADDED
data/lib/milight/v6.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Milight
|
4
|
+
module V6
|
5
|
+
class All
|
6
|
+
def initialize(command)
|
7
|
+
@command = command
|
8
|
+
end
|
9
|
+
|
10
|
+
# Switch the lights on.
|
11
|
+
def on
|
12
|
+
@command.on(0)
|
13
|
+
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
# Switch the lights off.
|
18
|
+
def off
|
19
|
+
@command.off(0)
|
20
|
+
|
21
|
+
self
|
22
|
+
end
|
23
|
+
|
24
|
+
# Enable night light mode.
|
25
|
+
def night_light
|
26
|
+
@command.night_light(0)
|
27
|
+
|
28
|
+
self
|
29
|
+
end
|
30
|
+
|
31
|
+
# Set brightness, value: 0% to 100%
|
32
|
+
def brightness(value)
|
33
|
+
@command.brightness(0, value)
|
34
|
+
|
35
|
+
self
|
36
|
+
end
|
37
|
+
|
38
|
+
# Set color temperature, value: 0 = 2700K, 100 = 6500K.
|
39
|
+
def temperature(value)
|
40
|
+
@command.temperature(0, value)
|
41
|
+
|
42
|
+
self
|
43
|
+
end
|
44
|
+
|
45
|
+
# Set color temperature to warm light (2700K).
|
46
|
+
def warm_light
|
47
|
+
@command.temperature(0, 0)
|
48
|
+
|
49
|
+
self
|
50
|
+
end
|
51
|
+
|
52
|
+
# Set color temperature to white (cool) light (6500K).
|
53
|
+
def white_light
|
54
|
+
@command.temperature(0, 100)
|
55
|
+
|
56
|
+
self
|
57
|
+
end
|
58
|
+
|
59
|
+
# Set the hue, value: 0 to 255 (red).
|
60
|
+
# See Milight::V6::Color for predefined colors.
|
61
|
+
def hue(value)
|
62
|
+
@command.hue(0, value)
|
63
|
+
|
64
|
+
self
|
65
|
+
end
|
66
|
+
|
67
|
+
# Set the saturation, value: 0% to 100%.
|
68
|
+
def saturation(value)
|
69
|
+
@command.saturation(0, value)
|
70
|
+
|
71
|
+
self
|
72
|
+
end
|
73
|
+
|
74
|
+
# Wait before continuing to next command.
|
75
|
+
def wait(seconds)
|
76
|
+
sleep(seconds)
|
77
|
+
|
78
|
+
self
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "milight/v6/socket"
|
4
|
+
|
5
|
+
module Milight
|
6
|
+
module V6
|
7
|
+
# see http://www.limitlessled.com/dev/
|
8
|
+
class Command
|
9
|
+
def initialize(host, port = 5987)
|
10
|
+
@socket = Milight::V6::Socket.new(host, port)
|
11
|
+
|
12
|
+
bridge_session
|
13
|
+
end
|
14
|
+
|
15
|
+
def link(zone_id)
|
16
|
+
execute(zone_id, [0x3D, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00])
|
17
|
+
end
|
18
|
+
|
19
|
+
def unlink(zone_id)
|
20
|
+
execute(zone_id, [0x3E, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00])
|
21
|
+
end
|
22
|
+
|
23
|
+
def on(zone_id)
|
24
|
+
execute(zone_id, [0x31, 0x00, 0x00, 0x08, 0x04, 0x01, 0x00, 0x00, 0x00])
|
25
|
+
end
|
26
|
+
|
27
|
+
def off(zone_id)
|
28
|
+
execute(zone_id, [0x31, 0x00, 0x00, 0x08, 0x04, 0x02, 0x00, 0x00, 0x00])
|
29
|
+
end
|
30
|
+
|
31
|
+
def night_light(zone_id)
|
32
|
+
execute(zone_id, [0x31, 0x00, 0x00, 0x08, 0x04, 0x05, 0x00, 0x00, 0x00])
|
33
|
+
end
|
34
|
+
|
35
|
+
def brightness(zone_id, value)
|
36
|
+
raise ArgumentError, "Please supply a brightness value between 0-100." if value.negative? || value > 100
|
37
|
+
|
38
|
+
execute(zone_id, [0x31, 0x00, 0x00, 0x08, 0x03, value, 0x00, 0x00, 0x00])
|
39
|
+
end
|
40
|
+
|
41
|
+
def temperature(zone_id, value)
|
42
|
+
raise ArgumentError, "Please supply a temperature value between 0-100 (2700K to 6500K)." if value.negative? || value > 100
|
43
|
+
|
44
|
+
execute(zone_id, [0x31, 0x00, 0x00, 0x08, 0x05, value, 0x00, 0x00, 0x00])
|
45
|
+
end
|
46
|
+
|
47
|
+
def hue(zone_id, value)
|
48
|
+
raise ArgumentError, "Please supply a hue value between 0-255." if value.negative? || value > 255
|
49
|
+
|
50
|
+
execute(zone_id, [0x31, 0x00, 0x00, 0x08, 0x01, value, value, value, value])
|
51
|
+
end
|
52
|
+
|
53
|
+
def saturation(zone_id, value)
|
54
|
+
raise ArgumentError, "Please supply a saturation value between 0-100." if value.negative? || value > 100
|
55
|
+
|
56
|
+
execute(zone_id, [0x31, 0x00, 0x00, 0x08, 0x02, value, 0x00, 0x00, 0x00])
|
57
|
+
end
|
58
|
+
|
59
|
+
def execute(zone_id, command)
|
60
|
+
raise ArgumentError, "Please supply a zone ID between 1-4." if zone_id.negative? || zone_id > 4
|
61
|
+
|
62
|
+
# UDP Hex Send Format: 80 00 00 00 11 {WifiBridgeSessionID1} {WifiBridgeSessionID2} 00 {SequenceNumber} 00 {COMMAND} {ZONE NUMBER} 00 {Checksum}
|
63
|
+
request = [0x80, 0x00, 0x00, 0x00, 0x11, @session_id1, @session_id2, 0x00, next_sequence_number, 0x00]
|
64
|
+
|
65
|
+
request += command
|
66
|
+
|
67
|
+
request << zone_id
|
68
|
+
request << 0x00
|
69
|
+
request << calculate_checksum(request)
|
70
|
+
|
71
|
+
@socket.send_bytes(request)
|
72
|
+
@socket.receive_bytes
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def bridge_session
|
78
|
+
# UDP.SEND hex bytes: 20 00 00 00 16 02 62 3A D5 ED A3 01 AE 08 2D 46 61 41 A7 F6 DC AF (D3 E6) 00 00 1E <-- Send this to the ip address of the wifi bridge v6
|
79
|
+
request = [0x20, 0x00, 0x00, 0x00, 0x16, 0x02, 0x62, 0x3A, 0xD5,
|
80
|
+
0xED, 0xA3, 0x01, 0xAE, 0x08, 0x2D, 0x46, 0x61, 0x41,
|
81
|
+
0xA7, 0xF6, 0xDC, 0xAF, 0xD3, 0xE6, 0x00, 0x00, 0x1E]
|
82
|
+
|
83
|
+
@socket.send_bytes(request)
|
84
|
+
response = @socket.receive_bytes
|
85
|
+
|
86
|
+
@session_id1 = response[19]
|
87
|
+
@session_id2 = response[20]
|
88
|
+
end
|
89
|
+
|
90
|
+
def next_sequence_number
|
91
|
+
@sequence_number = 0 if @sequence_number.nil? || @sequence_number >= 255
|
92
|
+
@sequence_number += 1
|
93
|
+
|
94
|
+
@sequence_number
|
95
|
+
end
|
96
|
+
|
97
|
+
def calculate_checksum(bytes)
|
98
|
+
checksum = 0
|
99
|
+
|
100
|
+
for i in 10..19 do
|
101
|
+
checksum += bytes[i]
|
102
|
+
end
|
103
|
+
|
104
|
+
checksum & 0xFF
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "milight/v6/command"
|
4
|
+
require "milight/v6/all"
|
5
|
+
require "milight/v6/zone"
|
6
|
+
|
7
|
+
module Milight
|
8
|
+
module V6
|
9
|
+
class Controller
|
10
|
+
def initialize(host, port = 5987)
|
11
|
+
@command = Milight::V6::Command.new(host, port)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Select all zones.
|
15
|
+
def all
|
16
|
+
Milight::V6::All.new(@command)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Select a specific zone.
|
20
|
+
def zone(zone_id)
|
21
|
+
Milight::V6::Zone.new(@command, zone_id)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "logger"
|
4
|
+
require "socket"
|
5
|
+
|
6
|
+
module Milight
|
7
|
+
module V6
|
8
|
+
class Socket
|
9
|
+
def initialize(host, port)
|
10
|
+
@host = host
|
11
|
+
@port = port
|
12
|
+
@socket = UDPSocket.new
|
13
|
+
|
14
|
+
@logger = Logger.new(STDOUT)
|
15
|
+
@logger.level = Logger::INFO if ENV["MILIGHT_DEBUG"] != "1"
|
16
|
+
end
|
17
|
+
|
18
|
+
def send_bytes(bytes)
|
19
|
+
@logger.debug("Sending: #{format_bytes_as_hex(bytes)}")
|
20
|
+
|
21
|
+
@socket.send bytes.pack('C*'), 0, @host, @port
|
22
|
+
end
|
23
|
+
|
24
|
+
def receive_bytes
|
25
|
+
response = @socket.recvfrom(128).first
|
26
|
+
bytes = response.unpack('C*')
|
27
|
+
|
28
|
+
@logger.debug("Received: #{format_bytes_as_hex(bytes)}")
|
29
|
+
|
30
|
+
bytes
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def format_bytes_as_hex(bytes)
|
36
|
+
bytes.map { |s| format("0x%02X", s) }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Milight
|
4
|
+
module V6
|
5
|
+
class Zone
|
6
|
+
attr_reader :zone_id
|
7
|
+
|
8
|
+
def initialize(command, zone_id)
|
9
|
+
@command = command
|
10
|
+
@zone_id = zone_id
|
11
|
+
end
|
12
|
+
|
13
|
+
# Link/sync light bulbs.
|
14
|
+
def link
|
15
|
+
@command.link(zone_id)
|
16
|
+
|
17
|
+
self
|
18
|
+
end
|
19
|
+
|
20
|
+
# Unlink/clear light bulbs.
|
21
|
+
def unlink
|
22
|
+
@command.unlink(zone_id)
|
23
|
+
|
24
|
+
self
|
25
|
+
end
|
26
|
+
|
27
|
+
# Switch the lights on.
|
28
|
+
def on
|
29
|
+
@command.on(zone_id)
|
30
|
+
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
# Switch the lights off.
|
35
|
+
def off
|
36
|
+
@command.off(zone_id)
|
37
|
+
|
38
|
+
self
|
39
|
+
end
|
40
|
+
|
41
|
+
# Enable night light mode.
|
42
|
+
def night_light
|
43
|
+
@command.night_light(zone_id)
|
44
|
+
|
45
|
+
self
|
46
|
+
end
|
47
|
+
|
48
|
+
# Set brightness, value: 0% to 100%
|
49
|
+
def brightness(value)
|
50
|
+
@command.brightness(zone_id, value)
|
51
|
+
|
52
|
+
self
|
53
|
+
end
|
54
|
+
|
55
|
+
# Set color temperature, value: 0 = 2700K, 100 = 6500K.
|
56
|
+
def temperature(value)
|
57
|
+
@command.temperature(zone_id, value)
|
58
|
+
|
59
|
+
self
|
60
|
+
end
|
61
|
+
|
62
|
+
# Set color temperature to warm light (2700K).
|
63
|
+
def warm_light
|
64
|
+
@command.temperature(zone_id, 0)
|
65
|
+
|
66
|
+
self
|
67
|
+
end
|
68
|
+
|
69
|
+
# Set color temperature to white (cool) light (6500K).
|
70
|
+
def white_light
|
71
|
+
@command.temperature(zone_id, 100)
|
72
|
+
|
73
|
+
self
|
74
|
+
end
|
75
|
+
|
76
|
+
# Set the hue, value: 0 to 255 (red).
|
77
|
+
# See Milight::V6::Color for predefined colors.
|
78
|
+
def hue(value)
|
79
|
+
@command.hue(zone_id, value)
|
80
|
+
|
81
|
+
self
|
82
|
+
end
|
83
|
+
|
84
|
+
# Set the saturation, value: 0% to 100%.
|
85
|
+
def saturation(value)
|
86
|
+
@command.saturation(zone_id, value)
|
87
|
+
|
88
|
+
self
|
89
|
+
end
|
90
|
+
|
91
|
+
# Wait before continuing to next command.
|
92
|
+
def wait(seconds)
|
93
|
+
sleep(seconds)
|
94
|
+
|
95
|
+
self
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/milight-v6.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "milight/v6/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "milight-v6"
|
9
|
+
spec.version = Milight::V6::VERSION
|
10
|
+
spec.authors = ["Peter Postma"]
|
11
|
+
spec.email = ["peter.postma@gmail.com"]
|
12
|
+
|
13
|
+
spec.summary = "Ruby API for the Milight Wifi Bridge v6"
|
14
|
+
spec.description = "Ruby API for the Milight Wifi Bridge (or Wifi iBOX controller) version 6."
|
15
|
+
spec.homepage = "https://github.com/ppostma/milight-v6-api"
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
20
|
+
end
|
21
|
+
spec.executables = ["milight"]
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: milight-v6
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Peter Postma
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Ruby API for the Milight Wifi Bridge (or Wifi iBOX controller) version
|
56
|
+
6.
|
57
|
+
email:
|
58
|
+
- peter.postma@gmail.com
|
59
|
+
executables:
|
60
|
+
- milight
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- ".rspec"
|
66
|
+
- ".rubocop.yml"
|
67
|
+
- ".ruby-gemset"
|
68
|
+
- ".ruby-version"
|
69
|
+
- ".travis.yml"
|
70
|
+
- Gemfile
|
71
|
+
- Gemfile.lock
|
72
|
+
- LICENSE.txt
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- bin/console
|
76
|
+
- bin/milight
|
77
|
+
- bin/setup
|
78
|
+
- lib/milight/v6.rb
|
79
|
+
- lib/milight/v6/all.rb
|
80
|
+
- lib/milight/v6/color.rb
|
81
|
+
- lib/milight/v6/command.rb
|
82
|
+
- lib/milight/v6/controller.rb
|
83
|
+
- lib/milight/v6/socket.rb
|
84
|
+
- lib/milight/v6/version.rb
|
85
|
+
- lib/milight/v6/zone.rb
|
86
|
+
- milight-v6.gemspec
|
87
|
+
homepage: https://github.com/ppostma/milight-v6-api
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.6.14
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Ruby API for the Milight Wifi Bridge v6
|
111
|
+
test_files: []
|