humble_rpi-plugin-pir 0.1.2 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1bfd39e7a20026132f7281e13c61dca45ff0a4a0
4
- data.tar.gz: 33b9e5aa8f1f7b4121cc41dcce44aac3f42ee762
3
+ metadata.gz: 7c77f7fdcfdd99682f5223785a1dd52fe71e89a2
4
+ data.tar.gz: 7369518bab17977ab4d25ade875eb11956f692f3
5
5
  SHA512:
6
- metadata.gz: 8c836e2e892e8b32453aa4910e4fa9047f8a137773476d122d6a280b5f690d9bac5c70bb0942a15a5a633c1179f2856d8c4acad8731b2f6eb20e8622a5e5477d
7
- data.tar.gz: e560788a10ce4a45d3de61a91845d360bc9a7832af3433fa2e9627d129f92da38a8da409f1af9d1032616aa337086b7d4df74438697d0c3c1691de95b495b1f9
6
+ metadata.gz: 05cd47f928086656dd9218d12e626f0ea0ee708d6287b5235543479f035acc72644e16e3c97345b74d8b8e787f02a514afc33a50af3bf516974049059000001c
7
+ data.tar.gz: 7cf2b9b15f41c06ddaded52d5a151c06e9392d5d078572b5c1992cad3eaf22de5b590e8087845a18173a95fa67d6750fc175e8b34da1a92ac3c700962a1e4fc3
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -2,31 +2,21 @@
2
2
 
3
3
  # file: humble_rpi-plugin-pir.rb
4
4
 
5
+
6
+ require 'rpi_pinin'
5
7
  require 'chronic_duration'
6
- require 'pi_piper'
8
+
7
9
 
8
10
 
9
11
  class HumbleRPiPluginPir
10
- include PiPiper
12
+
11
13
 
12
14
  def initialize(settings: {}, variables: {})
13
15
 
14
- @pins = settings[:pins]
16
+ @pins = settings[:pins].map {|x| RPiPinIn.new x}
15
17
  @duration = settings[:duration] || '1 minute'
16
18
  @notifier = variables[:notifier]
17
19
  @device_id = variables[:device_id] || 'pi'
18
-
19
- at_exit do
20
-
21
- @pins.each do |pin|
22
-
23
- uexp = open("/sys/class/gpio/unexport", "w")
24
- uexp.write(pin)
25
- uexp.close
26
-
27
- end
28
- end
29
-
30
20
 
31
21
  end
32
22
 
@@ -41,29 +31,31 @@ class HumbleRPiPluginPir
41
31
  t1 = Time.now - (ChronicDuration.parse(duration) + 10)
42
32
 
43
33
  puts 'ready to detect motion'
44
-
34
+
45
35
  @pins.each.with_index do |pin, i|
46
-
47
- after pin: pin.to_i, goes: :high do
36
+
37
+ Thread.new do
48
38
 
49
- count += 1
50
-
51
- if Time.now > t1 + ChronicDuration.parse(duration) then
52
-
53
- notifier.notice "%s/motion/%s: detected %s times within the past %s" \
54
- % [device_id, i, count, duration]
55
- t1 = Time.now
56
- count = 0
57
- end
58
-
59
- end
39
+ pin.watch_high do
40
+
41
+ count += 1
42
+
43
+ if Time.now > t1 + ChronicDuration.parse(duration) then
44
+
45
+ notifier.notice \
46
+ "%s/motion/%s: detected %s times within the past %s" % \
47
+ [device_id, i, count, duration]
48
+ t1 = Time.now
49
+ count = 0
50
+ end
51
+
52
+ end #/ watch_high
53
+ end #/ thread
60
54
  end
61
55
 
62
- PiPiper.wait
63
-
64
56
  end
65
57
 
66
58
  alias on_start start
67
59
 
68
60
 
69
- end
61
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: humble_rpi-plugin-pir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,28 +31,28 @@ cert_chain:
31
31
  sZmb/8bK00PWuk0XFH654xoL460Lx6jtyKxF+AGbl41ABU8/37TLpQ4JR+zak1pD
32
32
  6ChqgwUNdmh5Tw==
33
33
  -----END CERTIFICATE-----
34
- date: 2015-06-14 00:00:00.000000000 Z
34
+ date: 2016-04-11 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
- name: pi_piper
37
+ name: rpi_pinin
38
38
  requirement: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: '1.3'
42
+ version: '0.1'
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- version: 1.3.2
45
+ version: 0.1.2
46
46
  type: :runtime
47
47
  prerelease: false
48
48
  version_requirements: !ruby/object:Gem::Requirement
49
49
  requirements:
50
50
  - - "~>"
51
51
  - !ruby/object:Gem::Version
52
- version: '1.3'
52
+ version: '0.1'
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: 1.3.2
55
+ version: 0.1.2
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: chronic_duration
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  version: '0'
102
102
  requirements: []
103
103
  rubyforge_project:
104
- rubygems_version: 2.4.6
104
+ rubygems_version: 2.4.8
105
105
  signing_key:
106
106
  specification_version: 4
107
107
  summary: A humble_rpi plugin which detects motion for 1 or more PIR sensor.
metadata.gz.sig CHANGED
Binary file