mywx_pusher 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +16 -0
- data/Gemfile.lock +9 -9
- data/exe/mywx_pusher +80 -24
- data/lib/mywx_pusher/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12a04f6c8fbb2b86a66e68602ade29f5aa63e054d2d3fdea004d946811944840
|
4
|
+
data.tar.gz: f93f0c42a33af06f48b1fddc7b8ebaab719d9fd253088e868e3afdf31560f890
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2861380550dd188094ecbe2fa89834a95b64a65ebff946b4e6ab9e25aa426d90cdbdcd86978756cf869880bb4865975258025f3e9d84bd773d3cabc0bec4829c
|
7
|
+
data.tar.gz: 51d452df842fa984376ad60d473f21585d24131a0356a5e292c2c705c18414e9612b30ba9990cfd49c83a4c4c8ff07a1c53eed8a348fc0c9af270ae319e2d9fe
|
@@ -0,0 +1,16 @@
|
|
1
|
+
version: 2
|
2
|
+
updates:
|
3
|
+
- package-ecosystem: bundler
|
4
|
+
directory: "/"
|
5
|
+
schedule:
|
6
|
+
interval: daily
|
7
|
+
time: "13:00"
|
8
|
+
open-pull-requests-limit: 10
|
9
|
+
ignore:
|
10
|
+
- dependency-name: rubocop
|
11
|
+
versions:
|
12
|
+
- 1.10.0
|
13
|
+
- 1.12.0
|
14
|
+
- 1.12.1
|
15
|
+
- 1.9.0
|
16
|
+
- 1.9.1
|
data/Gemfile.lock
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mywx_pusher (0.1.
|
4
|
+
mywx_pusher (0.1.5)
|
5
5
|
weatherlink (~> 0.1.2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
ast (2.4.
|
10
|
+
ast (2.4.2)
|
11
11
|
diff-lcs (1.4.4)
|
12
12
|
parallel (1.20.1)
|
13
|
-
parser (3.0.
|
13
|
+
parser (3.0.1.1)
|
14
14
|
ast (~> 2.4.1)
|
15
15
|
rainbow (3.0.0)
|
16
16
|
rake (13.0.3)
|
17
|
-
regexp_parser (2.
|
18
|
-
rexml (3.2.
|
17
|
+
regexp_parser (2.1.1)
|
18
|
+
rexml (3.2.5)
|
19
19
|
rspec (3.10.0)
|
20
20
|
rspec-core (~> 3.10.0)
|
21
21
|
rspec-expectations (~> 3.10.0)
|
@@ -29,17 +29,17 @@ GEM
|
|
29
29
|
diff-lcs (>= 1.2.0, < 2.0)
|
30
30
|
rspec-support (~> 3.10.0)
|
31
31
|
rspec-support (3.10.0)
|
32
|
-
rubocop (1.
|
32
|
+
rubocop (1.16.0)
|
33
33
|
parallel (~> 1.10)
|
34
34
|
parser (>= 3.0.0.0)
|
35
35
|
rainbow (>= 2.2.2, < 4.0)
|
36
36
|
regexp_parser (>= 1.8, < 3.0)
|
37
37
|
rexml
|
38
|
-
rubocop-ast (>= 1.
|
38
|
+
rubocop-ast (>= 1.7.0, < 2.0)
|
39
39
|
ruby-progressbar (~> 1.7)
|
40
40
|
unicode-display_width (>= 1.4.0, < 3.0)
|
41
|
-
rubocop-ast (1.
|
42
|
-
parser (>=
|
41
|
+
rubocop-ast (1.7.0)
|
42
|
+
parser (>= 3.0.1.1)
|
43
43
|
ruby-progressbar (1.11.0)
|
44
44
|
ruby-units (2.3.2)
|
45
45
|
unicode-display_width (2.0.0)
|
data/exe/mywx_pusher
CHANGED
@@ -19,6 +19,7 @@ class MywxPusherCommand
|
|
19
19
|
|
20
20
|
def initialize_options
|
21
21
|
@options = OpenStruct.new(
|
22
|
+
debug: false,
|
22
23
|
mywx_base_uri: 'https://www.mywx.live/',
|
23
24
|
mywx_station_slug: nil,
|
24
25
|
mywx_secret_key: nil,
|
@@ -37,10 +38,11 @@ class MywxPusherCommand
|
|
37
38
|
exit 0
|
38
39
|
end
|
39
40
|
|
40
|
-
opts.on('-d', '--debug', 'Enable debug mode') { logger.level = Logger::DEBUG }
|
41
|
+
opts.on('-d', '--debug', 'Enable debug mode') { options.debug = true; logger.level = Logger::DEBUG }
|
41
42
|
|
42
43
|
opts.on('-w', '--weatherlink-host=HOST', '') { |o| options.weatherlink_host = o }
|
43
|
-
opts.on('-a', '--airlink-host=HOST', '') { |o| options.
|
44
|
+
opts.on('-a', '--outdoor-airlink-host=HOST', '') { |o| options.outdoor_airlink_host = o }
|
45
|
+
opts.on('-A', '--indoor-airlink-host=HOST', '') { |o| options.indoor_airlink_host = o }
|
44
46
|
|
45
47
|
opts.on('-b', '--mywx-base-uri=URI', '') { |o| options.mywx_base_uri = o }
|
46
48
|
opts.on('-s', '--mywx-station-slug=SLUG', '') { |o| options.mywx_station_slug = o }
|
@@ -80,16 +82,41 @@ class MywxPusherCommand
|
|
80
82
|
raise CollectError, e
|
81
83
|
end
|
82
84
|
|
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
85
|
iss_record = weatherlink_current_conditions.find { |sd| sd.record_type.id == 1 }
|
91
86
|
lss_pressure_record = weatherlink_current_conditions.find { |sd| sd.record_type.id == 3 }
|
92
|
-
|
87
|
+
|
88
|
+
outdoor_airlink_current_conditions = nil
|
89
|
+
if options.outdoor_airlink_host
|
90
|
+
begin
|
91
|
+
logger.debug("Collecting data from #{options.outdoor_airlink_host}...")
|
92
|
+
outdoor_airlink_current_conditions = airlink_client(options.outdoor_airlink_host)&.current_conditions
|
93
|
+
rescue StandardError => e
|
94
|
+
raise CollectError, e
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
outdoor_airlink_record = outdoor_airlink_current_conditions&.find { |sd| sd.record_type.id == 6 }
|
99
|
+
|
100
|
+
indoor_airlink_current_conditions = nil
|
101
|
+
if options.outdoor_airlink_host
|
102
|
+
begin
|
103
|
+
logger.debug("Collecting data from #{options.indoor_airlink_host}...")
|
104
|
+
indoor_airlink_current_conditions = airlink_client(options.indoor_airlink_host)&.current_conditions
|
105
|
+
rescue StandardError => e
|
106
|
+
raise CollectError, e
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
indoor_airlink_record = indoor_airlink_current_conditions&.find { |sd| sd.record_type.id == 6 }
|
111
|
+
|
112
|
+
if options.debug
|
113
|
+
pp({
|
114
|
+
iss_record: iss_record,
|
115
|
+
lss_pressure_record: lss_pressure_record,
|
116
|
+
outdoor_airlink_record: outdoor_airlink_record,
|
117
|
+
indoor_airlink_record: indoor_airlink_record,
|
118
|
+
})
|
119
|
+
end
|
93
120
|
|
94
121
|
data = {
|
95
122
|
ts: ts,
|
@@ -97,22 +124,49 @@ class MywxPusherCommand
|
|
97
124
|
dew_point: iss_record.dew_point.scalar.to_f.round(2),
|
98
125
|
humidity: iss_record.hum.scalar.to_f.round(2),
|
99
126
|
pressure: lss_pressure_record.bar_sea_level.scalar.to_f.round(2),
|
127
|
+
pressure_absolute: lss_pressure_record.bar_absolute.scalar.to_f.round(2),
|
128
|
+
pressure_trend: lss_pressure_record.bar_trend.scalar.to_f.round(2),
|
100
129
|
wind_speed: iss_record.wind_speed_avg_last_1_min.scalar.to_f.round(2),
|
101
130
|
wind_direction: iss_record.wind_dir_scalar_avg_last_1_min.scalar.to_i,
|
131
|
+
wind_speed_10_minutes_max: iss_record.wind_speed_hi_last_10_min.scalar.to_f.round(2),
|
132
|
+
wind_direction_10_minutes_max: iss_record.wind_dir_at_hi_speed_last_10_min.scalar.to_i,
|
102
133
|
rain_rate: iss_record.rain_rate_last.scalar.to_f.round(2),
|
103
134
|
solar_radiation: iss_record.solar_rad.scalar.to_f.round(2),
|
135
|
+
uv_index: iss_record.uv_index.round(2),
|
104
136
|
}
|
105
137
|
|
106
|
-
if
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
138
|
+
if outdoor_airlink_record
|
139
|
+
data.merge!(
|
140
|
+
{
|
141
|
+
air_quality: {
|
142
|
+
pm_1: outdoor_airlink_record.pm_1,
|
143
|
+
pm_2p5: outdoor_airlink_record.pm_2p5,
|
144
|
+
pm_2p5_last_1_hour: outdoor_airlink_record.pm_2p5_last_1_hour,
|
145
|
+
pm_2p5_last_24_hours: outdoor_airlink_record.pm_2p5_last_24_hours,
|
146
|
+
pm_10: outdoor_airlink_record.pm_10,
|
147
|
+
pm_10_last_1_hour: outdoor_airlink_record.pm_10_last_1_hour,
|
148
|
+
pm_10_last_24_hours: outdoor_airlink_record.pm_10_last_24_hours,
|
149
|
+
}
|
112
150
|
}
|
113
|
-
|
151
|
+
)
|
152
|
+
end
|
114
153
|
|
115
|
-
|
154
|
+
if indoor_airlink_record
|
155
|
+
data.merge!(
|
156
|
+
{
|
157
|
+
indoor_temperature: indoor_airlink_record.temp.scalar.to_f.round(2),
|
158
|
+
indoor_humidity: indoor_airlink_record.hum.scalar.to_f.round(2),
|
159
|
+
indoor_air_quality: {
|
160
|
+
pm_1: indoor_airlink_record.pm_1,
|
161
|
+
pm_2p5: indoor_airlink_record.pm_2p5,
|
162
|
+
pm_2p5_last_1_hour: indoor_airlink_record.pm_2p5_last_1_hour,
|
163
|
+
pm_2p5_last_24_hours: indoor_airlink_record.pm_2p5_last_24_hours,
|
164
|
+
pm_10: indoor_airlink_record.pm_10,
|
165
|
+
pm_10_last_1_hour: indoor_airlink_record.pm_10_last_1_hour,
|
166
|
+
pm_10_last_24_hours: indoor_airlink_record.pm_10_last_24_hours,
|
167
|
+
}
|
168
|
+
}
|
169
|
+
)
|
116
170
|
end
|
117
171
|
|
118
172
|
logger.debug("Collected data (#{data.size} variables): #{data}")
|
@@ -139,11 +193,12 @@ class MywxPusherCommand
|
|
139
193
|
)
|
140
194
|
end
|
141
195
|
|
142
|
-
def airlink_client
|
143
|
-
return unless
|
196
|
+
def airlink_client(airlink_host)
|
197
|
+
return unless airlink_host
|
144
198
|
|
145
|
-
@airlink_client ||=
|
146
|
-
|
199
|
+
@airlink_client ||= {}
|
200
|
+
@airlink_client[airlink_host] ||= WeatherLink::LocalClient.new(
|
201
|
+
host: airlink_host,
|
147
202
|
desired_units: WeatherLink::METRIC_WEATHER_UNITS
|
148
203
|
)
|
149
204
|
end
|
@@ -151,9 +206,10 @@ class MywxPusherCommand
|
|
151
206
|
def run
|
152
207
|
logger.info(
|
153
208
|
format(
|
154
|
-
'Collecting weather data from %s%s, pushing to %s every %i seconds...',
|
209
|
+
'Collecting weather data from %s%s%s, pushing to %s every %i seconds...',
|
155
210
|
options.weatherlink_host,
|
156
|
-
options.
|
211
|
+
options.outdoor_airlink_host ? ", outdoor air quality data from #{options.outdoor_airlink_host}" : '',
|
212
|
+
options.outdoor_airlink_host ? ", indoor air quality data from #{options.indoor_airlink_host}" : '',
|
157
213
|
mywx_push_data_uri,
|
158
214
|
options.interval
|
159
215
|
)
|
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.5
|
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-
|
11
|
+
date: 2021-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -75,6 +75,7 @@ executables:
|
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
|
+
- ".github/dependabot.yml"
|
78
79
|
- ".gitignore"
|
79
80
|
- ".rspec"
|
80
81
|
- ".rubocop.yml"
|