humble_rpi-plugin-magneticswitch 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/humble_rpi-plugin-magneticswitch.rb +13 -4
- metadata +4 -4
- 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: 39803a831996ad98dfb92a77dc83ade5a507a794
|
4
|
+
data.tar.gz: 449d5f6f18364666c9aeb6c60a5dd6fc20ab986e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f742502cf5a026513f28e0fbc70a3f7b330b683ffb4d76fd3b70dbf2ccabb7b85a5d1cac3f3bd6e8de02526a2b429b8be9cf5d30765e958c4bd30b7e8528fc7c
|
7
|
+
data.tar.gz: a3a2d5c677cfa7872ee421ae984ea361a14ac1a70b28866183c59fab98a0b2fc5f3756d6466ef61ff778c38edcd74d4d33472649c03c951c5cdaa0f618afdc96
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
@@ -7,6 +7,11 @@ require 'rpi_pinin'
|
|
7
7
|
require 'self-defense'
|
8
8
|
|
9
9
|
|
10
|
+
Thread.abort_on_exception=true
|
11
|
+
|
12
|
+
class PluginMagneticSwitchException < Exception
|
13
|
+
end
|
14
|
+
|
10
15
|
class HumbleRPiPluginMagneticSwitch
|
11
16
|
|
12
17
|
|
@@ -16,6 +21,7 @@ class HumbleRPiPluginMagneticSwitch
|
|
16
21
|
@pins = settings[:pins].map {|x| RPiPinIn.new x, pull: :up}
|
17
22
|
@notifier = variables[:notifier]
|
18
23
|
@device_id = variables[:device_id] || 'pi'
|
24
|
+
|
19
25
|
|
20
26
|
end
|
21
27
|
|
@@ -26,6 +32,7 @@ class HumbleRPiPluginMagneticSwitch
|
|
26
32
|
nc = @nc
|
27
33
|
|
28
34
|
puts 'ready to detect magnetic switches'
|
35
|
+
|
29
36
|
|
30
37
|
@pins.each.with_index do |pin, i|
|
31
38
|
|
@@ -33,8 +40,9 @@ class HumbleRPiPluginMagneticSwitch
|
|
33
40
|
|
34
41
|
n = (i+1).to_s
|
35
42
|
|
36
|
-
|
37
|
-
|
43
|
+
threads = []
|
44
|
+
threads << Thread.new do
|
45
|
+
|
38
46
|
pin.watch do |value|
|
39
47
|
|
40
48
|
state = value == 0 ? :opened : :closed
|
@@ -55,10 +63,10 @@ class HumbleRPiPluginMagneticSwitch
|
|
55
63
|
SelfDefense.new(&strategy) if state == :opened
|
56
64
|
|
57
65
|
if input_operation == :erratic then
|
58
|
-
|
66
|
+
|
59
67
|
notifier.notice "%s/magneticswitch/%s: " + \
|
60
68
|
" door error: Erratic input operation" % [device_id, i]
|
61
|
-
raise '
|
69
|
+
raise PluginMagneticSwitchException, 'Erratic input operation'
|
62
70
|
end
|
63
71
|
|
64
72
|
notifier.notice "%s/magneticswitch/%s: door %s" % \
|
@@ -67,6 +75,7 @@ class HumbleRPiPluginMagneticSwitch
|
|
67
75
|
end
|
68
76
|
|
69
77
|
end
|
78
|
+
threads.each(&:join)
|
70
79
|
|
71
80
|
end
|
72
81
|
|
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.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
bPWFwNbEi9CiEPveT/uvh62PLy8oXqUUvXHHxIjvpQICBlT6wc8vkY+Lz86rQ+xY
|
32
32
|
nKxNwaysAN6TFg==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2016-
|
34
|
+
date: 2016-12-15 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rpi_pinin
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
version: '0.1'
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.1.
|
45
|
+
version: 0.1.2
|
46
46
|
type: :runtime
|
47
47
|
prerelease: false
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
version: '0.1'
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.1.
|
55
|
+
version: 0.1.2
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: self-defense
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
Binary file
|