Class: Wizrb::Lighting::State
Constant Summary
collapse
- STATE_KEYS =
%i[state w c r g b temp dimming speed sceneId].freeze
Instance Method Summary
collapse
#initialize, #power, #to_json, #to_s
Instance Method Details
#brightness ⇒ Object
32
33
34
|
# File 'lib/wizrb/lighting/state.rb', line 32
def brightness
@state[:dimming]
end
|
#cold_white ⇒ Object
20
21
22
|
# File 'lib/wizrb/lighting/state.rb', line 20
def cold_white
@state[:c]
end
|
#color_temp ⇒ Object
28
29
30
|
# File 'lib/wizrb/lighting/state.rb', line 28
def color_temp
@state[:temp]
end
|
#parse!(response) ⇒ Object
8
9
10
11
12
13
14
|
# File 'lib/wizrb/lighting/state.rb', line 8
def parse!(response)
result = response&.dig("result")
return unless result
@state = result.transform_keys(&:to_sym).slice(*STATE_KEYS)
@state.delete(:sceneId) if @state[:sceneId]&.zero?
end
|
#rgb ⇒ Object
24
25
26
|
# File 'lib/wizrb/lighting/state.rb', line 24
def rgb
{red: @state[:r], green: @state[:g], blue: @state[:b]}
end
|
#scene ⇒ Object
40
41
42
|
# File 'lib/wizrb/lighting/state.rb', line 40
def scene
Wizrb::Lighting::SCENES.key(@state[:schdPsetId] || @state[:sceneId])
end
|
#speed ⇒ Object
36
37
38
|
# File 'lib/wizrb/lighting/state.rb', line 36
def speed
@state[:speed]
end
|
#warm_white ⇒ Object
16
17
18
|
# File 'lib/wizrb/lighting/state.rb', line 16
def warm_white
@state[:w]
end
|