myfirmata-plugin-pir 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +1 -0
- data.tar.gz.sig +0 -0
- data/lib/myfirmata-plugin-pir.rb +64 -0
- metadata +88 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b5a70abe759f5dbc59039f5ae6727453a0d5c177
|
4
|
+
data.tar.gz: ac2f386b1a3beda251599f4023bd1d63be635ed0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 85de8fea78496e247b309e2bf6458455b910f749c2951362d020d412ed34b79eaad435f963dde2130ac1664ce74231381d593dcac8958e0e78af82787d34b457
|
7
|
+
data.tar.gz: f295eb7b11d5cfc60cb8ed07b40c4b4e58bf7ce093e4b045e275977feff14a447682e6aed64d9afc9d26ea2825c8dab27df7fefe02d199d2a877cc87d5001620
|
checksums.yaml.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
���&�B�$D'�M]���4�uHYʩ�5�>t_�U`�A�Jr����s�48wUX�|N�"턕ya},� ���w�%�ߐ�>�~
|
data.tar.gz.sig
ADDED
Binary file
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: myfirmata-plugin-pir.rb
|
4
|
+
|
5
|
+
# a plugin for the myfirmata gem
|
6
|
+
|
7
|
+
require 'chronic_duration'
|
8
|
+
|
9
|
+
|
10
|
+
# note:
|
11
|
+
# the conditional statement for publishing a notice was based on the
|
12
|
+
# code from the humble_rpi-plugin-pir gem
|
13
|
+
|
14
|
+
class MyFirmataPluginPir
|
15
|
+
|
16
|
+
|
17
|
+
def initialize(arduino, settings: {}, variables: {})
|
18
|
+
|
19
|
+
@arduino = arduino
|
20
|
+
@settings, @variables = settings, variables
|
21
|
+
@pinx = @settings[:pin] || 2
|
22
|
+
|
23
|
+
@arduino.pin_mode @pinx, ArduinoFirmata::INPUT
|
24
|
+
@duration = settings[:duration] || '1 minute'
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
def start()
|
29
|
+
|
30
|
+
count = 0
|
31
|
+
|
32
|
+
duration = @duration
|
33
|
+
notifier = @variables[:notifier]
|
34
|
+
topic = @variables[:device_id]
|
35
|
+
msg = @settings[:msg] || 'motion'
|
36
|
+
pinx = @pinx
|
37
|
+
|
38
|
+
t1 = Time.now - (ChronicDuration.parse(duration) + 10)
|
39
|
+
|
40
|
+
puts 'ready to detect PIR sensor'
|
41
|
+
|
42
|
+
@arduino.on :digital_read do |pin, high|
|
43
|
+
|
44
|
+
if pin == pinx and high then
|
45
|
+
|
46
|
+
count += 1
|
47
|
+
|
48
|
+
if Time.now > t1 + ChronicDuration.parse(duration) then
|
49
|
+
|
50
|
+
notifier.notice \
|
51
|
+
"%s/motion: detected %s times within the past %s" % \
|
52
|
+
[topic, count, duration]
|
53
|
+
t1 = Time.now
|
54
|
+
count = 0
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
alias on_start start
|
63
|
+
|
64
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: myfirmata-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
|
+
8ixkARkWAmV1MB4XDTE3MDQxN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|
30
|
+
isI6b+kBoRenIT/VRx3QYZ2WQGCaG8bpelsyYTwiDvWBJWxvqFpe0QgpJRmaiP7e
|
31
|
+
qMYLyGZ6oqlJmCNJX+A9uVxKxLexn/B/52sLuZG+r6bZ0zGkKX1nmazfaBg7FM/4
|
32
|
+
RFgXKXS9Q8TOzA==
|
33
|
+
-----END CERTIFICATE-----
|
34
|
+
date: 2017-04-15 00:00:00.000000000 Z
|
35
|
+
dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: chronic_duration
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0.10'
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.10.6
|
46
|
+
type: :runtime
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0.10'
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.10.6
|
56
|
+
description:
|
57
|
+
email: james@jamesrobertson.eu
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/myfirmata-plugin-pir.rb
|
63
|
+
homepage: https://github.com/jrobertson/myfirmata-plugin-pir
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 2.6.8
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: A PIR motion sensing plugin for the MyFirmata gem. Publishes a message to
|
87
|
+
the SPS broker at a set inteval whenever motion is detected.
|
88
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|