rzwaveway 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/rzwaveway/command_classes/battery.rb +0 -4
 - data/lib/rzwaveway/command_classes/switch_multi_level.rb +2 -1
 - data/lib/rzwaveway/command_classes/wake_up.rb +6 -3
 - data/lib/rzwaveway/version.rb +1 -1
 - data/lib/rzwaveway/zwave_device.rb +12 -21
 - data/spec/zwave_device_spec.rb +15 -0
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 01e99f245086e41fbeca9e16d6c0c6867324906d
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: adc57ec22b54fb1f084b2adc44bbcde9835fb3c8
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 54c2f9b32d733c49a8e5022e452cc8d16c828f9b7eab5da5436db7dab2c15b73f7391378895f163b17bc6558a46dd13c3330e033a255d9b8fc23d0a973264687
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 7c1b8a78ebd3e5942b86e576b9e2323089b865c73dff680c7edd031c0c096e50afed5aa469db3853523b8911e640a53567e2ad8affbee8b55f10652f934e6486
         
     | 
| 
         @@ -7,7 +7,8 @@ module RZWaveWay 
     | 
|
| 
       7 
7 
     | 
    
         
             
                    @device = device
         
     | 
| 
       8 
8 
     | 
    
         
             
                    @device.add_property(name: :level,
         
     | 
| 
       9 
9 
     | 
    
         
             
                                         value: find('data.level.value', data),
         
     | 
| 
       10 
     | 
    
         
            -
                                         update_time: find('data.level.updateTime', data) 
     | 
| 
      
 10 
     | 
    
         
            +
                                         update_time: find('data.level.updateTime', data),
         
     | 
| 
      
 11 
     | 
    
         
            +
                                         read_only: false)
         
     | 
| 
       11 
12 
     | 
    
         
             
                  end
         
     | 
| 
       12 
13 
     | 
    
         | 
| 
       13 
14 
     | 
    
         
             
                  def process(updates)
         
     | 
| 
         @@ -11,13 +11,16 @@ module RZWaveWay 
     | 
|
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
                    @device.add_property(name: :wakeup_interval,
         
     | 
| 
       13 
13 
     | 
    
         
             
                                         value: wakeup_interval,
         
     | 
| 
       14 
     | 
    
         
            -
                                         update_time: find('data.interval.updateTime', data) 
     | 
| 
      
 14 
     | 
    
         
            +
                                         update_time: find('data.interval.updateTime', data),
         
     | 
| 
      
 15 
     | 
    
         
            +
                                         internal: true)
         
     | 
| 
       15 
16 
     | 
    
         
             
                    @device.add_property(name: :wakeup_last_sleep_time,
         
     | 
| 
       16 
17 
     | 
    
         
             
                                         value: last_sleep_time,
         
     | 
| 
       17 
     | 
    
         
            -
                                         update_time: find('data.lastSleep.updateTime', data) 
     | 
| 
      
 18 
     | 
    
         
            +
                                         update_time: find('data.lastSleep.updateTime', data),
         
     | 
| 
      
 19 
     | 
    
         
            +
                                         internal: true)
         
     | 
| 
       18 
20 
     | 
    
         
             
                    @device.add_property(name: :wakeup_last_wakeup_time,
         
     | 
| 
       19 
21 
     | 
    
         
             
                                         value: last_wakeup_time,
         
     | 
| 
       20 
     | 
    
         
            -
                                         update_time: find('data. 
     | 
| 
      
 22 
     | 
    
         
            +
                                         update_time: find('data.lastWakeup.updateTime', data),
         
     | 
| 
      
 23 
     | 
    
         
            +
                                         internal: true)
         
     | 
| 
       21 
24 
     | 
    
         | 
| 
       22 
25 
     | 
    
         
             
                    @device.contact_frequency = wakeup_interval
         
     | 
| 
       23 
26 
     | 
    
         
             
                    @device.notify_contacted(last_wakeup_time)
         
     | 
    
        data/lib/rzwaveway/version.rb
    CHANGED
    
    
| 
         @@ -25,22 +25,6 @@ module RZWaveWay 
     | 
|
| 
       25 
25 
     | 
    
         
             
                  @last_contact_time + (@contact_frequency * (1 + @missed_contact_count) * 1.1)
         
     | 
| 
       26 
26 
     | 
    
         
             
                end
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
                def to_json
         
     | 
| 
       29 
     | 
    
         
            -
                  attributes = {
         
     | 
| 
       30 
     | 
    
         
            -
                    name: @name,
         
     | 
| 
       31 
     | 
    
         
            -
                    deviceId: @id,
         
     | 
| 
       32 
     | 
    
         
            -
                    # TODO remove these obsolete attributes (kept for backward compatibility)
         
     | 
| 
       33 
     | 
    
         
            -
                    lastSleepTime: @last_contact_time,
         
     | 
| 
       34 
     | 
    
         
            -
                    lastWakeUpTime: @last_contact_time,
         
     | 
| 
       35 
     | 
    
         
            -
                    wakeUpInterval: @contact_frequency,
         
     | 
| 
       36 
     | 
    
         
            -
                    # ---
         
     | 
| 
       37 
     | 
    
         
            -
                    # 'lastContactTime' => @last_contact_time,
         
     | 
| 
       38 
     | 
    
         
            -
                    # 'contactFrequency' => @contact_frequency,
         
     | 
| 
       39 
     | 
    
         
            -
                    properties: @properties
         
     | 
| 
       40 
     | 
    
         
            -
                  }
         
     | 
| 
       41 
     | 
    
         
            -
                  attributes.to_json
         
     | 
| 
       42 
     | 
    
         
            -
                end
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
28 
     | 
    
         
             
                def support_commandclass?(command_class_id)
         
     | 
| 
       45 
29 
     | 
    
         
             
                  @command_classes.has_key? command_class_id
         
     | 
| 
       46 
30 
     | 
    
         
             
                end
         
     | 
| 
         @@ -87,14 +71,21 @@ module RZWaveWay 
     | 
|
| 
       87 
71 
     | 
    
         
             
                  end
         
     | 
| 
       88 
72 
     | 
    
         
             
                end
         
     | 
| 
       89 
73 
     | 
    
         | 
| 
       90 
     | 
    
         
            -
                def add_property( 
     | 
| 
       91 
     | 
    
         
            -
                  name =  
     | 
| 
       92 
     | 
    
         
            -
                  read_only =  
     | 
| 
       93 
     | 
    
         
            -
                  @properties[name] =  
     | 
| 
      
 74 
     | 
    
         
            +
                def add_property(property)
         
     | 
| 
      
 75 
     | 
    
         
            +
                  name = property.delete(:name)
         
     | 
| 
      
 76 
     | 
    
         
            +
                  property[:read_only] = true unless property.has_key? :read_only
         
     | 
| 
      
 77 
     | 
    
         
            +
                  @properties[name] = property
         
     | 
| 
       94 
78 
     | 
    
         
             
                end
         
     | 
| 
       95 
79 
     | 
    
         | 
| 
       96 
80 
     | 
    
         
             
                def get_property(name)
         
     | 
| 
       97 
     | 
    
         
            -
                  [ 
     | 
| 
      
 81 
     | 
    
         
            +
                  [
         
     | 
| 
      
 82 
     | 
    
         
            +
                    @properties[name][:value],
         
     | 
| 
      
 83 
     | 
    
         
            +
                    @properties[name][:update_time]
         
     | 
| 
      
 84 
     | 
    
         
            +
                  ]
         
     | 
| 
      
 85 
     | 
    
         
            +
                end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
                def properties
         
     | 
| 
      
 88 
     | 
    
         
            +
                  @properties.reject { |_, property| property.has_key? :internal }
         
     | 
| 
       98 
89 
     | 
    
         
             
                end
         
     | 
| 
       99 
90 
     | 
    
         | 
| 
       100 
91 
     | 
    
         
             
                def update_property(name, value, update_time)
         
     | 
    
        data/spec/zwave_device_spec.rb
    CHANGED
    
    | 
         @@ -53,6 +53,21 @@ module RZWaveWay 
     | 
|
| 
       53 
53 
     | 
    
         
             
                  end
         
     | 
| 
       54 
54 
     | 
    
         
             
                end
         
     | 
| 
       55 
55 
     | 
    
         | 
| 
      
 56 
     | 
    
         
            +
                describe '#properties' do
         
     | 
| 
      
 57 
     | 
    
         
            +
                  it 'returns the name and value of all properties' do
         
     | 
| 
      
 58 
     | 
    
         
            +
                    device.add_property({ name: 'prop1', value: 123, update_time: 1390252000 })
         
     | 
| 
      
 59 
     | 
    
         
            +
                    device.add_property({ name: 'prop2', value: 456, update_time: 1390252000 })
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                    expect(device.properties).to eq( 'prop1' => { value: 123, update_time: 1390252000, read_only: true },
         
     | 
| 
      
 62 
     | 
    
         
            +
                                                     'prop2' => { value: 456, update_time: 1390252000, read_only: true })
         
     | 
| 
      
 63 
     | 
    
         
            +
                  end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                  it 'does not include internal properties' do
         
     | 
| 
      
 66 
     | 
    
         
            +
                    device.add_property({ name: 'prop1', value: 123, update_time: 1390252000, internal: true })
         
     | 
| 
      
 67 
     | 
    
         
            +
                    expect(device.properties).to be_empty
         
     | 
| 
      
 68 
     | 
    
         
            +
                  end
         
     | 
| 
      
 69 
     | 
    
         
            +
                end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
       56 
71 
     | 
    
         
             
                describe '#contacts_controller_periodically?' do
         
     | 
| 
       57 
72 
     | 
    
         
             
                  it 'returns true if device supports wake up cc' do
         
     | 
| 
       58 
73 
     | 
    
         
             
                    expect(device.contacts_controller_periodically?).to be true
         
     |