garden_messenger 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/lib/garden_messenger/cli.rb +20 -2
- data/lib/garden_messenger/reporter.rb +2 -1
- data/lib/garden_messenger/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c62f2e95f39628a4b0b1d82302e02cdd2ee8fa8c6e1d526499ac57ded6b078d
|
4
|
+
data.tar.gz: 3ceb8b89feafa04ffb436d0431b1b945b39861e719c2c05351875b91010e3f50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2cdf5b607b90830c0d273792a2c44fd5b93bf3bdfe8ac18a3c7f677e374eedaac10b980f315d2a1881e451eeb43de8d7fa46f1ea734da7b9f1a224547b01c61
|
7
|
+
data.tar.gz: e0ce5bb9f48bf987897c26e2915ca833187f47ccfb94ae304e87be58a61771c4edb3864bfabd2e67b810c19a0d6543c6ffffd1bb1c4e25fe3ed916b1d66d6b29
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -6,6 +6,7 @@ Collects data of [AtlasScientific](https://www.atlas-scientific.com/) and [myStr
|
|
6
6
|
|
7
7
|
Currently supported:
|
8
8
|
|
9
|
+
- [x] [DHT22 temperature and humidity sensor](https://www.adafruit.com/product/385)
|
9
10
|
- [x] [pH Kit](https://www.atlas-scientific.com/product_pages/kits/ph-kit.html)
|
10
11
|
- [x] [Conductivity Kit](https://www.atlas-scientific.com/product_pages/kits/ec_k1_0_kit.html)
|
11
12
|
- [x] [Temperature Kit](https://www.atlas-scientific.com/product_pages/kits/temp_kit.html)
|
data/lib/garden_messenger/cli.rb
CHANGED
@@ -2,6 +2,13 @@ require 'thor'
|
|
2
2
|
|
3
3
|
module GardenMessenger
|
4
4
|
class CLI < Thor
|
5
|
+
map %w[--version -v] => :__print_version
|
6
|
+
|
7
|
+
desc '--version, -v', 'print the version'
|
8
|
+
def __print_version
|
9
|
+
puts GardenMessenger::VERSION
|
10
|
+
end
|
11
|
+
|
5
12
|
desc 'report MONITOR_URL TOKEN [options]', 'Report to a monitor which is located on MONITOR_URL'
|
6
13
|
option 'wattage-switch-host'
|
7
14
|
option 'update-rate'
|
@@ -19,15 +26,26 @@ module GardenMessenger
|
|
19
26
|
ec = GardenMessenger::AtlasScientific::EC.new
|
20
27
|
wattage = GardenMessenger::Wattage.new(options['wattage-switch-host'])
|
21
28
|
|
29
|
+
begin
|
30
|
+
require 'dht-sensor-ffi'
|
31
|
+
rescue LoadError
|
32
|
+
warn 'Failed to load dht-sensor-ffi, air temperature and humidity are disabled. ' \
|
33
|
+
'To enable it, install dht-sensor-ffi: https://github.com/chetan/dht-sensor-ffi'
|
34
|
+
end
|
35
|
+
|
22
36
|
reporter.report! do
|
23
|
-
data = {
|
37
|
+
data = {}
|
24
38
|
|
25
|
-
data[:wattage] = wattage.get if options.key?('wattage-switch-host')
|
26
39
|
data[:water_temp] = water_temperature.take_reading
|
40
|
+
wattage_thread = Thread.new { wattage.get }
|
27
41
|
ph_thread = Thread.new { ph.take_reading_with_temperature_compensation(data[:water_temp]) }
|
28
42
|
ec_thread = Thread.new { ec.take_reading_with_temperature_compensation(data[:water_temp]) }
|
43
|
+
dht_thread = Thread.new { DhtSensor.read(4, 22) } if defined?(DhtSensor)
|
44
|
+
data[:wattage] = wattage_thread.value
|
29
45
|
data[:ph] = ph_thread.value
|
30
46
|
data[:ec] = ec_thread.value
|
47
|
+
data[:air_temp] = dht_thread.value.temperature if defined?(DhtSensor)
|
48
|
+
data[:humidity] = dht_thread.value.humidity if defined?(DhtSensor)
|
31
49
|
|
32
50
|
data
|
33
51
|
end
|
@@ -35,7 +35,7 @@ module GardenMessenger
|
|
35
35
|
puts 'Connection established with monitor ' \
|
36
36
|
"on #{@monitor_url}"
|
37
37
|
end
|
38
|
-
Thread.new do
|
38
|
+
thread = Thread.new do
|
39
39
|
loop do
|
40
40
|
data = yield
|
41
41
|
puts "Sending data: #{data.to_json}" if @verbose
|
@@ -44,6 +44,7 @@ module GardenMessenger
|
|
44
44
|
sleep @update_rate
|
45
45
|
end
|
46
46
|
end
|
47
|
+
thread.abort_on_exception = true
|
47
48
|
end
|
48
49
|
|
49
50
|
client.disconnected do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: garden_messenger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yves Siegrist
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: action_cable_client
|