humble_rpi-plugin-dhtsensor 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 004540a96dd99d1f6b6205c1c522e61e9c09a499
4
+ data.tar.gz: 0000ef795a80d662c1ced88d9aa5e345354708e4
5
+ SHA512:
6
+ metadata.gz: c026fbb1cff1ecb8bdd506c74731e9691c61462df9ec71996a8965263436584a0e1a4ae5f048a6409723209644afe6de26c7a158b67bee18c7db72352f3c4b0c
7
+ data.tar.gz: 02e7ecb98a68837d13d5873012fecf82a8abf66806ede803e152384c70442aa90f00019361753dadb5413e955b1d11eecb11ef4dc747b08920123c19bb892d72
checksums.yaml.gz.sig ADDED
Binary file
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: humble_rpi-plugin-dhtsensor.rb
4
+
5
+
6
+ require 'dht-sensor-ffi'
7
+
8
+
9
+ class HumbleRPiPluginDhtSensor
10
+
11
+
12
+ def initialize(settings: {}, variables: {})
13
+
14
+ @pin = settings[:pin]
15
+
16
+ if @pin.nil? then
17
+ raise 'HumbleRPiPluginDhtSensor: settings error: please supply a pin'
18
+ end
19
+
20
+ h = {
21
+ version: 11,
22
+ temperature_threshold: 1,
23
+ humidity_threshold: 2,
24
+ interval: 3,
25
+ msg_format: "%s/dht11_sensor: temperature: %s humidity: %s"
26
+ }.merge settings
27
+
28
+ @version = h[:version]
29
+ @temperature_threshold = h[:temperature_threshold]
30
+ @humidity_threshold = h[:humidity_threshold]
31
+ @interval = h[:interval]
32
+ @msg_format = h[:msg_format]
33
+
34
+ @notifier = variables[:notifier]
35
+ @device_id = variables[:device_id] || 'pi'
36
+
37
+ end
38
+
39
+ def start()
40
+
41
+ puts 'ready to monitor temperature and humidity'
42
+
43
+ val = DhtSensor.read(@pin, @version)
44
+ push val
45
+
46
+ loop do
47
+
48
+ val = DhtSensor.read(@pin, @version)
49
+
50
+ if (@old_tval - val.temperature).abs >= @temperature_threshold or \
51
+ (@old_hval - val.humidity).abs >= @humidity_threshold then
52
+ push val
53
+ end
54
+
55
+ sleep @interval
56
+
57
+ end
58
+
59
+ end
60
+
61
+ alias on_start start
62
+
63
+ private
64
+
65
+ def push(val)
66
+
67
+ @notifier.notice @msg_format % [@device_id, val.temperature, val.humidity]
68
+ @old_tval = val.temperature
69
+ @old_hval = val.humidity
70
+
71
+ end
72
+
73
+ end
data.tar.gz.sig ADDED
@@ -0,0 +1 @@
1
+ Zqx'ߌ+�dy}��q9N"t�{�قQ� ��i]��I3��Dz������ʁJ�3���W��L��n��TG��@CV�������?5GiJ�|�jȫ4�C�JʒJ�ͱ��F�!���ˍ�X��K8�t<�5Vư���� ���?t���?���3��N�0kJ�Y/�E2���ڱ�i6���`������#L+���T��!�~;G"Ӯ'ңH�6'�O���"���q����n�6�?�X���
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: humble_rpi-plugin-dhtsensor
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
+ 8ixkARkWAmV1MB4XDTE2MDIyMDEzMjA1MVoXDTE3MDIxOTEzMjA1MVowSDESMBAG
16
+ A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
+ EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
+ ggEBAKOboV2V5PZQV+/26kC2/ceT4M5KybTj461kHYitICaiTx0QPZkYU5Gqj5n2
19
+ dgfaT7tdi0Jb+3a+L/gGxd8DE91C7+9JPkR54B+qQlipiY+jDSIgg85guSwNr4aU
20
+ Oc/RU1aAM2wuNcgyh2PwnAQq57I11f5N5KeoIXLjWFHtL5xkXEQ7l+enqWEsxEW8
21
+ evOoeWhPD+QLn2ZfnwJctHLS6Z+p51gq1CAtaJyN8Scjf7TM+ZJQPJCwq6SZFtb5
22
+ wA2UR8t2UoJV/ul9pTMnFRWHx9JARWPokEdnkzcrL/1pSbvVdPmBuL+DzN7Ei/mp
23
+ CLKyw+GpZc0IfPxSWIU2viGPPGcCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
+ DwQEAwIEsDAdBgNVHQ4EFgQU8p1HlVs9TGEXI1fHsoCi5vmVSa8wJgYDVR0RBB8w
25
+ HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
26
+ c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAlwt4E9wE
27
+ WT4hmqXdPG1N+si0KWoBlE467ZV0RPLcWMLsqvXi7siu/o3H++3EWXLYgokJHO7a
28
+ d1s/VJAB3YwrOt3Szq11zH/BHfgxSSEhr6dMRrqcjfULPtTiuuDVNxmohS7Z/abk
29
+ vWThkLnzHSmnYBzM4zt7vAab4sY2KL430d/CBYNGX+nsK56Qk5qHJ5J5D94MoLxN
30
+ OpYGsTd7K7AHWKxjCsVo3FhqUutjyH6Yu1sfFqPiSHW3KQhmv7WmmUurTR6GGSap
31
+ 1yv1zPKYGoahrCXWtSWVIetnZLs8B3G+KzjKglCxVrcmqQEw+04aEq3GmzMYmB3A
32
+ dZoV0AypAhDyaQ==
33
+ -----END CERTIFICATE-----
34
+ date: 2016-02-20 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: dht-sensor-ffi
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '0.1'
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.1.4
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '0.1'
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 0.1.4
56
+ description:
57
+ email: james@r0bertson.co.uk
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - lib/humble_rpi-plugin-dhtsensor.rb
63
+ homepage: https://github.com/jrobertson/humble_rpi-plugin-dhtsensor
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 to read the ambient temperature and humidity from the
87
+ DHT sensor.
88
+ test_files: []
metadata.gz.sig ADDED
Binary file