mywx_pusher 0.1.4 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8eeb914b9d3c08b8400056b7faedaf21b1b26aecd27f2de46150e91a86bdcca4
4
- data.tar.gz: 98e35107640ccc0016e51ccb984e5987101c7fb7d8f2681ce83aa7a236c8e261
3
+ metadata.gz: 12a04f6c8fbb2b86a66e68602ade29f5aa63e054d2d3fdea004d946811944840
4
+ data.tar.gz: f93f0c42a33af06f48b1fddc7b8ebaab719d9fd253088e868e3afdf31560f890
5
5
  SHA512:
6
- metadata.gz: 65218968070e650cb6d21620246c0b25c451cc5a799c265e5269256fd7b64f7e71a7bafe62a59ea8469fecc99320ec3be455c980d92bdce0c0fe5ce8d6e2a848
7
- data.tar.gz: aca04123e6a7a30429a8fb9ccf618e8684673d7d4f51f3d40476ce93ea1bc0d664bb2c20a177c47efbbd691ef3e09fb8d3a6dba5d26fde9bb79458b0b3cc42ec
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)
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.1)
10
+ ast (2.4.2)
11
11
  diff-lcs (1.4.4)
12
12
  parallel (1.20.1)
13
- parser (3.0.0.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.0.3)
18
- rexml (3.2.4)
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.8.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.2.0, < 2.0)
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.4.0)
42
- parser (>= 2.7.1.5)
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.airlink_host = o }
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
- airlink_record = airlink_current_conditions&.find { |sd| sd.record_type.id == 6 }
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 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,
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
- data.merge!(air_quality_data)
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 options.airlink_host
196
+ def airlink_client(airlink_host)
197
+ return unless airlink_host
144
198
 
145
- @airlink_client ||= WeatherLink::LocalClient.new(
146
- host: options.airlink_host,
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.airlink_host ? " and air quality data from #{options.airlink_host}" : '',
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
  )
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MywxPusher
4
- VERSION = '0.1.4'
4
+ VERSION = '0.1.5'
5
5
  end
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
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-03-01 00:00:00.000000000 Z
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"