humble_rpi-plugin-magneticswitch 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 +1 -0
- data.tar.gz.sig +1 -0
- data/lib/humble_rpi-plugin-magneticswitch.rb +70 -0
- metadata +88 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e5372c95725130fb8c6df5fc93b810f5eeee497d
|
4
|
+
data.tar.gz: 3f709fb7d07ccc460ebb80a4e290ab4191ab2409
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2d625ef3b46a3d3966291a6feb725a934edfaa0fa6748496468fdffc7298f88d3ef8203f1c4bf0738eb39e02bf2958edbd13e1b06dc8281bf5d6bd31b2ee6f6d
|
7
|
+
data.tar.gz: c3700a8291345368cb2140eb9555574e7048f33ea66006800af7f332b6e70eb221d34c05eb1e0018f54179f795290a89a88dec9e23468de5a686a8784427cd68
|
checksums.yaml.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
�$�4�c5�����'��s�Rj�WL@���W�c����C�����!>j_����e�"t�`Kk!�b�D� +�=�t���6L���gM��k�#��S�V�6a0�=����a_���P��p�7�}h�-���ciQ Z�pI��Z9TA";������̟t�?h�4�e 8HYu�@�@k��.�)8�Qv#�
|
data.tar.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
�:���Ύe�e�ԉɄT���"{�>@r
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: humble_rpi-plugin-magneticswitch.rb
|
4
|
+
|
5
|
+
|
6
|
+
require 'pi_piper'
|
7
|
+
|
8
|
+
|
9
|
+
class HumbleRPiPluginMagneticSwitch
|
10
|
+
include PiPiper
|
11
|
+
|
12
|
+
def initialize(settings: {}, variables: {})
|
13
|
+
|
14
|
+
@nc = settings[:nc] || true
|
15
|
+
@pins = settings[:pins]
|
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
|
+
notifier = @notifier
|
36
|
+
device_id = @device_id
|
37
|
+
nc = @nc
|
38
|
+
|
39
|
+
puts 'ready to detect magnetic switches'
|
40
|
+
|
41
|
+
@pins.each.with_index do |button, i|
|
42
|
+
|
43
|
+
puts 'magnetic switch sensor %s on GPIO %s enabled ' % [i+1, button]
|
44
|
+
|
45
|
+
n = (i+1).to_s
|
46
|
+
|
47
|
+
PiPiper.watch :pin => button.to_i, :invert => nc do |pin|
|
48
|
+
|
49
|
+
state = case pin.value
|
50
|
+
when 1
|
51
|
+
:open
|
52
|
+
when 0
|
53
|
+
:closed
|
54
|
+
end
|
55
|
+
|
56
|
+
notifier.notice "%s/magneticswitch/%s: door %s" % [device_id, i, state]
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
PiPiper.wait
|
63
|
+
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
alias on_start start
|
68
|
+
|
69
|
+
|
70
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: humble_rpi-plugin-magneticswitch
|
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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XE2KeQILOwerdFj0wdpPDKsjfzwgNJavrow7NezYtpbbkwimorLkB2wWrLWf/Q7A
|
28
|
+
D30wGBHSb+iCtq4O954p6hYhdSNMQ3FNA1H661Gq7NfkjC8D/LrmPgzoGji+ZF1a
|
29
|
+
TjIhaj/5u/dGrDmlXf62jq4ahCrTPrex3BR71s6tFWDbAVemyKUNXxeA/vfUZ28S
|
30
|
+
cNyCKJh9uGgaJd6WkczULaoGd53o7/hZeBRkOJYtlXKnX3T0Pjp0ea0Zogmofowc
|
31
|
+
bPWFwNbEi9CiEPveT/uvh62PLy8oXqUUvXHHxIjvpQICBlT6wc8vkY+Lz86rQ+xY
|
32
|
+
nKxNwaysAN6TFg==
|
33
|
+
-----END CERTIFICATE-----
|
34
|
+
date: 2016-02-18 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.9'
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.9.9
|
46
|
+
type: :runtime
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '1.9'
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 1.9.9
|
56
|
+
description:
|
57
|
+
email: james@r0bertson.co.uk
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/humble_rpi-plugin-magneticswitch.rb
|
63
|
+
homepage: https://github.com/jrobertson/humble_rpi-plugin-magneticswitch
|
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.4.8
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: A Humble RPi plugin which detects the opening or closing of a door using
|
87
|
+
a magnetic switch sensor.
|
88
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|