humble_rpi-plugin-magneticswitch 0.2.2 → 0.3.0
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/lib/humble_rpi-plugin-magneticswitch.rb +24 -1
- data.tar.gz.sig +0 -0
- metadata +22 -2
- 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: e3881e137d35f35f75eeedde484a7d66ba591148
|
4
|
+
data.tar.gz: 80615bfbc04dcb9c718965fb38d0d6275104beae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a5e75789d29796fd26314a6de8f95febde54e8269a34596ce2cd9683306db2fb0594ab664c8f346ba52cb35fd221fe8e5f3ad6c59fcdde96cdf2e42a44264f3
|
7
|
+
data.tar.gz: 946ca0e54dff90a247f9f73fd49c3e0758b1e87af54e48fe12956042ddc43215d06c397d3cbe4045d3c34b725b05c0fb02c9169ad47708ee10aaf9f79a27b1ed
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -4,6 +4,7 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
require 'rpi_pinin'
|
7
|
+
require 'self-defense'
|
7
8
|
|
8
9
|
|
9
10
|
class HumbleRPiPluginMagneticSwitch
|
@@ -38,8 +39,30 @@ class HumbleRPiPluginMagneticSwitch
|
|
38
39
|
|
39
40
|
state = value == 0 ? :opened : :closed
|
40
41
|
|
42
|
+
input_operation = :unknown
|
43
|
+
|
44
|
+
strategy = lambda do |defense|
|
45
|
+
|
46
|
+
coping_with_it = []
|
47
|
+
coping_with_it << defense.rapid?(0.5)
|
48
|
+
|
49
|
+
input_operation = coping_with_it.all? ? :normal : :erratic
|
50
|
+
end
|
51
|
+
|
52
|
+
# detect erratic input behaviour by checking if the door is
|
53
|
+
# opened within 0.5 of a second after it was last opened
|
54
|
+
|
55
|
+
SelfDefense.new(&strategy) if state == :opened
|
56
|
+
|
57
|
+
if input_operation == :erratic then
|
58
|
+
|
59
|
+
notifier.notice "%s/magneticswitch/%s: " + \
|
60
|
+
" door error: Erratic input operation" % [device_id, i]
|
61
|
+
raise 'humble_rpi-plugin-magneticwitch: Erratic input operation'
|
62
|
+
end
|
63
|
+
|
41
64
|
notifier.notice "%s/magneticswitch/%s: door %s" % \
|
42
|
-
|
65
|
+
[device_id, i, state]
|
43
66
|
|
44
67
|
end
|
45
68
|
|
data.tar.gz.sig
CHANGED
Binary file
|
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.3.0
|
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-11-
|
34
|
+
date: 2016-11-21 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rpi_pinin
|
@@ -53,6 +53,26 @@ dependencies:
|
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: 0.1.1
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: self-defense
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.1'
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 0.1.5
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - "~>"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0.1'
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.1.5
|
56
76
|
description:
|
57
77
|
email: james@r0bertson.co.uk
|
58
78
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|