Class: X10::Cm17a::Device
- Inherits:
-
Object
- Object
- X10::Cm17a::Device
- Defined in:
- lib/x10/cm17a_device.rb
Overview
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
Instance Method Summary collapse
-
#initialize(house, unit, controller) ⇒ Device
constructor
Create a new X10 device using a CM17A protocol controller.
-
#off ⇒ Object
Turn the device off.
-
#on ⇒ Object
Turn the device on.
-
#step(steps) ⇒ Object
Adjust the brightness level by
steps
.
Constructor Details
#initialize(house, unit, controller) ⇒ Device
Create a new X10 device using a CM17A protocol controller. Such a device can handle on/off commands and simple dim controls.
Normally device objects are created through the X10 framework and not directly by the client software.
26 27 28 29 30 31 |
# File 'lib/x10/cm17a_device.rb', line 26 def initialize(house, unit, controller) @house = house @unit = unit @controller = controller @address = X10.make_address(house, unit) end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
18 19 20 |
# File 'lib/x10/cm17a_device.rb', line 18 def address @address end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
18 19 20 |
# File 'lib/x10/cm17a_device.rb', line 18 def controller @controller end |
Instance Method Details
#off ⇒ Object
Turn the device off.
39 40 41 |
# File 'lib/x10/cm17a_device.rb', line 39 def off @controller.command(@house, @unit, :off, 0) end |
#on ⇒ Object
Turn the device on.
34 35 36 |
# File 'lib/x10/cm17a_device.rb', line 34 def on @controller.command(@house, @unit, :on, 0) end |
#step(steps) ⇒ Object
Adjust the brightness level by steps
. If steps
is positive, the brightness level is increased that many steps. If steps
is negative, the brightness level is decreased by
|steps|
.
The controller limits the step size to 6, so larger steps must be broken up.
50 51 52 53 54 55 56 57 58 |
# File 'lib/x10/cm17a_device.rb', line 50 def step(steps) direction = (steps > 0) ? :brighten : :dim nsteps = steps.abs while nsteps > 0 n = (nsteps > 6) ? 6 : nsteps @controller.command(@house, @unit, direction, n) nsteps -= n end end |