myfirmata-plugin-pir 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/myfirmata-plugin-pir.rb +28 -5
- metadata +27 -23
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1e34ee48b5aadad771eb23f3c0bfed5a8895d6fc8cfc0ea3749facaa423964de
|
4
|
+
data.tar.gz: 2a78f18396256d2ed2521a235f7a41dfc2bc7b9aa1feb70e0b07596c84e4abc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01d5d29c0e9b241beaccb11c9ead82a69dea3fb780542fe67e7265e1c1d2a7b297038f081a6d3656c544021ae5c981a2ec816b9317d775e96f442effe7ad6c73
|
7
|
+
data.tar.gz: d6338f05478bb1ceaf82a89fbe154eb754aa415ee25b32ff1b43de737b2c5339ecc6317e22b8bce4e04f03f71e01d69f71e762c4573af3a5bf196f92d390a2b7
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/myfirmata-plugin-pir.rb
CHANGED
@@ -17,7 +17,9 @@ class MyFirmataPluginPir
|
|
17
17
|
def initialize(arduino, settings: {}, variables: {})
|
18
18
|
|
19
19
|
@arduino = arduino
|
20
|
-
@settings, @variables = settings, variables
|
20
|
+
@settings, @variables = settings, {debug: false}.merge(variables)
|
21
|
+
@debug = @variables[:debug
|
22
|
+
]
|
21
23
|
@pinx = @settings[:pin] || 2
|
22
24
|
|
23
25
|
@arduino.pin_mode @pinx, ArduinoFirmata::INPUT
|
@@ -30,28 +32,49 @@ class MyFirmataPluginPir
|
|
30
32
|
count = 0
|
31
33
|
|
32
34
|
duration = @duration
|
35
|
+
puts 'duration: ' + duration.inspect if @debug
|
33
36
|
notifier = @variables[:notifier]
|
34
37
|
topic = @variables[:device_id]
|
35
38
|
msg = @settings[:msg] || 'motion'
|
36
39
|
pinx = @pinx
|
37
|
-
threshold = @settings[:threshold]
|
40
|
+
threshold = if @settings[:threshold] then
|
41
|
+
@settings[:threshold]
|
42
|
+
else
|
43
|
+
ChronicDuration.parse(duration) > 30 ? 5 : 0
|
44
|
+
end
|
38
45
|
|
39
46
|
t1 = Time.now - (ChronicDuration.parse(duration) + 10)
|
47
|
+
puts 't1: ' + t1.inspect if @debug
|
40
48
|
|
41
49
|
puts 'ready to detect PIR sensor'
|
42
50
|
|
51
|
+
debug = @debug
|
52
|
+
|
43
53
|
@arduino.on :digital_read do |pin, high|
|
44
54
|
|
45
55
|
if pin == pinx and high then
|
46
56
|
|
47
57
|
count += 1
|
58
|
+
puts 'count: ' + count.inspect if debug
|
48
59
|
|
49
60
|
if Time.now > t1 + ChronicDuration.parse(duration) then
|
50
61
|
|
51
62
|
if count > threshold then
|
52
|
-
|
53
|
-
|
63
|
+
|
64
|
+
|
65
|
+
fqm = if ChronicDuration.parse(duration) == 1 then
|
66
|
+
"%s/motion: detected within the past second" % topic
|
67
|
+
elsif count == 1
|
68
|
+
"%s/motion: detected once within the past %s"% [topic, duration]
|
69
|
+
elsif count == 2
|
70
|
+
"%s/motion: detected twice within the past %s" % \
|
71
|
+
[topic, duration]
|
72
|
+
else
|
73
|
+
"%s/motion: detected %s times within the past %s" % \
|
54
74
|
[topic, count, duration]
|
75
|
+
end
|
76
|
+
|
77
|
+
notifier.notice fqm
|
55
78
|
end
|
56
79
|
t1 = Time.now
|
57
80
|
count = 0
|
@@ -64,4 +87,4 @@ class MyFirmataPluginPir
|
|
64
87
|
|
65
88
|
alias on_start start
|
66
89
|
|
67
|
-
end
|
90
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: myfirmata-plugin-pir
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,28 +10,32 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
13
|
+
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTgxMDA3MTUxNTU4WhcN
|
15
|
+
MTkxMDA3MTUxNTU4WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDMxhzM
|
17
|
+
j/5/QpWfT+0pKWV+8W6r9LlHE7K/HIAT/2rW6WmfNVuqM41MyPJ0TFik+roARH5W
|
18
|
+
QH0gg1CN3BDVbTQ99PQEBHQqwauULZqp6csGDluieLSClgHuttvb4ymxhO4F4rYO
|
19
|
+
P4se9y+K+0d8t1jFOLX9YOPmFWqcUiHF1JyOPsM59LrssDxEKoFctnZqtXawsgUD
|
20
|
+
OfYmdPYlT/TQrSQMvqLUrZYigaPdCIO8USVcy60PQEExFCVQrdIc2m/2IlUJcmdj
|
21
|
+
yp5Z7SldaBoV9E/7QU31QwOAgCN/jP6wmB+y7E0OLx7zkx8TJ0DSWCUWk32oRRS/
|
22
|
+
ACBhCL6dPHic5rI1CtM+YntBxyaujG7feAKHLoh0y3jIk29e8Phzy5VrQ6608v1w
|
23
|
+
+GTtkQr9MmbmiHO6k6YKP408b0IU8+N9g5aH3MFndxW8RcuZbZbQx6SxPlAhn/st
|
24
|
+
0Hg4Wlqu66YbZrs5picvF95M83sJeGTCin2MUAC9MJPywsdz61IiYcAT090CAwEA
|
25
|
+
AaOBijCBhzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUxwYELJ6r
|
26
|
+
LLs8mnef7QMx6c5JDhswJgYDVR0RBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
|
27
|
+
c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
|
28
|
+
BgkqhkiG9w0BAQsFAAOCAYEAKLl0/B9FpKO/HZE6bdzAg/vggPe/RF80/0xwOqDR
|
29
|
+
V7/tswbEseGKHMSpFdxZ2bj84B4HMIMe1gy7cJHjyJbS37MavawwHOvyUSMVEtNZ
|
30
|
+
xGFpysPkVanU6ueFDSG+6Vj30xLaK0GYsFcrZqB3rcnLAdejy8sAlmajN2rJWdE5
|
31
|
+
eYpJEqE14t3ZbJCJ5MWeqDIxIVFZg1R/vkaVy/vObr5RknBKYM05hqLbyuGETHAy
|
32
|
+
eSxpYZb7Ireskjj40arzukRaOPoCH6OdLrNbSHja+N9NPfpaWtG63sR6xnejnHHT
|
33
|
+
9mgqG6kEOWi6UOePIG7p8dwqLd0aqzNKR6YTVsCDllrwzvSYnL2QX39z6T4Fxs1K
|
34
|
+
50nzuR2cBqeUB3IXTa7CBPRkn+Ckncq/OWkzppClehwc4HmqGerByyQq1Bn3pJiD
|
35
|
+
B6RGukwevhrVxssJnRyPuEjYURxILqaBynKnS7mb+A/XbFiaWk7dH4hNRFFEQp4A
|
36
|
+
QtMcn44MoVHUH9Uh4q0FFx6x
|
33
37
|
-----END CERTIFICATE-----
|
34
|
-
date:
|
38
|
+
date: 2018-10-07 00:00:00.000000000 Z
|
35
39
|
dependencies:
|
36
40
|
- !ruby/object:Gem::Dependency
|
37
41
|
name: chronic_duration
|
@@ -80,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
84
|
version: '0'
|
81
85
|
requirements: []
|
82
86
|
rubyforge_project:
|
83
|
-
rubygems_version: 2.6
|
87
|
+
rubygems_version: 2.7.6
|
84
88
|
signing_key:
|
85
89
|
specification_version: 4
|
86
90
|
summary: A PIR motion sensing plugin for the MyFirmata gem. Publishes a message to
|
metadata.gz.sig
CHANGED
Binary file
|