specify brightness and temp for named settings
This commit is contained in:
parent
845d706b21
commit
ac72ba1f12
1 changed files with 41 additions and 10 deletions
51
lights
51
lights
|
|
@ -4,13 +4,34 @@ require 'huemote'
|
|||
|
||||
LIGHT_NAMES = ['Office 1', 'Office 2']
|
||||
TEMPS = {
|
||||
'bright' => 4200,
|
||||
'cloudy' => 3500,
|
||||
'sunrise' => 2200,
|
||||
'morning' => 2600,
|
||||
'noon' => 4200,
|
||||
'sunset' => 2600,
|
||||
'night' => 2200,
|
||||
'bright' => {
|
||||
brightness: 100,
|
||||
temp: 4200,
|
||||
},
|
||||
'cloudy' => {
|
||||
brightness: 90,
|
||||
temp: 3500,
|
||||
},
|
||||
'sunrise' => {
|
||||
brightness: 70,
|
||||
temp: 2600,
|
||||
},
|
||||
'morning' => {
|
||||
brightness: 90,
|
||||
temp: 2200,
|
||||
},
|
||||
'noon' => {
|
||||
brightness: 100,
|
||||
temp: 4200,
|
||||
},
|
||||
'sunset' => {
|
||||
brightness: 90,
|
||||
temp: 2600,
|
||||
},
|
||||
'night' => {
|
||||
brightness: 70,
|
||||
temp: 2200,
|
||||
},
|
||||
}
|
||||
TEMPS['sunny'] = TEMPS['bright']
|
||||
TEMPS['overcast'] = TEMPS['cloudy']
|
||||
|
|
@ -26,9 +47,19 @@ when 'on'
|
|||
lights.each(&:on!)
|
||||
else
|
||||
lights.each(&:on!)
|
||||
temp = TEMPS[setting] || setting.to_i
|
||||
if temp > 0
|
||||
lights.each { |l| l.kelvin(temp) }
|
||||
attrs = TEMPS[setting] || {
|
||||
brightness: (ARGV[1] || 80).to_i,
|
||||
temp: setting.to_i,
|
||||
}
|
||||
if attrs
|
||||
lights.each do |l|
|
||||
if attrs[:brightness]
|
||||
l.brightness(attrs[:brightness])
|
||||
end
|
||||
if attrs[:temp]
|
||||
l.kelvin(attrs[:temp])
|
||||
end
|
||||
end
|
||||
else
|
||||
puts "Unknown setting: #{setting}"
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue