class Belphanior::Servant::HomeNetwork::Insteon_2412n_x10_Codec
Constants
- ADDRESS_SUFFIX
- COMMAND_CODE_TABLE
- COMMAND_SUFFIX
- HOUSE_CODE_TABLE
- UNIT_CODE_TABLE
- X10_PREFIX
Public Class Methods
new(marshaller)
click to toggle source
# File lib/belphanior/servant/homenetwork/insteon_2412n_x10_codec.rb, line 31 def initialize(marshaller) @marshaller = marshaller end
Public Instance Methods
device_brighter(identifier)
click to toggle source
# File lib/belphanior/servant/homenetwork/insteon_2412n_x10_codec.rb, line 43 def device_brighter(identifier) send_command(identifier, :brighter) end
device_dimmer(identifier)
click to toggle source
# File lib/belphanior/servant/homenetwork/insteon_2412n_x10_codec.rb, line 47 def device_dimmer(identifier) send_command(identifier, :dimmer) end
device_off(identifier)
click to toggle source
# File lib/belphanior/servant/homenetwork/insteon_2412n_x10_codec.rb, line 39 def device_off(identifier) send_command(identifier, :off) end
device_on(identifier)
click to toggle source
# File lib/belphanior/servant/homenetwork/insteon_2412n_x10_codec.rb, line 35 def device_on(identifier) send_command(identifier, :on) end
Private Instance Methods
select_code(house_and_unit)
click to toggle source
Converts house, unit code string to hex command string
# File lib/belphanior/servant/homenetwork/insteon_2412n_x10_codec.rb, line 61 def select_code(house_and_unit) if not house_and_unit.length <= 3 raise BadCode, "Code should be three characters or less." end house = house_and_unit[0..0] unit = house_and_unit[1..2] if not HOUSE_CODE_TABLE.has_key? house raise BadCode, "House code was '" << house << "', must be between 'A' and 'P'" end if not UNIT_CODE_TABLE.has_key? unit raise BadCode, "Unit code was '" << unit << "', must be between '1' and '16'" end [HOUSE_CODE_TABLE[house], UNIT_CODE_TABLE[unit]] end
send_command(house_and_unit, command)
click to toggle source
sends command to device specified by house and unit string
# File lib/belphanior/servant/homenetwork/insteon_2412n_x10_codec.rb, line 53 def send_command(house_and_unit, command) house_code, unit_code = select_code(house_and_unit) @marshaller.send(X10_PREFIX + house_code + unit_code + ADDRESS_SUFFIX) @marshaller.send(X10_PREFIX + house_code + COMMAND_CODE_TABLE[command] + COMMAND_SUFFIX) end