Class: RZWaveWay::CommandClasses::Alarm

Inherits:
RZWaveWay::CommandClass show all
Defined in:
lib/rzwaveway/command_classes/alarm.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

#build_from, #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

#process(updates) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rzwaveway/command_classes/alarm.rb', line 5

def process(updates)
  updates.each do |key, value|
    if key == 'data.V1event'
      alarm_type = value['alarmType']['value']
      yield AlarmEvent.new(device_id: device.id,
                           time: value['updateTime'],
                           alarm_type: ALARM_TYPES[alarm_type],
                           level: value['level']['value'])
    else
      match_data = key.match(/^data.(\d+)/)
      if match_data
        alarm_type = match_data[1].to_i
        yield AlarmEvent.new(device_id: device.id,
                             time: value['updateTime'],
                             alarm_type: ALARM_TYPES[alarm_type],
                             level: value['event']['value'])
      end
    end
  end
end