Class: TPLink::Plug

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

Overview

Control TPLink Smart Plugs

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 device off


12
13
14
# File 'lib/tp_link/plug.rb', line 12

def off
  relay_state(0)
end

#onObject

Turn device on


7
8
9
# File 'lib/tp_link/plug.rb', line 7

def on
  relay_state(1)
end

#toggleObject

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


17
18
19
20
21
22
23
# File 'lib/tp_link/plug.rb', line 17

def toggle
  if on?
    off
  else
    on
  end
end