humble_rpi-plugin-pir 0.1.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 +7 -0
- checksums.yaml.gz.sig +0 -0
- data/lib/humble_rpi-plugin-pir.rb +66 -0
- data.tar.gz.sig +0 -0
- metadata +107 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 17a9b34ec0daefc2289b836d631df4b0ad087291
|
4
|
+
data.tar.gz: 3d8ab10596c8e68540cf3dab595f9bae489cd0b0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 002f489f8cae0a548a88f9d53e52af2fc51dc6c9c4abc3771b0c704da703c4ac52724066d3c655bbade108f3690f6fe5ca98e5fc3309b40ae02c2be3d28fc3d7
|
7
|
+
data.tar.gz: 39af08307ac53689aa4f6c1f751d6c2d7dd33a5c77f26e124b3cf5672dbf2f59f18fd9255d9c21ace0d436ee5c6f18bbe4883a6534b1a22f5d4a06ed62641f7e
|
checksums.yaml.gz.sig
ADDED
Binary file
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: humble_rpi-plugin-pir.rb
|
4
|
+
|
5
|
+
require 'chronic_duration'
|
6
|
+
require 'pi_piper'
|
7
|
+
|
8
|
+
|
9
|
+
class HumbleRPiPluginPir
|
10
|
+
include PiPiper
|
11
|
+
|
12
|
+
def initialize(settings: {}, variables: {})
|
13
|
+
|
14
|
+
@pins = settings[:pins]
|
15
|
+
@duration = settings[:duration] || '1 minute'
|
16
|
+
@notifier = variables[:notifier]
|
17
|
+
@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
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
def start()
|
34
|
+
|
35
|
+
count = 0
|
36
|
+
t1 = Time.now - ChronicDuration.parse('1 minute and 10 seconds')
|
37
|
+
|
38
|
+
duration = @duration
|
39
|
+
notifier = @notifier
|
40
|
+
device_id = @device_id
|
41
|
+
|
42
|
+
@pins.each do |pin|
|
43
|
+
|
44
|
+
after pin: pin.to_i, goes: :high do
|
45
|
+
|
46
|
+
count += 1
|
47
|
+
|
48
|
+
if Time.now > t1 + ChronicDuration.parse(duration) then
|
49
|
+
|
50
|
+
notifier.notice "%s/motion: detected %s times within the past %s" \
|
51
|
+
% [device_id, count, duration]
|
52
|
+
t1 = Time.now
|
53
|
+
count = 0
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
PiPiper.wait
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
alias on_start start
|
64
|
+
|
65
|
+
|
66
|
+
end
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: humble_rpi-plugin-pir
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
|
14
|
+
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
+
8ixkARkWAmV1MB4XDTE1MDYxMzIwMTM1M1oXDTE2MDYxMjIwMTM1M1owSDESMBAG
|
16
|
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OipM7iNMDmNWMjTxEieQIoObxqUY
|
31
|
+
sZmb/8bK00PWuk0XFH654xoL460Lx6jtyKxF+AGbl41ABU8/37TLpQ4JR+zak1pD
|
32
|
+
6ChqgwUNdmh5Tw==
|
33
|
+
-----END CERTIFICATE-----
|
34
|
+
date: 2015-06-13 00:00:00.000000000 Z
|
35
|
+
dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: pi_piper
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '1.3'
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.3.2
|
46
|
+
type: :runtime
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '1.3'
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 1.3.2
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: chronic_duration
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.10'
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 0.10.6
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - "~>"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0.10'
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.10.6
|
76
|
+
description: This plugin can be tested in isolation with the Raspberry Pi.
|
77
|
+
email: james@r0bertson.co.uk
|
78
|
+
executables: []
|
79
|
+
extensions: []
|
80
|
+
extra_rdoc_files: []
|
81
|
+
files:
|
82
|
+
- lib/humble_rpi-plugin-pir.rb
|
83
|
+
homepage: https://github.com/jrobertson/humble_rpi-plugin-pir
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.4.6
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: A humble_rpi plugin which detects motion for 1 or more PIR sensor.
|
107
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|