Class: TuyaCloud::Device::Light
- Inherits:
-
Switchable
- Object
- Control
- Switchable
- TuyaCloud::Device::Light
- Defined in:
- lib/tuya_cloud/device.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#brightness ⇒ Object
Returns the value of attribute brightness.
Attributes inherited from Switchable
Attributes inherited from Control
Instance Method Summary collapse
-
#initialize(json, auth_context) ⇒ Light
constructor
A new instance of Light.
- #set_brightness(value) ⇒ Object
Methods inherited from Switchable
Methods inherited from Control
Constructor Details
#initialize(json, auth_context) ⇒ Light
Returns a new instance of Light.
76 77 78 79 |
# File 'lib/tuya_cloud/device.rb', line 76 def initialize(json, auth_context) super(json, auth_context) self.brightness = json['data']['brightness'].to_i end |
Instance Attribute Details
#brightness ⇒ Object
Returns the value of attribute brightness.
74 75 76 |
# File 'lib/tuya_cloud/device.rb', line 74 def brightness @brightness end |
Instance Method Details
#set_brightness(value) ⇒ Object
81 82 83 84 85 86 87 88 |
# File 'lib/tuya_cloud/device.rb', line 81 def set_brightness(value) raise ArgumentError unless value.is_a?(Integer) raise ArgumentError if value.negative? || value > 255 self.state = true process_request('brightnessSet', payload: { value: value }) self.brightness = value end |