mywx_pusher 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/exe/mywx_pusher +38 -7
- data/lib/mywx_pusher/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: 8eeb914b9d3c08b8400056b7faedaf21b1b26aecd27f2de46150e91a86bdcca4
|
4
|
+
data.tar.gz: 98e35107640ccc0016e51ccb984e5987101c7fb7d8f2681ce83aa7a236c8e261
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65218968070e650cb6d21620246c0b25c451cc5a799c265e5269256fd7b64f7e71a7bafe62a59ea8469fecc99320ec3be455c980d92bdce0c0fe5ce8d6e2a848
|
7
|
+
data.tar.gz: aca04123e6a7a30429a8fb9ccf618e8684673d7d4f51f3d40476ce93ea1bc0d664bb2c20a177c47efbbd691ef3e09fb8d3a6dba5d26fde9bb79458b0b3cc42ec
|
data/Gemfile.lock
CHANGED
data/exe/mywx_pusher
CHANGED
@@ -40,6 +40,7 @@ class MywxPusherCommand
|
|
40
40
|
opts.on('-d', '--debug', 'Enable debug mode') { logger.level = Logger::DEBUG }
|
41
41
|
|
42
42
|
opts.on('-w', '--weatherlink-host=HOST', '') { |o| options.weatherlink_host = o }
|
43
|
+
opts.on('-a', '--airlink-host=HOST', '') { |o| options.airlink_host = o }
|
43
44
|
|
44
45
|
opts.on('-b', '--mywx-base-uri=URI', '') { |o| options.mywx_base_uri = o }
|
45
46
|
opts.on('-s', '--mywx-station-slug=SLUG', '') { |o| options.mywx_station_slug = o }
|
@@ -69,18 +70,26 @@ class MywxPusherCommand
|
|
69
70
|
end
|
70
71
|
|
71
72
|
def collect_data
|
72
|
-
logger.debug("Collecting data from #{options.weatherlink_host}...")
|
73
73
|
|
74
74
|
ts = Time.now.to_i
|
75
75
|
|
76
76
|
begin
|
77
|
-
|
77
|
+
logger.debug("Collecting data from #{options.weatherlink_host}...")
|
78
|
+
weatherlink_current_conditions = weatherlink_client.current_conditions
|
78
79
|
rescue StandardError => e
|
79
80
|
raise CollectError, e
|
80
81
|
end
|
81
82
|
|
82
|
-
|
83
|
-
|
83
|
+
begin
|
84
|
+
logger.debug("Collecting data from #{options.airlink_host}...")
|
85
|
+
airlink_current_conditions = airlink_client&.current_conditions
|
86
|
+
rescue StandardError => e
|
87
|
+
raise CollectError, e
|
88
|
+
end
|
89
|
+
|
90
|
+
iss_record = weatherlink_current_conditions.find { |sd| sd.record_type.id == 1 }
|
91
|
+
lss_pressure_record = weatherlink_current_conditions.find { |sd| sd.record_type.id == 3 }
|
92
|
+
airlink_record = airlink_current_conditions&.find { |sd| sd.record_type.id == 6 }
|
84
93
|
|
85
94
|
data = {
|
86
95
|
ts: ts,
|
@@ -94,6 +103,18 @@ class MywxPusherCommand
|
|
94
103
|
solar_radiation: iss_record.solar_rad.scalar.to_f.round(2),
|
95
104
|
}
|
96
105
|
|
106
|
+
if airlink_record
|
107
|
+
air_quality_data = {
|
108
|
+
air_quality: {
|
109
|
+
pm_1: airlink_record.pm_1,
|
110
|
+
pm_2p5: airlink_record.pm_2p5,
|
111
|
+
pm_10: airlink_record.pm_10,
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
data.merge!(air_quality_data)
|
116
|
+
end
|
117
|
+
|
97
118
|
logger.debug("Collected data (#{data.size} variables): #{data}")
|
98
119
|
|
99
120
|
data
|
@@ -111,18 +132,28 @@ class MywxPusherCommand
|
|
111
132
|
true
|
112
133
|
end
|
113
134
|
|
114
|
-
def
|
115
|
-
@
|
135
|
+
def weatherlink_client
|
136
|
+
@weatherlink_client ||= WeatherLink::LocalClient.new(
|
116
137
|
host: options.weatherlink_host,
|
117
138
|
desired_units: WeatherLink::METRIC_WEATHER_UNITS
|
118
139
|
)
|
119
140
|
end
|
120
141
|
|
142
|
+
def airlink_client
|
143
|
+
return unless options.airlink_host
|
144
|
+
|
145
|
+
@airlink_client ||= WeatherLink::LocalClient.new(
|
146
|
+
host: options.airlink_host,
|
147
|
+
desired_units: WeatherLink::METRIC_WEATHER_UNITS
|
148
|
+
)
|
149
|
+
end
|
150
|
+
|
121
151
|
def run
|
122
152
|
logger.info(
|
123
153
|
format(
|
124
|
-
'Collecting from %s, pushing to %s every %i seconds...',
|
154
|
+
'Collecting weather data from %s%s, pushing to %s every %i seconds...',
|
125
155
|
options.weatherlink_host,
|
156
|
+
options.airlink_host ? " and air quality data from #{options.airlink_host}" : '',
|
126
157
|
mywx_push_data_uri,
|
127
158
|
options.interval
|
128
159
|
)
|
data/lib/mywx_pusher/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mywx_pusher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Cole
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01
|
11
|
+
date: 2021-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|