class TPLink::RGBLight

Control TP-Link LS130 / RGB lights

Public Instance Methods

off() click to toggle source

Turn light off

# File lib/tp_link/rgb_light.rb, line 12
def off
  transition_light_state(0, 100, 100, 100)
end
on(b = 100, h = 100, s = 100) click to toggle source

Turn Light on

# File lib/tp_link/rgb_light.rb, line 7
def on(b = 100, h = 100, s = 100)
  transition_light_state(1, b, h, s)
end
toggle() click to toggle source

Toggle device (turn off if on, on if off)

# File lib/tp_link/rgb_light.rb, line 17
def toggle
  if on?
    off
  else
    on
  end
end

Private Instance Methods

transition_light_state(o, b, h, s) click to toggle source
# File lib/tp_link/rgb_light.rb, line 27
def transition_light_state(o, b, h, s)
  @parent.send_data(self,
                    "smartlife.iot.smartbulb.lightingservice": {
                      "transition_light_state": {
                        "on_off": o,
                        "brightness": b,
                        "hue": h,
                        "saturation": s
                      }
                    })
end