humble_rpi-plugin-magneticswitch 0.1.0 → 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 +1 -1
- data/lib/humble_rpi-plugin-magneticswitch.rb +15 -30
- metadata +7 -7
- 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: fca6cd9ded5712a16f6854a377a9b17da0a14f82
|
4
|
+
data.tar.gz: 56478f009591aa878db947e874d6a152af935fb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48acbefdf4d184c3ba3b80a69e4cd8faf4779c42eb17b125bb2ca0319d34223987e207730ca8ec11e3b1ae264208a057ab25b6b1fb5b0c3d75381cdb00efc7f1
|
7
|
+
data.tar.gz: c4d6a0b067e935163a8f9afd4fc52b95e691b7368393f85dfde201396e0f5776c44b94f7e61979ea1b65e5a0f0e3ab751151f36b57445be4e7badd9127ddfee0
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
|
@@ -3,30 +3,18 @@
|
|
3
3
|
# file: humble_rpi-plugin-magneticswitch.rb
|
4
4
|
|
5
5
|
|
6
|
-
require '
|
6
|
+
require 'rpi_pinin'
|
7
7
|
|
8
8
|
|
9
9
|
class HumbleRPiPluginMagneticSwitch
|
10
|
-
|
10
|
+
|
11
11
|
|
12
12
|
def initialize(settings: {}, variables: {})
|
13
13
|
|
14
14
|
@nc = settings[:nc] || true
|
15
|
-
@pins = settings[:pins]
|
15
|
+
@pins = settings[:pins].map {|x| RPiPinIn.new x}
|
16
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
|
-
|
17
|
+
@device_id = variables[:device_id] || 'pi'
|
30
18
|
|
31
19
|
end
|
32
20
|
|
@@ -38,33 +26,30 @@ class HumbleRPiPluginMagneticSwitch
|
|
38
26
|
|
39
27
|
puts 'ready to detect magnetic switches'
|
40
28
|
|
41
|
-
@pins.each.with_index do |
|
29
|
+
@pins.each.with_index do |pin, i|
|
42
30
|
|
43
|
-
puts 'magnetic switch sensor %s on GPIO %s enabled ' % [i+1,
|
31
|
+
puts 'magnetic switch sensor %s on GPIO %s enabled ' % [i+1, pin.to_s]
|
44
32
|
|
45
33
|
n = (i+1).to_s
|
46
34
|
|
47
|
-
|
35
|
+
Thread.new do
|
48
36
|
|
49
|
-
|
50
|
-
|
51
|
-
:open
|
52
|
-
|
53
|
-
:
|
37
|
+
pin.watch do |value|
|
38
|
+
|
39
|
+
state = value == 0 ? :open : :closed
|
40
|
+
|
41
|
+
notifier.notice "%s/magneticswitch/%s: door %s" % \
|
42
|
+
[device_id, i, state]
|
43
|
+
|
54
44
|
end
|
55
45
|
|
56
|
-
notifier.notice "%s/magneticswitch/%s: door %s" % [device_id, i, state]
|
57
|
-
|
58
46
|
end
|
59
47
|
|
60
48
|
end
|
61
49
|
|
62
|
-
PiPiper.wait
|
63
|
-
|
64
|
-
|
65
50
|
end
|
66
51
|
|
67
52
|
alias on_start start
|
68
53
|
|
69
54
|
|
70
|
-
end
|
55
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: humble_rpi-plugin-magneticswitch
|
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
|
bPWFwNbEi9CiEPveT/uvh62PLy8oXqUUvXHHxIjvpQICBlT6wc8vkY+Lz86rQ+xY
|
32
32
|
nKxNwaysAN6TFg==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2016-
|
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.1
|
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.1
|
56
56
|
description:
|
57
57
|
email: james@r0bertson.co.uk
|
58
58
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|