Class: RZWaveWay::CommandClasses::SwitchBinary

Inherits:
RZWaveWay::CommandClass show all
Defined in:
lib/rzwaveway/command_classes/switch_binary.rb

Constant Summary

Constants inherited from RZWaveWay::CommandClass

RZWaveWay::CommandClass::ALARM, RZWaveWay::CommandClass::ALARM_SENSOR, RZWaveWay::CommandClass::ASSOCIATION, RZWaveWay::CommandClass::BASIC, RZWaveWay::CommandClass::BATTERY, RZWaveWay::CommandClass::CONFIGURATION, RZWaveWay::CommandClass::MANUFACTURER_SPECIFIC, RZWaveWay::CommandClass::METER, RZWaveWay::CommandClass::NOTIFICATION, RZWaveWay::CommandClass::SECURITY, RZWaveWay::CommandClass::SENSOR_BINARY, RZWaveWay::CommandClass::SENSOR_MULTI_LEVEL, RZWaveWay::CommandClass::SWITCH_BINARY, RZWaveWay::CommandClass::SWITCH_MULTI_LEVEL, RZWaveWay::CommandClass::VERSION, RZWaveWay::CommandClass::WAKEUP

Instance Attribute Summary

Attributes inherited from RZWaveWay::CommandClass

#device

Instance Method Summary collapse

Methods inherited from RZWaveWay::CommandClass

#initialize, #name, #to_s

Methods included from PropertiesCache

#save_properties, #to_hash

Methods included from Logger

#log

Constructor Details

This class inherits a constructor from RZWaveWay::CommandClass

Instance Method Details

#build_from(data) ⇒ Object



5
6
7
# File 'lib/rzwaveway/command_classes/switch_binary.rb', line 5

def build_from(data)
  define_property(:level, 'data.level', false, data)
end

#level=(value) ⇒ Object



20
21
22
# File 'lib/rzwaveway/command_classes/switch_binary.rb', line 20

def level=(value)
  RZWaveWay::ZWay.instance.execute(device.id, SWITCH_BINARY, :Set, value)
end

#process(updates) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/rzwaveway/command_classes/switch_binary.rb', line 9

def process(updates)
  if updates.keys.include?('data.level')
    data = updates['data.level']
    value = data['value']
    update_time = data['updateTime']
    if @properties[:level].update(value, update_time)
      yield LevelEvent.new(device_id: device.id, time: update_time, level: value)
    end
  end
end

#refreshObject



24
25
26
# File 'lib/rzwaveway/command_classes/switch_binary.rb', line 24

def refresh
  RZWaveWay::ZWay.instance.execute(device.id, SWITCH_BINARY, :Get)
end