Module: TpLinkSmartplug

Defined in:
lib/tp_link_smartplug.rb,
lib/tp_link_smartplug/_base.rb,
lib/tp_link_smartplug/device.rb,
lib/tp_link_smartplug/command.rb,
lib/tp_link_smartplug/helpers.rb,
lib/tp_link_smartplug/message.rb,
lib/tp_link_smartplug/version.rb

Overview

Author:

  • Ben Hughes

Defined Under Namespace

Modules: Command, Helpers, Message Classes: Base, BaseError, Device, DeviceError

Constant Summary collapse

VERSION =

Gem version

'0.4.0'.freeze

Instance Method Summary collapse

Instance Method Details

#alias=(name) ⇒ Hash

Set plug alias

Parameters:

  • name (String)

    the name to assign to the plug alias

Returns:

  • (Hash)

    the output from the plug command



210
211
212
# File 'lib/tp_link_smartplug/device.rb', line 210

def alias=(name)
  JSON.parse(poll(command: "{\"system\":{\"set_dev_alias\":{\"alias\":\"#{name}\"}}}"))
end

#location!(longitude, lattitude) ⇒ Hash

Set plug location

Parameters:

  • longitude (String)

    the longitude to assign to the plug location

  • lattitude (String)

    the lattitude to assign to the plug location

Returns:

  • (Hash)

    the output from the plug command



219
220
221
# File 'lib/tp_link_smartplug/device.rb', line 219

def location!(longitude, lattitude)
  JSON.parse(poll(command: "{\"system\":{\"set_dev_location\":{\"longitude\":\"#{lattitude}\", \"latitude\":\"#{longitude}\"}}}"))
end