Class: RZWaveWay::CommandClasses::WakeUp

Inherits:
RZWaveWay::CommandClass show all
Defined in:
lib/rzwaveway/command_classes/wake_up.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
8
9
10
11
# File 'lib/rzwaveway/command_classes/wake_up.rb', line 5

def build_from(data)
  define_property(:contact_frequency, 'data.interval', true, data)
  define_property(:last_sleep_time, 'data.lastSleep', true, data)
  define_property(:last_wakeup_time, 'data.lastWakeup', true, data)

  device.notify_contacted(find('data.lastWakeup.value', data))
end

#missed_contact_count(time = Time.now) ⇒ Object



13
14
15
# File 'lib/rzwaveway/command_classes/wake_up.rb', line 13

def missed_contact_count(time = Time.now)
  (elapsed_seconds_since_last_contact(time) / contact_frequency).to_i
end

#on_time?(time = Time.now) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/rzwaveway/command_classes/wake_up.rb', line 17

def on_time?(time = Time.now)
  elapsed_seconds_since_last_contact(time) < (contact_frequency * 1.2)
end

#process(updates) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rzwaveway/command_classes/wake_up.rb', line 21

def process(updates)
  if updates.keys.include?('data.lastWakeup')
    data = updates['data.lastWakeup']
    value = data['value']
    update_time = data['updateTime']
    if @properties[:last_wakeup_time].update(value, update_time)
      device.notify_contacted(value)
    end
  end
  nil
  # TODO handle change of wake up interval value?
end