Class: LifxToys::Sunrise
- Inherits:
-
Object
- Object
- LifxToys::Sunrise
- Defined in:
- lib/lifx_toys/sunrise.rb
Constant Summary collapse
- MIN_KELVIN =
2500
- MAX_KELVIN =
9000
- MIN_BRIGHTNESS =
0.0
- MAX_BRIGHTNESS =
1.0
- SUNRISE_TIME =
minutes
30 * # minutes 60.0
Instance Attribute Summary collapse
-
#end_brightness ⇒ Object
readonly
seconds.
-
#end_temperature ⇒ Object
readonly
seconds.
-
#start_brightness ⇒ Object
readonly
seconds.
-
#start_temperature ⇒ Object
readonly
seconds.
-
#sunrise_time ⇒ Object
readonly
seconds.
Instance Method Summary collapse
- #half_sunrise_time ⇒ Object
-
#initialize(selector = 'all', sunrise_time = SUNRISE_TIME, start_brightness = MIN_BRIGHTNESS, start_temperature = MIN_KELVIN, end_brightness = MAX_BRIGHTNESS, end_temperature = MAX_KELVIN) ⇒ Sunrise
constructor
A new instance of Sunrise.
-
#run ⇒ Object
warning: this method takes half the sunrise time to execute.
Constructor Details
#initialize(selector = 'all', sunrise_time = SUNRISE_TIME, start_brightness = MIN_BRIGHTNESS, start_temperature = MIN_KELVIN, end_brightness = MAX_BRIGHTNESS, end_temperature = MAX_KELVIN) ⇒ Sunrise
Returns a new instance of Sunrise.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/lifx_toys/sunrise.rb', line 20 def initialize(selector = 'all', sunrise_time = SUNRISE_TIME, start_brightness = MIN_BRIGHTNESS, start_temperature = MIN_KELVIN, end_brightness = MAX_BRIGHTNESS, end_temperature = MAX_KELVIN) @sunrise_time = sunrise_time @start_brightness = start_brightness @start_temperature = start_temperature @end_brightness = end_brightness @end_temperature = end_temperature @lights = LifxHttp::Api.with_default_selector(selector) end |
Instance Attribute Details
#end_brightness ⇒ Object (readonly)
seconds
14 15 16 |
# File 'lib/lifx_toys/sunrise.rb', line 14 def end_brightness @end_brightness end |
#end_temperature ⇒ Object (readonly)
seconds
14 15 16 |
# File 'lib/lifx_toys/sunrise.rb', line 14 def end_temperature @end_temperature end |
#start_brightness ⇒ Object (readonly)
seconds
14 15 16 |
# File 'lib/lifx_toys/sunrise.rb', line 14 def start_brightness @start_brightness end |
#start_temperature ⇒ Object (readonly)
seconds
14 15 16 |
# File 'lib/lifx_toys/sunrise.rb', line 14 def start_temperature @start_temperature end |
#sunrise_time ⇒ Object (readonly)
seconds
14 15 16 |
# File 'lib/lifx_toys/sunrise.rb', line 14 def sunrise_time @sunrise_time end |
Instance Method Details
#half_sunrise_time ⇒ Object
45 46 47 |
# File 'lib/lifx_toys/sunrise.rb', line 45 def half_sunrise_time sunrise_time / 2 end |
#run ⇒ Object
warning: this method takes half the sunrise time to execute
37 38 39 40 41 42 43 |
# File 'lib/lifx_toys/sunrise.rb', line 37 def run # pre-set light color to avoid green at low brightness @lights.set_color("brightness:#{start_brightness} kelvin:#{start_temperature}", duration: 0, power_on: false) @lights.set_color("brightness:#{end_brightness}", duration: half_sunrise_time) sleep(half_sunrise_time) @lights.set_color("kelvin:#{end_temperature}", duration: half_sunrise_time) end |