rzwaveway 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c12e4156998c8b5f3b5f46d45e1e155169d556c6
4
- data.tar.gz: 12394850fe070c5c3094507453159057fee67222
3
+ metadata.gz: 01e99f245086e41fbeca9e16d6c0c6867324906d
4
+ data.tar.gz: adc57ec22b54fb1f084b2adc44bbcde9835fb3c8
5
5
  SHA512:
6
- metadata.gz: 1ab8e9b3a74c1ba9a355193acecef32554527808ebfdf4ebe818a996e1e198f30d16749dc21e11b7b933c43ce87c4310368028b2406b934ff7a3f75d50090f45
7
- data.tar.gz: ffc3ff8422425c5a9fbdef9fe0d11dd30b0c00cfd6b6f955a6e7484beba1887896efddc3369c103f1c90b7da2481c491906ed1c4e631e26cad83c2cd8cfc5feb
6
+ metadata.gz: 54c2f9b32d733c49a8e5022e452cc8d16c828f9b7eab5da5436db7dab2c15b73f7391378895f163b17bc6558a46dd13c3330e033a255d9b8fc23d0a973264687
7
+ data.tar.gz: 7c1b8a78ebd3e5942b86e576b9e2323089b865c73dff680c7edd031c0c096e50afed5aa469db3853523b8911e640a53567e2ad8affbee8b55f10652f934e6486
@@ -21,10 +21,6 @@ module RZWaveWay
21
21
  end
22
22
  end
23
23
 
24
- def battery_value
25
- @device.get_property(:battery_level)[0]
26
- end
27
-
28
24
  def get
29
25
  RZWaveWay::ZWay.instance.execute(@device.id, BATTERY, :Get)
30
26
  end
@@ -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.lastSleep.updateTime', 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)
@@ -1,3 +1,3 @@
1
1
  module RZWaveWay
2
- VERSION = '0.0.10'
2
+ VERSION = '0.0.11'
3
3
  end
@@ -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(options)
91
- name = options.delete(:name)
92
- read_only = options.delete(:read_only) || true
93
- @properties[name] = options
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
- [ @properties[name][:value], @properties[name][:update_time] ]
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)
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rzwaveway
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Touchard