-
Notifications
You must be signed in to change notification settings - Fork 8
/
install.py
executable file
·432 lines (409 loc) · 11.2 KB
/
install.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
"""
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
Installer for Ecowitt Gateway Driver
Version: 0.6.3 Date: 2 August 2024
Revision History
2 August 2024 v0.6.3
- added WH46 and WS85 battery and signal extractors config
23 February 2024 v0.6.2
- no change, version increment only
21 February 2024 v0.6.1
- no change, version increment only
7 February 2024 v0.6.0
- remove distutils.StrictVersion dependency
- added extractor config for heap_free
13 June 2022 v0.5.0
- changed descriptive name of extension
- changed reference to 'GW1000 driver' to 'Ecowitt gateway driver'
- redesignated WH35 as WN35
- added accumulator extractor entries for WN34 and WS90 battery and
signal state data
20 March 2022 v0.4.2
- no change, version increment only
14 October 2021 v0.4.1
- fix incorrect installer version number
27 September 2021 v0.4.0
- add wh24_batt and wh24_sig to extractors
28 March 2021 v0.3.1
- no change, version increment only
20 March 2021 v0.3.0
- added field lightningcount to the extractor definitions
- added extractors for WH35 sensor battery state and signal level
fields
9 January 2021 v0.2.0
- GW1000 config used by installer is now derived from a multiline
string so as to allow embedded comments in installed config stanzas
- added extractors for sensor signal level fields
- use multiline string for [GW1000] config to allow comments to be
included
- renamed various 24 hour average particulate concentration fields
1 September 2020 v0.1.0 (b1-b12)
- initial implementation
"""
# python imports
import configobj
from setup import ExtensionInstaller
# import StringIO, use six.moves due to python2/python3 differences
from six.moves import StringIO
# WeeWX imports
import weewx
REQUIRED_WEEWX_VERSION = "3.7.0"
GW1000_VERSION = "0.6.3"
# define our config as a multiline string so we can preserve comments
gw1000_config = """
[GW1000]
# This section is for the Ecowitt Gateway driver.
# How often to poll the API, default is every 20 seconds:
poll_interval = 20
# The driver to use:
driver = user.gw1000
[Accumulator]
# Start Ecowitt Gateway driver extractors
[[daymaxwind]]
extractor = last
[[lightning_distance]]
extractor = last
[[lightning_strike_count]]
extractor = sum
[[lightningcount]]
extractor = last
[[lightning_last_det_time]]
extractor = last
[[stormRain]]
extractor = last
[[hourRain]]
extractor = last
[[dayRain]]
extractor = last
[[weekRain]]
extractor = last
[[monthRain]]
extractor = last
[[yearRain]]
extractor = last
[[totalRain]]
extractor = last
[[p_rain]]
extractor = sum
[[p_stormRain]]
extractor = last
[[p_dayRain]]
extractor = last
[[p_weekRain]]
extractor = last
[[p_monthRain]]
extractor = last
[[p_yearRain]]
extractor = last
[[t_rain]]
extractor = sum
[[t_stormRain]]
extractor = last
[[t_dayRain]]
extractor = last
[[t_weekRain]]
extractor = last
[[_monthRain]]
extractor = last
[[t_yearRain]]
extractor = last
[[pm2_51_24h_avg]]
extractor = last
[[pm2_52_24h_avg]]
extractor = last
[[pm2_53_24h_avg]]
extractor = last
[[pm2_54_24h_avg]]
extractor = last
[[pm2_55_24h_avg]]
extractor = last
[[pm10_24h_avg]]
extractor = last
[[co2_24h_avg]]
extractor = last
[[heap_free]]
extractor = last
[[wh40_batt]]
extractor = last
[[wh26_batt]]
extractor = last
[[wh25_batt]]
extractor = last
[[wh24_batt]]
extractor = last
[[wh65_batt]]
extractor = last
[[wh31_ch1_batt]]
extractor = last
[[wh31_ch2_batt]]
extractor = last
[[wh31_ch3_batt]]
extractor = last
[[wh31_ch4_batt]]
extractor = last
[[wh31_ch5_batt]]
extractor = last
[[wh31_ch6_batt]]
extractor = last
[[wh31_ch7_batt]]
extractor = last
[[wh31_ch8_batt]]
extractor = last
[[wn34_ch1_batt]]
extractor = last
[[wn34_ch2_batt]]
extractor = last
[[wn34_ch3_batt]]
extractor = last
[[wn34_ch4_batt]]
extractor = last
[[wn34_ch5_batt]]
extractor = last
[[wn34_ch6_batt]]
extractor = last
[[wn34_ch7_batt]]
extractor = last
[[wn34_ch8_batt]]
extractor = last
[[wn35_ch1_batt]]
extractor = last
[[wn35_ch2_batt]]
extractor = last
[[wn35_ch3_batt]]
extractor = last
[[wn35_ch4_batt]]
extractor = last
[[wn35_ch5_batt]]
extractor = last
[[wn35_ch6_batt]]
extractor = last
[[wn35_ch7_batt]]
extractor = last
[[wn35_ch8_batt]]
extractor = last
[[wh41_ch1_batt]]
extractor = last
[[wh41_ch2_batt]]
extractor = last
[[wh41_ch3_batt]]
extractor = last
[[wh41_ch4_batt]]
extractor = last
[[wh45_batt]]
extractor = last
[[wh46_batt]]
extractor = last
[[wh51_ch1_batt]]
extractor = last
[[wh51_ch2_batt]]
extractor = last
[[wh51_ch3_batt]]
extractor = last
[[wh51_ch4_batt]]
extractor = last
[[wh51_ch5_batt]]
extractor = last
[[wh51_ch6_batt]]
extractor = last
[[wh51_ch7_batt]]
extractor = last
[[wh51_ch8_batt]]
extractor = last
[[wh51_ch9_batt]]
extractor = last
[[wh51_ch10_batt]]
extractor = last
[[wh51_ch11_batt]]
extractor = last
[[wh51_ch12_batt]]
extractor = last
[[wh51_ch13_batt]]
extractor = last
[[wh51_ch14_batt]]
extractor = last
[[wh51_ch15_batt]]
extractor = last
[[wh51_ch16_batt]]
extractor = last
[[wh55_ch1_batt]]
extractor = last
[[wh55_ch2_batt]]
extractor = last
[[wh55_ch3_batt]]
extractor = last
[[wh55_ch4_batt]]
extractor = last
[[wh57_batt]]
extractor = last
[[wh68_batt]]
extractor = last
[[ws80_batt]]
extractor = last
[[ws85_batt]]
extractor = last
[[ws90_batt]]
extractor = last
[[wh40_sig]]
extractor = last
[[wh26_sig]]
extractor = last
[[wh25_sig]]
extractor = last
[[wh24_sig]]
extractor = last
[[wh65_sig]]
extractor = last
[[wh31_ch1_sig]]
extractor = last
[[wh31_ch2_sig]]
extractor = last
[[wh31_ch3_sig]]
extractor = last
[[wh31_ch4_sig]]
extractor = last
[[wh31_ch5_sig]]
extractor = last
[[wh31_ch6_sig]]
extractor = last
[[wh31_ch7_sig]]
extractor = last
[[wh31_ch8_sig]]
extractor = last
[[wn34_ch1_sig]]
extractor = last
[[wn34_ch2_sig]]
extractor = last
[[wn34_ch3_sig]]
extractor = last
[[wn34_ch4_sig]]
extractor = last
[[wn34_ch5_sig]]
extractor = last
[[wn34_ch6_sig]]
extractor = last
[[wn34_ch7_sig]]
extractor = last
[[wn34_ch8_sig]]
extractor = last
[[wn35_ch1_sig]]
extractor = last
[[wn35_ch2_sig]]
extractor = last
[[wn35_ch3_sig]]
extractor = last
[[wn35_ch4_sig]]
extractor = last
[[wn35_ch5_sig]]
extractor = last
[[wn35_ch6_sig]]
extractor = last
[[wn35_ch7_sig]]
extractor = last
[[wn35_ch8_sig]]
extractor = last
[[wh41_ch1_sig]]
extractor = last
[[wh41_ch2_sig]]
extractor = last
[[wh41_ch3_sig]]
extractor = last
[[wh41_ch4_sig]]
extractor = last
[[wh45_sig]]
extractor = last
[[wh46_sig]]
extractor = last
[[wh51_ch1_sig]]
extractor = last
[[wh51_ch2_sig]]
extractor = last
[[wh51_ch3_sig]]
extractor = last
[[wh51_ch4_sig]]
extractor = last
[[wh51_ch5_sig]]
extractor = last
[[wh51_ch6_sig]]
extractor = last
[[wh51_ch7_sig]]
extractor = last
[[wh51_ch8_sig]]
extractor = last
[[wh51_ch9_sig]]
extractor = last
[[wh51_ch10_sig]]
extractor = last
[[wh51_ch11_sig]]
extractor = last
[[wh51_ch12_sig]]
extractor = last
[[wh51_ch13_sig]]
extractor = last
[[wh51_ch14_sig]]
extractor = last
[[wh51_ch15_sig]]
extractor = last
[[wh51_ch16_sig]]
extractor = last
[[wh55_ch1_sig]]
extractor = last
[[wh55_ch2_sig]]
extractor = last
[[wh55_ch3_sig]]
extractor = last
[[wh55_ch4_sig]]
extractor = last
[[wh57_sig]]
extractor = last
[[wh68_sig]]
extractor = last
[[ws80_sig]]
extractor = last
[[ws85_sig]]
extractor = last
[[ws90_sig]]
extractor = last
# End Ecowitt Gateway driver extractors
"""
# construct our config dict
gw1000_dict = configobj.ConfigObj(StringIO(gw1000_config))
def version_compare(v1, v2):
"""Basic 'distutils' and 'packaging' free version comparison.
v1 and v2 are WeeWX version numbers in string format.
Returns:
0 if v1 and v2 are the same
-1 if v1 is less than v2
+1 if v1 is greater than v2
"""
import itertools
mash = itertools.zip_longest(v1.split('.'), v2.split('.'), fillvalue='0')
for x1, x2 in mash:
if x1 > x2:
return 1
if x1 < x2:
return -1
return 0
def loader():
return Gw1000Installer()
class Gw1000Installer(ExtensionInstaller):
def __init__(self):
if version_compare(weewx.__version__, REQUIRED_WEEWX_VERSION) < 0:
msg = "%s requires WeeWX %s or greater, found %s" % (''.join(('Ecowitt gateway driver ', GW1000_VERSION)),
REQUIRED_WEEWX_VERSION,
weewx.__version__)
raise weewx.UnsupportedFeature(msg)
super(Gw1000Installer, self).__init__(
version=GW1000_VERSION,
name='GW1000',
description='WeeWX driver for devices using the Ecowitt LAN/Wi-Fi Gateway API.',
author="Gary Roderick",
author_email="gjroderick<@>gmail.com",
files=[('bin/user', ['bin/user/gw1000.py'])],
config=gw1000_dict
)