humble_rpi-plugin-relay 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 +0 -0
- data/lib/humble_rpi-plugin-relay.rb +50 -0
- metadata +88 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4521cd7141d11ca378b15527a0a4b337e356bddf
|
4
|
+
data.tar.gz: 47a4b477739278842bf4ee1ea4f2a23c84f2618b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d5808fb71bd8849c9bc967ea9de9e763e6661d02274d4b9e2b8fc76ac7264c19a6ea47f67724a90bb6666c5ccf955913adfc597db6bdaf0406ee169a85fc716b
|
7
|
+
data.tar.gz: d688b8db40e473eeabfa97c866aff43eff491fb392404ac67e680b322d2f4ea700da8e71807814a5bd892a02fd807f97a391a5f411bbf08662516d06fa208ef1
|
checksums.yaml.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
B�U�K�>ݯF]�IB�������m�Y���@�[�TH�<�p��J�x��S�?��?v�8f�֓d��U+�c[�
|
data.tar.gz.sig
ADDED
Binary file
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: humble_rpi-plugin-relay.rb
|
4
|
+
|
5
|
+
require 'rpi'
|
6
|
+
|
7
|
+
|
8
|
+
class HumbleRPiPluginRelay
|
9
|
+
|
10
|
+
def initialize(settings: {}, variables: {})
|
11
|
+
|
12
|
+
@gpio_pins = settings[:pins]
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
def on_relay_message(message)
|
17
|
+
|
18
|
+
r = message.match(/(\d+)\s*(on|off)\s*([\d\.]+)?/)
|
19
|
+
|
20
|
+
if r then
|
21
|
+
index, state, seconds, raw_duration = r.captures
|
22
|
+
duration = raw_duration ? raw_duration.to_f : nil
|
23
|
+
|
24
|
+
a = case state
|
25
|
+
|
26
|
+
when 'on'
|
27
|
+
[:on, duration]
|
28
|
+
|
29
|
+
when 'off'
|
30
|
+
[:off]
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
@relay[index.to_i].send(*a)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def start()
|
39
|
+
|
40
|
+
@relay = RPi.new(@gpio_pins).pins if @gpio_pins.any?
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
alias on_start start
|
45
|
+
|
46
|
+
def on_exit()
|
47
|
+
@relay.on_exit
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: humble_rpi-plugin-relay
|
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
|
+
8ixkARkWAmV1MB4XDTE1MDkyNjE5MjEyOFoXDTE2MDkyNTE5MjEyOFowSDESMBAG
|
16
|
+
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
|
17
|
+
EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
|
18
|
+
ggEBAMMnsETZoHsOCfM3cA/Oq2MZyNg/p4Dy7UuGNGvPP8kExCcyiW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+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rpi
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0.4'
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.4.0
|
46
|
+
type: :runtime
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0.4'
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.4.0
|
56
|
+
description:
|
57
|
+
email: james@r0bertson.co.uk
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/humble_rpi-plugin-relay.rb
|
63
|
+
homepage: https://github.com/jrobertson/humble_rpi-plugin-relay
|
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: Control 1 or more relays with the Raspberry Pi using the Humble_rpi gem +
|
87
|
+
humble_rpi-plugin-relay gem.
|
88
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|