Class: TuyaCloud::Device
- Inherits:
-
Object
- Object
- TuyaCloud::Device
- Defined in:
- lib/tuya_cloud/device.rb
Defined Under Namespace
Classes: ColorLight, Control, Light, Scene, Switch, Switchable
Instance Attribute Summary collapse
-
#controls ⇒ Object
Returns the value of attribute controls.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(json, auth_context) ⇒ Device
constructor
A new instance of Device.
Constructor Details
#initialize(json, auth_context) ⇒ Device
Returns a new instance of Device.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/tuya_cloud/device.rb', line 10 def initialize(json, auth_context) self.id = json['id'] self.name = json['name'] self.type = json['dev_type'] case type when 'light' self.controls = if json['data'] && json['data']['color_mode'] ColorLight.new(json, auth_context) else Light.new(json, auth_context) end when 'switch' self.controls = Switch.new(json, auth_context) when 'scene' self.controls = Scene.new(json, auth_context) else raise ArgumentError, 'unknown device type' end end |
Instance Attribute Details
#controls ⇒ Object
Returns the value of attribute controls.
5 6 7 |
# File 'lib/tuya_cloud/device.rb', line 5 def controls @controls end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/tuya_cloud/device.rb', line 5 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/tuya_cloud/device.rb', line 5 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/tuya_cloud/device.rb', line 5 def type @type end |