Class: TPLink::Light

Inherits:
Device show all
Defined in:
lib/tp_link/light.rb

Overview

Control TPLink Dimmable lights

Examples:

light.on # turn on light
light.off # turn off light

# turn on light and set brightness to 50%
light.on
light.on(50)

Instance Attribute Summary

Attributes inherited from Device

#alias, #name, #status

Instance Method Summary collapse

Methods inherited from Device

#off?, #on?, #reload, #rssi

Instance Method Details

#offObject

Turn light off



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

def off
  transition_light_state(0, 100)
end

#on(b = 100) ⇒ Object

Turn light on

Parameters:

  • b (Integer<1-100>) (defaults to: 100)

    Set light intensity between 1 and 100



15
16
17
18
# File 'lib/tp_link/light.rb', line 15

def on(b = 100)
  transition_light_state(1, b) if self.off?
  transition_light_state(1, b)
end

#toggleObject

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



26
27
28
29
30
31
32
# File 'lib/tp_link/light.rb', line 26

def toggle
  if on?
    off
  else
    on
  end
end