Class: Kasa::Device
- Inherits:
-
Object
- Object
- Kasa::Device
- Defined in:
- lib/kasa/devices.rb
Overview
Common methods across kasa devices
Direct Known Subclasses
Constant Summary collapse
- ON =
1
- OFF =
0
Instance Attribute Summary collapse
-
#alias ⇒ Object
readonly
Returns the value of attribute alias.
-
#dev_name ⇒ Object
readonly
Returns the value of attribute dev_name.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#mac ⇒ Object
readonly
Returns the value of attribute mac.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
-
#initialize(ip, args) ⇒ Device
constructor
initialize.
-
#off ⇒ Object
Turn off light.
-
#off? ⇒ Boolean
Is relay off?.
-
#on ⇒ Object
Turn on light.
-
#on? ⇒ Boolean
Is relay on?.
-
#sysinfo ⇒ Object
Get system information.
Constructor Details
#initialize(ip, args) ⇒ Device
initialize
12 13 14 15 16 17 18 |
# File 'lib/kasa/devices.rb', line 12 def initialize(ip, args) @ip = ip @alias = args['alias'] @model = args['model'] @dev_name = args['dev_name'] @mac = args['mac'] end |
Instance Attribute Details
#alias ⇒ Object (readonly)
Returns the value of attribute alias.
9 10 11 |
# File 'lib/kasa/devices.rb', line 9 def alias @alias end |
#dev_name ⇒ Object (readonly)
Returns the value of attribute dev_name.
9 10 11 |
# File 'lib/kasa/devices.rb', line 9 def dev_name @dev_name end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
9 10 11 |
# File 'lib/kasa/devices.rb', line 9 def ip @ip end |
#mac ⇒ Object (readonly)
Returns the value of attribute mac.
9 10 11 |
# File 'lib/kasa/devices.rb', line 9 def mac @mac end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
9 10 11 |
# File 'lib/kasa/devices.rb', line 9 def model @model end |
Instance Method Details
#off? ⇒ Boolean
Is relay off?
36 37 38 |
# File 'lib/kasa/devices.rb', line 36 def off? relay_state.zero? end |
#on? ⇒ Boolean
Is relay on?
41 42 43 |
# File 'lib/kasa/devices.rb', line 41 def on? relay_state.eql? 1 end |