Class: LifxToys::Clouds

Inherits:
Object
  • Object
show all
Defined in:
lib/lifx_toys/clouds.rb

Constant Summary collapse

MIN_KELVIN =
2500
MAX_KELVIN =
9000
MIN_BRIGHTNESS =
10
MAX_BRIGHTNESS =
100
CYCLE_TIME =
5.0

Instance Method Summary collapse

Constructor Details

#initializeClouds

Returns a new instance of Clouds.



13
14
15
# File 'lib/lifx_toys/clouds.rb', line 13

def initialize
  @lights = LifxHttp::LifxLight.get_lights.select{|x| x.connected }
end

Instance Method Details

#random_brightnessObject



30
31
32
# File 'lib/lifx_toys/clouds.rb', line 30

def random_brightness
  rand(MIN_BRIGHTNESS..MAX_BRIGHTNESS).to_f / 100
end

#random_kelvinObject



26
27
28
# File 'lib/lifx_toys/clouds.rb', line 26

def random_kelvin
  rand(MIN_KELVIN..MAX_KELVIN)
end

#runObject



17
18
19
20
21
22
23
24
# File 'lib/lifx_toys/clouds.rb', line 17

def run
  while (true)
    @lights.each do |light|
      light.set_color("kelvin:#{random_kelvin} brightness:#{random_brightness}", duration: CYCLE_TIME* 1.5)
      sleep(CYCLE_TIME/ @lights.count)
    end
  end
end