Class: Kasa::SmartStrip

Inherits:
NonDimmable show all
Defined in:
lib/kasa/devices.rb

Overview

add dimmable device

Constant Summary

Constants inherited from Device

Device::OFF, Device::ON

Instance Attribute Summary collapse

Attributes inherited from Device

#alias, #dev_name, #ip, #mac, #model

Instance Method Summary collapse

Methods inherited from Device

#sysinfo

Constructor Details

#initialize(ip, args) ⇒ SmartStrip

Returns a new instance of SmartStrip.



86
87
88
89
# File 'lib/kasa/devices.rb', line 86

def initialize(ip, args)
  super
  @children = args['children'].map { |c| c['id'] }
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



84
85
86
# File 'lib/kasa/devices.rb', line 84

def children
  @children
end

Instance Method Details

#off(index) ⇒ Object

Turn off light



97
98
99
# File 'lib/kasa/devices.rb', line 97

def off(index)
  relay OFF, index
end

#off?(index) ⇒ Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/kasa/devices.rb', line 101

def off?(index)
  relay_state(index).zero?
end

#on(index) ⇒ Object

Turn on light



92
93
94
# File 'lib/kasa/devices.rb', line 92

def on(index)
  relay ON, index
end

#on?(index) ⇒ Boolean

Returns:

  • (Boolean)


105
106
107
# File 'lib/kasa/devices.rb', line 105

def on?(index)
  relay_state(index).eql? 1
end