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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/humble_rpi-plugin-pir.rb +24 -32
- metadata +8 -8
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c77f7fdcfdd99682f5223785a1dd52fe71e89a2
|
4
|
+
data.tar.gz: 7369518bab17977ab4d25ade875eb11956f692f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05cd47f928086656dd9218d12e626f0ea0ee708d6287b5235543479f035acc72644e16e3c97345b74d8b8e787f02a514afc33a50af3bf516974049059000001c
|
7
|
+
data.tar.gz: 7cf2b9b15f41c06ddaded52d5a151c06e9392d5d078572b5c1992cad3eaf22de5b590e8087845a18173a95fa67d6750fc175e8b34da1a92ac3c700962a1e4fc3
|
checksums.yaml.gz.sig
CHANGED
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
|
-
|
8
|
+
|
7
9
|
|
8
10
|
|
9
11
|
class HumbleRPiPluginPir
|
10
|
-
|
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
|
-
|
36
|
+
|
37
|
+
Thread.new do
|
48
38
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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.
|
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:
|
34
|
+
date: 2016-04-11 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
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
|
42
|
+
version: '0.1'
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1.
|
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
|
52
|
+
version: '0.1'
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 1.
|
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.
|
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
|