class Belphanior::Servant::HomeNetwork::Insteon_2412n_Insteon_Codec
Constants
- BRIGHTNESS_CODE_LIST
- COMMAND_CODE_TABLE
- INSTEON_PREFIX
Public Class Methods
new(marshaller)
click to toggle source
# File lib/belphanior/servant/homenetwork/insteon_2412n_insteon_codec.rb, line 26 def initialize(marshaller) @marshaller = marshaller end
Public Instance Methods
device_off(address)
click to toggle source
# File lib/belphanior/servant/homenetwork/insteon_2412n_insteon_codec.rb, line 34 def device_off(address) send_command(address, :fast_off, "FF") end
device_on(address)
click to toggle source
# File lib/belphanior/servant/homenetwork/insteon_2412n_insteon_codec.rb, line 30 def device_on(address) send_command(address, :fast_on, "FF") end
device_set_brightness(address, brightness)
click to toggle source
Set the brightness level. address: 6-hexcode address of INSTEON device. brightness: float value between 0 and 1
# File lib/belphanior/servant/homenetwork/insteon_2412n_insteon_codec.rb, line 41 def device_set_brightness(address, brightness) send_command(address, :on, brightness_value_to_code(brightness)) end
Private Instance Methods
brightness_value_to_code(brightness)
click to toggle source
# File lib/belphanior/servant/homenetwork/insteon_2412n_insteon_codec.rb, line 52 def brightness_value_to_code(brightness) if brightness < 0 then brightness = 0 end if brightness > 1 then brightness = 1 end BRIGHTNESS_CODE_LIST.each do |codepair| if brightness <= codepair[0] then return codepair[1] end end return "FF" end
send_command(address, command, brightness_code)
click to toggle source
sends command to device specified by address.
# File lib/belphanior/servant/homenetwork/insteon_2412n_insteon_codec.rb, line 47 def send_command(address, command, brightness_code) @marshaller.send(INSTEON_PREFIX + address + "0F" + COMMAND_CODE_TABLE[command] + brightness_code) end