Class: Light

Inherits:
HueResource show all
Defined in:
lib/ha/light.rb

Instance Method Summary collapse

Methods inherited from HueResource

#gen_reskey

Constructor Details

#initialize(key, hashvalue, grouparray) ⇒ Light

Returns a new instance of Light.



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/ha/light.rb', line 4

def initialize(key, hashvalue, grouparray)
  super(key, hashvalue)
  @grouparray = grouparray
  @onstate = hashvalue.dig("state", "on")
  @brightstate = hashvalue.dig("state", "bri")
  @combinedsate = "#{@onstate} (#{@brightstate})"
  @number = key
  @group = Group.owning(key, grouparray)
  gen_reskey("l")
  build_name
  @state.merge! ({"on" => @combinedsate})
end

Instance Method Details

#array(selectors) ⇒ Object



21
22
23
# File 'lib/ha/light.rb', line 21

def array(selectors)
  selectors.map { |key| @state[key] }
end

#build_nameObject



17
18
19
# File 'lib/ha/light.rb', line 17

def build_name
  @state["detail"] += " in " + Group.owning(@number, @grouparray).first.name
end