-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsdr.py.orig
3512 lines (2992 loc) · 145 KB
/
sdr.py.orig
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
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
# Copyright 2016-2022 Matthew Wall
# Distributed under the terms of the GNU Public License (GPLv3)
"""
Collect data from stl-sdr. Run rtl_433 on a thread and push the output onto
a queue.
The SDR detects many different sensors and sensor types, so this driver
includes a mechanism to filter the incoming data, and to map the filtered
data onto the weewx database schema and identify the type of data from each
sensor.
Sensors are filtered based on a tuple that identifies uniquely each sensor.
A tuple consists of the observation name, a unique identifier for the hardware,
and the packet type, separated by periods:
<observation_name>.<hardware_id>.<packet_type>
The filter and data types are specified in a sensor_map stanza in the driver
stanza. For example:
[SDR]
driver = user.sdr
[[sensor_map]]
inTemp = temperature.25A6.AcuriteTowerPacket
outTemp = temperature.24A4.AcuriteTowerPacket
rain_total = rain_total.A52B.Acurite5n1Packet
If no sensor_map is specified, no data will be collected.
The deltas stanza indicates which observations are cumulative measures and
how they should be split into delta measures.
[SDR]
...
[[deltas]]
rain = rain_total
In this case, the value for rain will be a delta calculated from sequential
rain_total observations.
To identify sensors, run the driver directly. Alternatively, use the options
log_unknown_sensors and log_unmapped_sensors to see data from the SDR that are
not yet recognized by your configuration.
[SDR]
driver = user.sdr
log_unknown_sensors = True
log_unmapped_sensors = True
The default for each of these is False.
Eventually we would prefer to have all rtl_433 output as json. Unfortunately,
many of the rtl_433 decoders do not emit this format yet (as of January 2017).
So this driver is designed to look for json first, then fall back to single-
or multi-line plain text format.
Battery Status
In the weewx database, a battery status of 1 indicates low battery. This has
origins in the original battery indicators from davis vantage stations. Some
devices report 'battery' where a value of 1 indicates that the battery is ok,
i.e., the battery is *not* low. The rtl_433 output has been changed recently
to make this less ambiguous, so many devices now report 'battery_ok' instead
of just 'battery'. There were also cases where the 'battery' value was a
string, typically just 'OK'. FWIW, user fgonza2 reports that the Acurite low
battery indicator kicks in when the voltage hits about 4V.
WARNING: Handling of units and unit systems in rtl_433 is a mess, but it is
getting better. Although there is an option to request SI units, there is no
indicate in the decoder output whether that option is respected, nor does
rtl_433 specify exactly which SI units are used for various types of measure.
There seems to be a pattern of appending a unit label to the observation name
in the JSON data, for example 'wind_speed_mph' instead of just 'wind_speed'.
"""
# FIXME: deprecate then eliminate the V2 acurite packets - single packet def
# can recognize anything rtl_433 spits out
from __future__ import with_statement
from calendar import timegm
try:
# Python 3
import queue
except ImportError:
# Python 2:
import Queue as queue
import fnmatch
import os
import re
import subprocess
import threading
import time
import copy
try:
import cjson as json
setattr(json, 'dumps', json.encode)
setattr(json, 'loads', json.decode)
except (ImportError, AttributeError):
try:
import simplejson as json
except ImportError:
import json
import weewx.drivers
import weewx.units
from weeutil.weeutil import tobool
try:
# New-style weewx logging
import weeutil.logger
import logging
log = logging.getLogger(__name__)
def logdbg(msg):
log.debug(msg)
def loginf(msg):
log.info(msg)
def logerr(msg):
log.error(msg)
except ImportError:
# Old-style weewx logging
import syslog
def logmsg(level, msg):
syslog.syslog(level, 'sdr: %s: %s' %
(threading.currentThread().getName(), msg))
def logdbg(msg):
logmsg(syslog.LOG_DEBUG, msg)
def loginf(msg):
logmsg(syslog.LOG_INFO, msg)
def logerr(msg):
logmsg(syslog.LOG_ERR, msg)
DRIVER_NAME = 'SDR'
DRIVER_VERSION = '0.87'
# The default command requests json output from every decoder
# Use the -R option to indicate specific decoders
# -q - suppress non-data messages (for older versions of rtl_433)
# -M utc - print timestamps in UTC (-U for older versions of rtl_433)
# -F json - emit data in json format (not all rtl_433 decoders support this)
# -G - emit data for all rtl decoders (only available in newer rtl_433)
# as of early 2020, the syntax is '-G4', but use only for testing
# very old implmentations:
#DEFAULT_CMD = 'rtl_433 -q -U -F json -G'
# as of dec2018:
#DEFAULT_CMD = 'rtl_433 -M utc -F json -G'
# as of feb2020:
DEFAULT_CMD = 'rtl_433 -M utc -F json'
def loader(config_dict, _):
return SDRDriver(**config_dict[DRIVER_NAME])
def confeditor_loader():
return SDRConfigurationEditor()
# utilities for inline unit conversions. respect the None!
def to_F(v):
if v is not None:
v = v * 1.8 + 32
return v
def to_mph(v):
if v is not None:
v *= 0.621371
return v
def to_in(v):
if v is not None:
v /= 25.4
return v
class AsyncReader(threading.Thread):
def __init__(self, fd, queue, label):
threading.Thread.__init__(self)
self._fd = fd
self._queue = queue
self._running = False
self.setDaemon(True)
self.setName(label)
def run(self):
logdbg("start async reader for %s" % self.getName())
self._running = True
for line in iter(self._fd.readline, ''):
if line:
self._queue.put(line)
if not self._running:
break
def stop_running(self):
self._running = False
class ProcManager(object):
TS = re.compile('^\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d[\s]+')
def __init__(self):
self._cmd = None
self._process = None
self.stdout_queue = queue.Queue()
self.stdout_reader = None
self.stderr_queue = queue.Queue()
self.stderr_reader = None
def startup(self, cmd, path=None, ld_library_path=None):
self._cmd = cmd
loginf("startup process '%s'" % self._cmd)
env = os.environ.copy()
if path:
env['PATH'] = path + ':' + env['PATH']
if ld_library_path:
env['LD_LIBRARY_PATH'] = ld_library_path
try:
self._process = subprocess.Popen(cmd.split(' '),
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
self.stdout_reader = AsyncReader(
self._process.stdout, self.stdout_queue, 'stdout-thread')
self.stdout_reader.start()
self.stderr_reader = AsyncReader(
self._process.stderr, self.stderr_queue, 'stderr-thread')
self.stderr_reader.start()
except (OSError, ValueError) as e:
raise weewx.WeeWxIOError("failed to start process '%s': %s" %
(cmd, e))
def shutdown(self):
loginf('shutdown process %s' % self._cmd)
self._process.kill()
logdbg("close stdout")
self._process.stdout.close()
logdbg("close stderr")
self._process.stderr.close()
logdbg('shutdown %s' % self.stdout_reader.getName())
self.stdout_reader.stop_running()
self.stdout_reader.join(0.5)
logdbg('shutdown %s' % self.stderr_reader.getName())
self.stderr_reader.stop_running()
self.stderr_reader.join(0.5)
if self._process.poll() is None:
logerr('process did not respond to kill, shutting down anyway')
self._process = None
if self.stdout_reader.is_alive():
loginf('timed out waiting for %s' % self.stdout_reader.getName())
self.stdout_reader = None
if self.stderr_reader.is_alive():
loginf('timed out waiting for %s' % self.stderr_reader.getName())
self.stderr_reader = None
loginf('shutdown complete')
def running(self):
return self._process.poll() is None
def get_stderr(self):
lines = []
while not self.stderr_queue.empty():
lines.append(self.stderr_queue.get().decode())
return lines
def get_stdout(self):
lines = []
while self.running():
try:
# Fetch the output line. For it to be searched, Python 3
# requires that it be decoded to unicode. Decoding does no
# harm under Python 2:
line = self.stdout_queue.get(True, 3).decode()
m = ProcManager.TS.search(line)
if m and lines:
yield lines
lines = []
lines.append(line)
except queue.Empty:
yield lines
lines = []
yield lines
class Packet:
def __init__(self):
pass
@staticmethod
def parse_text(ts, payload, lines):
return None
@staticmethod
def parse_json(obj):
return None
TS_PATTERN = re.compile('(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d)')
@staticmethod
def parse_time(line):
ts = None
try:
m = Packet.TS_PATTERN.search(line)
if m:
utc = time.strptime(m.group(1), "%Y-%m-%d %H:%M:%S")
ts = timegm(utc)
except Exception as e:
logerr("parse timestamp failed for '%s': %s" % (line, e))
return ts
@staticmethod
def get_float(obj, key_):
if key_ in obj:
try:
return float(obj[key_])
except ValueError:
pass
return None
@staticmethod
def get_int(obj, key_):
if key_ in obj:
try:
return int(obj[key_])
except ValueError:
pass
return None
@staticmethod
def parse_lines(lines, parseinfo=None):
# parse each line, splitting on colon for name:value
# tuple in parseinfo is label, pattern, lambda
# if there is a label, use it to transform the name
# if there is a pattern, use it to match the value
# if there is a lamba, use it to convert the value
if parseinfo is None:
parseinfo = dict()
packet = dict()
for line in lines[1:]:
if line.count(':') == 1:
try:
(name, value) = [x.strip() for x in line.split(':')]
if name in parseinfo:
if parseinfo[name][1]:
m = parseinfo[name][1].search(value)
if m:
value = m.group(1)
else:
logdbg("regex failed for %s:'%s'" %
(name, value))
if parseinfo[name][2]:
value = parseinfo[name][2](value)
if parseinfo[name][0]:
name = parseinfo[name][0]
packet[name] = value
else:
logdbg("ignoring %s:%s" % (name, value))
except Exception as e:
logerr("parse failed for line '%s': %s" % (line, e))
else:
logdbg("skip line '%s'" % line)
while lines:
lines.pop(0)
return packet
@staticmethod
def add_identifiers(pkt, sensor_id='', packet_type=''):
# qualify each field name with details about the sensor. not every
# sensor has all three fields.
# observation.<sensor_id>.<packet_type>
packet = dict()
if 'dateTime' in pkt:
packet['dateTime'] = pkt.pop('dateTime', 0)
if 'usUnits' in pkt:
packet['usUnits'] = pkt.pop('usUnits', 0)
for n in pkt:
packet["%s.%s.%s" % (n, sensor_id, packet_type)] = pkt[n]
return packet
class Acurite(object):
@staticmethod
def insert_ids(pkt, pkt_type):
# there should be a sensor_id field in the packet to identify sensor.
# ensure the sensor_id is upper-case - it should be 4 hex characters.
sensor_id = str(pkt.pop('hardware_id', '0000')).upper()
return Packet.add_identifiers(pkt, sensor_id, pkt_type)
class AcuriteAtlasPacket(Packet):
# {"time": "2019-12-14 16:56:57", "model": "Acurite-Atlas", "id": 896, "channel": "A", "sequence_num": 0, "battery_ok": 1, "message_type": 37, "wind_avg_mi_h": 5.000, "temperature_F": 40.000, "humidity": 76, "byte8": 0, "byte9": 37, "byte89": 37}
# {"time": "2019-12-14 16:57:07", "model": "Acurite-Atlas", "id": 896, "channel": "A", "sequence_num": 0, "battery_ok": 1, "message_type": 38, "wind_avg_mi_h": 6.000, "wind_dir_deg": 291.000, "rain_in": 0.290, "byte8": 0, "byte9": 37, "byte89": 37}}
# {"time": "2019-12-14 16:57:58", "model": "Acurite-Atlas", "id": 896, "channel": "A", "sequence_num": 0, "battery_ok": 1, "message_type": 39, "wind_avg_mi_h": 6.000, "uv": 0, "lux": 22900, "byte8": 0, "byte9": 37, "byte89": 37}
# for battery, 0 means OK (assuming that 1 for battery_ok means OK)
# message types: 37, 38, 39
# 37: wind_avg_mi_h, temperature_F, humidity
# 38: wind_avg_mi_h, wind_dir_deg, rain_in
# 39: wind_avg_mi_h, uv, lux
IDENTIFIER = "Acurite-Atlas"
@staticmethod
def parse_json(obj):
pkt = dict()
pkt['usUnits'] = weewx.US
pkt['dateTime'] = Packet.parse_time(obj.get('time'))
pkt['model'] = obj.get('model')
pkt['hardware_id'] = "%04x" % obj.get('id', 0)
pkt['channel'] = obj.get('channel')
pkt['sequence_num'] = Packet.get_int(obj, 'sequence_num')
pkt['message_type'] = Packet.get_int(obj, 'message_type')
if 'humidity' in obj:
pkt['humidity'] = Packet.get_float(obj, 'humidity')
if 'temperature_F' in obj:
pkt['temperature'] = Packet.get_float(obj, 'temperature_F')
elif 'temperature_C' in obj:
pkt['temperature'] = to_F(Packet.get_float(obj, 'temperature_C'))
if 'wind_avg_mi_h' in obj:
pkt['wind_speed'] = Packet.get_float(obj, 'wind_avg_mi_h')
elif 'wind_avg_km_h' in obj:
pkt['wind_speed'] = to_mph(Packet.get_float(obj, 'wind_avg_km_h'))
if 'wind_dir_deg' in obj:
pkt['wind_dir'] = Packet.get_float(obj, 'wind_dir_deg')
if 'rain_in' in obj:
pkt['rain_total'] = Packet.get_float(obj, 'rain_in')
elif 'rain_mm' in obj:
pkt['rain_total'] = to_in(Packet.get_float(obj, 'rain_mm'))
if 'uv' in obj:
pkt['uv'] = Packet.get_int(obj, 'uv')
if 'lux' in obj:
pkt['lux'] = Packet.get_int(obj, 'lux')
if 'strike_count' in obj:
pkt['strike_count'] = Packet.get_int(obj, 'strike_count')
if 'strike_distance' in obj:
pkt['strike_distance'] = Packet.get_int(obj, 'strike_distance')
if 'snr' in obj:
pkt['snr'] = obj.get('snr')
if 'rssi' in obj:
pkt['rssi'] = obj.get('rssi')
if 'noise' in obj:
pkt['noise'] = obj.get('noise')
pkt['battery'] = 1 if Packet.get_int(obj, 'battery_ok') == 0 else 0
return Acurite.insert_ids(pkt, AcuriteAtlasPacket.__name__)
class AcuriteTowerPacketV2(Packet):
# Based on AcuriteTowerPacket type, but implemented for unsupported format
# Sample data:
# {"time" : "2019-07-29 07:44:23.005624", "protocol" : 40, "model" : "Acurite-Tower", "id" : 1234, "sensor_id" : 1234, "channel" : "A", "temperature_C" : 22.600, "humidity" : 45, "battery_ok" : 0, "mod" : "ASK", "freq" : 433.938, "rssi" : -0.134, "snr" : 14.391, "noise" : -14.525}
# {"time" : "2021-12-20 20:00:59", "model" : "Acurite-Tower", "id" : 11041, "channel" : "B", "battery_ok" : 1, "temperature_C" : -3.500, "humidity" : 71, "mic" : "CHECKSUM"}
IDENTIFIER = "Acurite-Tower"
@staticmethod
def parse_json(obj):
pkt = dict()
pkt['usUnits'] = weewx.US
pkt['dateTime'] = Packet.parse_time(obj.get('time'))
pkt['protocol'] = Packet.get_int(obj, 'protocol') # 40
pkt['model'] = obj.get('model') # model = Acurite-Tower
pkt['hardware_id'] = "%04x" % obj.get('id', 0)
pkt['sensor_id'] = "%04x" % obj.get('sensor_id', 0)
pkt['channel'] = obj.get('channel')
pkt['humidity'] = Packet.get_float(obj, 'humidity')
if 'temperature_F' in obj:
pkt['temperature'] = Packet.get_float(obj, 'temperature_F')
elif 'temperature_C' in obj:
pkt['temperature'] = to_F(Packet.get_float(obj, 'temperature_C'))
pkt['battery'] = 0 if obj.get('battery_ok') == 1 else 1
pkt['mod'] = obj.get('mod') # apparently mod = ASK
pkt['freq'] = Packet.get_float(obj, 'freq')
pkt['rssi'] = Packet.get_float(obj, 'rssi')
pkt['snr'] = Packet.get_float(obj, 'snr')
pkt['noise'] = Packet.get_float(obj, 'noise')
return Acurite.insert_ids(pkt, AcuriteTowerPacketV2.__name__)
class Acurite3n1PacketV2(Packet):
# sample json output from rtl_433
# {"time" : "2021-12-27 02:53:38", "model" : "Acurite-3n1", "subtype" : 32, "id" : 7220, "channel" : "B", "sequence_num" : 1, "battery_ok" : 1, "wind_avg_mi_h" : 5.000, "temperature_F" : 5.100, "humidity" : 65, "mic" : "CHECKSUM"}
IDENTIFIER = "Acurite-3n1"
@staticmethod
def parse_json(obj):
pkt = dict()
pkt['usUnits'] = weewx.US
pkt['dateTime'] = Packet.parse_time(obj.get('time'))
pkt['model'] = obj.get('model')
pkt['hardware_id'] = "%04x" % obj.get('id', 0)
pkt['channel'] = obj.get('channel')
pkt['sequence_num'] = Packet.get_int(obj, 'sequence_num')
pkt['battery'] = 0 if obj.get('battery_ok') == 1 else 1
if 'subtype' in obj:
pkt['msg_type'] = Packet.get_int(obj, 'subtype')
elif 'message_type' in obj:
pkt['msg_type'] = Packet.get_int(obj, 'message_type')
if 'humidity' in obj:
pkt['humidity'] = Packet.get_float(obj, 'humidity')
if 'temperature_F' in obj:
pkt['temperature'] = Packet.get_float(obj, 'temperature_F')
elif 'temperature_C' in obj:
pkt['temperature'] = to_F(Packet.get_float(obj, 'temperature_C'))
if 'wind_avg_mi_h' in obj:
pkt['wind_speed'] = Packet.get_float(obj, 'wind_avg_mi_h')
elif 'wind_avg_km_h' in obj:
pkt['wind_speed'] = to_mph(Packet.get_float(obj, 'wind_avg_km_h'))
return Acurite.insert_ids(pkt, Acurite3n1PacketV2.__name__)
class Acurite5n1PacketV2(Packet):
# Based on Acurite5n1Packet class, but implemented for unsupported format
# sample json output from rtl_433
# {"time" : "2019-07-29 07:46:22.482883", "protocol" : 40, "model" : "Acurite-5n1", "id" : 1234, "channel" : "B", "sequence_num" : 1, "battery_ok" : 1, "message_type" : 56, "wind_avg_km_h" : 0.000, "temperature_C" : 20.500, "humidity" : 93, "mod" : "ASK", "freq" : 433.934, "rssi" : -1.719, "snr" : 24.404, "noise" : -26.124}
# {"time" : "2020-02-05 02:20:54", "model" : "Acurite-5n1", "subtype" : 56, "id" : 956, "channel" : "A", "sequence_num" : 2, "battery_ok" : 1, "wind_avg_km_h" : 3.483, "temperature_F" : 31.300, "humidity" : 66}
# {"time" : "2020-10-26 22:09:12", "model" : "Acurite-5n1", "message_type" : 49, "id" : 2662, "channel" : "A", "sequence_num" : 0, "battery_ok" : 1, "wind_avg_km_h" : 15.900, "wind_dir_deg" : 337.500, "rain_in" : 7.290, "mic" : "CHECKSUM"}
# {"time" : "2020-10-26 22:08:54", "model" : "Acurite-5n1", "message_type" : 56, "id" : 2662, "channel" : "A", "sequence_num" : 2, "battery_ok" : 1, "wind_avg_km_h" : 9.278, "temperature_F" : 76.100, "humidity" : 15, "mic" : "CHECKSUM"}
IDENTIFIER = "Acurite-5n1"
@staticmethod
def parse_json(obj):
pkt = dict()
pkt['usUnits'] = weewx.US
pkt['dateTime'] = Packet.parse_time(obj.get('time'))
pkt['protocol'] = Packet.get_int(obj, 'protocol')
pkt['model'] = obj.get('model')
pkt['hardware_id'] = "%04x" % obj.get('id', 0)
pkt['channel'] = obj.get('channel')
pkt['sequence_num'] = Packet.get_int(obj, 'sequence_num')
pkt['battery'] = 0 if obj.get('battery_ok') == 1 else 1
# connection diagnostics depend on the version of rtl_433
pkt['mod'] = obj.get('mod') # apparently is ASK
pkt['freq'] = Packet.get_float(obj, 'freq')
pkt['rssi'] = Packet.get_float(obj, 'rssi')
pkt['snr'] = Packet.get_float(obj, 'snr')
pkt['noise'] = Packet.get_float(obj, 'noise')
# the label for message type has changed in rtl_433
if 'subtype' in obj:
pkt['msg_type'] = Packet.get_int(obj, 'subtype')
elif 'message_type' in obj:
pkt['msg_type'] = Packet.get_int(obj, 'message_type')
# each message type contains different information. units vary
# depending on the rtl_433 configuration, so be ready for anything.
# 49 has wind_speed, wind_dir, and rain
# 56 has wind_speed, temperature, humidity
if 'wind_avg_km_h' in obj:
pkt['wind_speed'] = to_mph(Packet.get_float(obj, 'wind_avg_km_h'))
if 'wind_dir_deg' in obj:
pkt['wind_dir'] = Packet.get_float(obj, 'wind_dir_deg')
if 'rain_in' in obj:
pkt['rain_total'] = Packet.get_float(obj, 'rain_in')
elif 'rain_mm' in obj:
pkt['rain_total'] = to_in(Packet.get_float(obj, 'rain_mm'))
if 'temperature_F' in obj:
pkt['temperature'] = Packet.get_float(obj, 'temperature_F')
elif 'temperature_C' in obj:
pkt['temperature'] = to_F(Packet.get_float(obj, 'temperature_C'))
if 'humidity' in obj:
pkt['humidity'] = Packet.get_float(obj, 'humidity')
return Acurite.insert_ids(pkt, Acurite5n1PacketV2.__name__)
class AcuriteTowerPacket(Packet):
# initial implementation was single-line
# 2016-08-30 23:57:20 Acurite tower sensor 0x37FC Ch A: 26.7 C 80.1 F 16 % RH
#
# multi-line was introduced nov2016 - only single line is supported here
# 2017-01-12 02:55:10 : Acurite tower sensor : 12391 : B
# Temperature: 18.0 C
# Humidity: 68
# Battery: 0
# : 68
IDENTIFIER = "Acurite tower sensor"
PATTERN = re.compile('0x([0-9a-fA-F]+) Ch ([A-C]): ([\d.-]+) C ([\d.-]+) F ([\d]+) % RH')
@staticmethod
def parse_text(ts, payload, lines):
pkt = dict()
m = AcuriteTowerPacket.PATTERN.search(lines[0])
if m:
pkt['dateTime'] = ts
pkt['usUnits'] = weewx.METRIC
pkt['hardware_id'] = m.group(1)
pkt['channel'] = m.group(2)
pkt['temperature'] = float(m.group(3))
pkt['temperature_F'] = float(m.group(4))
pkt['humidity'] = float(m.group(5))
pkt = Acurite.insert_ids(pkt, AcuriteTowerPacket.__name__)
else:
loginf("AcuriteTowerPacket: unrecognized data: '%s'" % lines[0])
lines.pop(0)
return pkt
# JSON format as of mid-2018
# {"time" : "2018-07-21 01:53:56", "model" : "Acurite tower sensor", "id" : 13009, "sensor_id" : 13009, "channel" : "A", "temperature_C" : 15.000, "humidity" : 16, "battery_low" : 1}
# {"time" : "2018-07-21 01:52:24", "model" : "Acurite tower sensor", "id" : 13009, "sensor_id" : 13009, "channel" : "A", "temperature_C" : 15.600, "humidity" : 16, "battery_low" : 0}
# JSON format as of early 2017
# {"time" : "2017-01-12 03:43:05", "model" : "Acurite tower sensor", "id" : 521, "channel" : "A", "temperature_C" : 0.800, "humidity" : 68, "battery" : 0, "status" : 68}
# {"time" : "2017-01-12 03:43:11", "model" : "Acurite tower sensor", "id" : 5585, "channel" : "C", "temperature_C" : 21.100, "humidity" : 32, "battery" : 0, "status" : 68}
@staticmethod
def parse_json(obj):
pkt = dict()
pkt['dateTime'] = Packet.parse_time(obj.get('time'))
pkt['usUnits'] = weewx.US
pkt['hardware_id'] = "%04x" % obj.get('id', 0)
pkt['channel'] = obj.get('channel')
# support both battery status keywords
if 'battery_low' in obj:
pkt['battery'] = Packet.get_int(obj, 'battery_low')
else:
pkt['battery'] = Packet.get_int(obj, 'battery')
pkt['status'] = obj.get('status')
if 'temperature_F' in obj:
pkt['temperature'] = Packet.get_float(obj, 'temperature_F')
elif 'temperature_C' in obj:
pkt['temperature'] = to_F(Packet.get_float(obj, 'temperature_C'))
pkt['humidity'] = Packet.get_float(obj, 'humidity')
return Acurite.insert_ids(pkt, AcuriteTowerPacket.__name__)
class Acurite5n1Packet(Packet):
# 2016-08-31 16:41:39 Acurite 5n1 sensor 0x0BFA Ch C, Msg 31, Wind 15 kmph / 9.3 mph 270.0^ W (3), rain gauge 0.00 in
# 2016-08-30 23:57:25 Acurite 5n1 sensor 0x0BFA Ch C, Msg 38, Wind 2 kmph / 1.2 mph, 21.3 C 70.3 F 70 % RH
# 2016-09-27 17:09:34 Acurite 5n1 sensor 0x062C Ch A, Total rain fall since last reset: 2.00
#
# the 'rain fall since last reset' seems to be emitted once when rtl_433
# starts up, then never again. the rain measure in the type 31 messages
# is a cumulative value, but not the same as rain since last reset.
#
# rtl_433 keeps using different labels and calculations for the rain
# counter, so try to deal with the variants we have seen.
IDENTIFIER = "Acurite 5n1 sensor"
PATTERN = re.compile('0x([0-9a-fA-F]+) Ch ([A-C]), (.*)')
RAIN = re.compile('Total rain fall since last reset: ([\d.]+)')
MSG = re.compile('Msg (\d+), (.*)')
MSG31 = re.compile('Wind ([\d.]+) kmph / ([\d.]+) mph ([\d.]+).*rain gauge ([\d.]+) in')
MSG38 = re.compile('Wind ([\d.]+) kmph / ([\d.]+) mph, ([\d.-]+) C ([\d.-]+) F ([\d.]+) % RH')
@staticmethod
def parse_text(ts, payload, lines):
pkt = dict()
m = Acurite5n1Packet.PATTERN.search(lines[0])
if m:
pkt['dateTime'] = ts
pkt['usUnits'] = weewx.METRIC
pkt['hardware_id'] = m.group(1)
pkt['channel'] = m.group(2)
payload = m.group(3)
m = Acurite5n1Packet.MSG.search(payload)
if m:
msg_type = m.group(1)
payload = m.group(2)
if msg_type == '31':
m = Acurite5n1Packet.MSG31.search(payload)
if m:
pkt['wind_speed'] = float(m.group(1))
pkt['wind_speed_mph'] = float(m.group(2))
pkt['wind_dir'] = float(m.group(3))
pkt['rain_total'] = float(m.group(4))
else:
loginf("Acurite5n1Packet: no match for type 31: '%s'"
% payload)
elif msg_type == '38':
m = Acurite5n1Packet.MSG38.search(payload)
if m:
pkt['wind_speed'] = float(m.group(1))
pkt['wind_speed_mph'] = float(m.group(2))
pkt['temperature'] = float(m.group(3))
pkt['temperature_F'] = float(m.group(4))
pkt['humidity'] = float(m.group(5))
else:
loginf("Acurite5n1Packet: no match for type 38: '%s'"
% payload)
else:
loginf("Acurite5n1Packet: unknown message type %s"
" in line '%s'" % (msg_type, lines[0]))
else:
m = Acurite5n1Packet.RAIN.search(payload)
if m:
total = float(m.group(1))
pkt['rain_since_reset'] = total
loginf("Acurite5n1Packet: rain since reset: %s" % total)
else:
loginf("Acurite5n1Packet: unknown message format: '%s'" %
lines[0])
else:
loginf("Acurite5n1Packet: unrecognized data: '%s'" % lines[0])
lines.pop(0)
return Acurite.insert_ids(pkt, Acurite5n1Packet.__name__)
# sample json output from rtl_433 as of jan2017
# {"time" : "2017-01-16 02:34:12", "model" : "Acurite 5n1 sensor", "sensor_id" : 3066, "channel" : "C", "sequence_num" : 1, "battery" : "OK", "message_type" : 49, "wind_speed" : 0.000, "wind_dir_deg" : 67.500, "wind_dir" : "ENE", "rainfall_accumulation" : 0.000, "raincounter_raw" : 8978}
# {"time" : "2017-01-16 02:37:33", "model" : "Acurite 5n1 sensor", "sensor_id" : 3066, "channel" : "C", "sequence_num" : 1, "battery" : "OK", "message_type" : 56, "wind_speed" : 0.000, "temperature_F" : 27.500, "humidity" : 56}
# some changes to rtl_433 as of dec2017
# {"time" : "2017-12-24 02:07:00", "model" : "Acurite 5n1 sensor", "sensor_id" : 2662, "channel" : "A", "sequence_num" : 2, "battery" : "OK", "message_type" : 56, "wind_speed_mph" : 0.000, "temperature_F" : 47.500, "humidity" : 74}
# {"time" : "2017-12-24 02:07:18", "model" : "Acurite 5n1 sensor", "sensor_id" : 2662, "channel" : "A", "sequence_num" : 2, "battery" : "OK", "message_type" : 49, "wind_speed_mph" : 0.000, "wind_dir_deg" : 157.500, "wind_dir" : "SSE", "rainfall_accumulation_inch" : 0.000, "raincounter_raw" : 421}
# more changes to rtl_433 as of dec2018
# {"time" : "2019-01-04 02:37:10", "model" : "Acurite 5n1 sensor", "sensor_id" : 2662, "channel" : "A", "sequence_num" : 1, "battery" : "OK", "message_type" : 56, "wind_speed_kph" : 0.000, "temperature_F" : 42.400, "humidity" : 83}
# {"time" : "2019-01-04 02:37:28", "model" : "Acurite 5n1 sensor", "sensor_id" : 2662, "channel" : "A", "sequence_num" : 0, "battery" : "LOW", "message_type" : 49, "wind_speed_kph" : 0.000, "wind_dir_deg" : 180.000, "rain_inch" : 28.970}
@staticmethod
def parse_json(obj):
pkt = dict()
pkt['dateTime'] = Packet.parse_time(obj.get('time'))
pkt['usUnits'] = weewx.US
pkt['hardware_id'] = "%04x" % obj.get('sensor_id', 0)
pkt['channel'] = obj.get('channel')
pkt['battery'] = 0 if obj.get('battery') == 'OK' else 1
pkt['status'] = obj.get('status')
msg_type = obj.get('message_type')
if msg_type == 49: # 0x31
pkt['wind_speed'] = Acurite5n1Packet.get_wind_speed(obj)
pkt['wind_dir'] = Packet.get_float(obj, 'wind_dir_deg')
pkt['rain_total'] = Acurite5n1Packet.get_rain_total(obj)
elif msg_type == 56: # 0x38
pkt['wind_speed'] = Acurite5n1Packet.get_wind_speed(obj)
pkt['temperature'] = Packet.get_float(obj, 'temperature_F')
pkt['humidity'] = Packet.get_float(obj, 'humidity')
return Acurite.insert_ids(pkt, Acurite5n1Packet.__name__)
@staticmethod
def get_wind_speed(obj):
ws = None
if 'wind_speed_mph' in obj:
ws = Packet.get_float(obj, 'wind_speed_mph')
if 'wind_speed_kph' in obj:
ws = Packet.get_float(obj, 'wind_speed_kph')
if ws is not None:
ws = weewx.units.kph_to_mph(ws)
return ws
@staticmethod
def get_rain_total(obj):
rain_total = None
if 'raincounter_raw' in obj:
rain_counter = Packet.get_int(obj, 'raincounter_raw')
# put some units on the rain total - each tip is 0.01 inch
if rain_counter is not None:
rain_total = rain_counter * 0.01 # inch
elif 'rain_inch' in obj:
rain_total = Packet.get_float(obj, 'rain_inch')
return rain_total
class Acurite606TXPacket(Packet):
# 2017-03-20: Acurite 606TX Temperature Sensor
# {"time" : "2017-03-04 16:18:12", "model" : "Acurite 606TX Sensor", "id" : 48, "battery" : "OK", "temperature_C" : -1.100}
IDENTIFIER = "Acurite 606TX Sensor"
@staticmethod
def parse_json(obj):
pkt = dict()
pkt['dateTime'] = Packet.parse_time(obj.get('time'))
pkt['usUnits'] = weewx.US
sensor_id = obj.get('id')
if 'temperature_F' in obj:
pkt['temperature'] = Packet.get_float(obj, 'temperature_F')
elif 'temperature_C' in obj:
pkt['temperature'] = to_F(Packet.get_float(obj, 'temperature_C'))
if 'battery_ok' in obj:
pkt['battery'] = 0 if Packet.get_int(obj, 'battery_ok') == 1 else 1
else:
pkt['battery'] = 0 if obj.get('battery') == 'OK' else 1
pkt = Packet.add_identifiers(pkt, sensor_id, Acurite606TXPacket.__name__)
return pkt
class Acurite606TXPacketV2(Packet):
# 2021-02-23: Acurite 606TX Temperature Sensor
# {"time" : "2021-02-23 16:24:07", "model" : "Acurite-606TX", "id" : 153, "battery_ok" : 1, "temperature_C" : 18.800, "mic" : "CHECKSUM"}
# {"time" : "2021-10-26 23:39:49", "model" : "Acurite-606TX", "id" : 194, "battery_ok" : 1, "temperature_C" : 19.200, "mic" : "CHECKSUM"}
IDENTIFIER = "Acurite-606TX"
@staticmethod
def parse_json(obj):
pkt = dict()
pkt['dateTime'] = Packet.parse_time(obj.get('time'))
pkt['usUnits'] = weewx.US
sensor_id = obj.get('id')
if 'temperature_F' in obj:
pkt['temperature'] = Packet.get_float(obj, 'temperature_F')
elif 'temperature_C' in obj:
pkt['temperature'] = to_F(Packet.get_float(obj, 'temperature_C'))
pkt['battery'] = 0 if obj.get('battery_ok') == '1' else 1
pkt = Packet.add_identifiers(pkt, sensor_id, Acurite606TXPacketV2.__name__)
return pkt
class AcuriteRain899Packet(Packet):
# Sample data:
# {"time" : "2019-12-05 16:32:20", "model" : "Acurite-Rain899", "id" : 1699, "channel" : 0, "battery_ok" : 0, "rain_mm" : 6.096}
# {"time" : "2019-12-05 16:32:20", "model" : "Acurite-Rain899", "id" : 1699, "channel" : 0, "battery_ok" : 0, "rain_mm" : 6.096}
# {"time" : "2019-12-05 16:32:20", "model" : "Acurite-Rain899", "id" : 1699, "channel" : 0, "battery_ok" : 0, "rain_mm" : 6.096}
IDENTIFIER = "Acurite-Rain899"
@staticmethod
def parse_json(obj):
pkt = dict()
pkt['usUnits'] = weewx.US
pkt['dateTime'] = Packet.parse_time(obj.get('time'))
pkt['model'] = obj.get('model')
pkt['hardware_id'] = "%04x" % obj.get('id', 0)
pkt['channel'] = obj.get('channel')
pkt['battery'] = 0 if obj.get('battery_ok') == 1 else 1
if 'rain_mm' in obj:
pkt['rain_total'] = to_in(Packet.get_float(obj, 'rain_mm'))
return Acurite.insert_ids(pkt, AcuriteRain899Packet.__name__)
class Acurite986Packet(Packet):
# 2016-10-31 15:24:29 Acurite 986 sensor 0x2c87 - 2F: 16.7 C 62 F
# 2016-10-31 15:23:54 Acurite 986 sensor 0x85ed - 1R: 16.7 C 62 F
# {"time" : "2018-04-22 18:01:03", "model" : "Acurite 986 Sensor", "id" : 43248, "channel" : "1R", "temperature_F" : 69, "battery" : "OK", "status" : 0}
# {"time" : "2020-10-19 07:00:32", "model" : "Acurite-986", "id" : 9534, "channel" : "2F", "battery_ok" : 1, "temperature_F" : -10.000, "status" : 0, "mic" : "CRC"}
# The 986 hardware_id changes, so using the 2F and 1R as the hardware
# identifer. As long as you only have one set of sendors and your
# close neighbors have none.
# Older releases of rtl_433 used 'Acurite 986 sensor', while recent
# versions use 'Acurite 986 Sensor'. So we try to be compatible by
# matching on the least that we can.
# IDENTIFIER = "Acurite 986 sensor"
# IDENTIFIER = "Acurite 986 Sensor"
IDENTIFIER = "Acurite-986"
PATTERN = re.compile('0x([0-9a-fA-F]+) - (1R|2F): ([\d.-]+) C ([\d.-]+) F')
@staticmethod
def parse_text(ts, payload, lines):
pkt = dict()
m = Acurite986Packet.PATTERN.search(lines[0])
if m:
pkt['dateTime'] = ts
pkt['usUnits'] = weewx.METRIC
pkt['hardware_id'] = m.group(1)
pkt['channel'] = m.group(2)
pkt['temperature'] = float(m.group(3))
pkt['temperature_F'] = float(m.group(4))
else:
loginf("Acurite986Packet: unrecognized data: '%s'" % lines[0])
lines.pop(0)
return Acurite.insert_ids(pkt, Acurite986Packet.__name__)
@staticmethod
def parse_json(obj):
pkt = dict()
pkt['dateTime'] = Packet.parse_time(obj.get('time'))
pkt['hardware_id'] = obj.get('id', 0)
pkt['channel'] = obj.get('channel')
pkt['battery'] = 0 if obj.get('battery_ok') == 1 else 1
if 'temperature_F' in obj:
pkt['usUnits'] = weewx.US
pkt['temperature'] = Packet.get_float(obj, 'temperature_F')
else:
pkt['usUnits'] = weewx.METRIC
pkt['temperature'] = Packet.get_float(obj, 'temperature_C')
return Acurite.insert_ids(pkt, Acurite986Packet.__name__)
class AcuriteLightningPacket(Packet):
# with rtl_433 update of 19mar2017
# 2017-03-19 16:48:31 Acurite lightning 0x976F Ch A Msg Type 0x02: 66.2 F 25 % RH Strikes 1 Distance 0 L_status 0x02 - c0 97* 6f 99 50 72 81 c0 62*
# 2017-03-19 16:48:47 Acurite lightning 0x976F Ch A Msg Type 0x02: 66.2 F 25 % RH Strikes 1 Distance 0 L_status 0x02 - c0 97* 6f 99 50 72 81 c0 62*
# pre-19mar2017
# 2016-11-04 04:34:58 Acurite lightning 0x536F Ch A Msg Type 0x51: 15 C 58 % RH Strikes 50 Distance 69 - c0 53 6f 3a d1 0f b2 c5 13*
# 2016-11-04 04:43:14 Acurite lightning 0x536F Ch A Msg Type 0x51: 15 C 58 % RH Strikes 55 Distance 5 - c0 53 6f 3a d1 0f b7 05 58*
# 2016-11-04 04:43:22 Acurite lightning 0x536F Ch A Msg Type 0x51: 15 C 58 % RH Strikes 55 Distance 69 - c0 53 6f 3a d1 0f b7 c5 18
# 2017-01-16 02:37:39 Acurite lightning 0x526F Ch A Msg Type 0x11: 67 C 38 % RH Strikes 47 Distance 81 - dd 52* 6f a6 11 c3 af d1 98*
# April 21, 2018 - JSON support
# {"time" : "2018-04-21 19:12:53", "model" : "Acurite Lightning 6045M", "id" : 151, "channel" : "C", "temperature_F" : 66.900, "humidity" : 33, "strike_count" : 47, "storm_dist" : 12, "active" : 1, "rfi" : 0, "ussb1" : 1, "battery" : "LOW", "exception" : 0, "raw_msg" : "0097af2150f9afcc2b"}
# {"time" : "2020-10-13 22:49:34", "model" : "Acurite-6045M", "id" : 15431, "channel" : "A", "battery_ok" : 0, "temperature_F" : 91.800, "humidity" : 21, "strike_count" : 171, "storm_dist" : 12, "active" : 1, "rfi" : 0, "exception" : 0, "raw_msg" : "fc47af95d2de55cc58"}
# IDENTIFIER = "Acurite lightning"
# IDENTIFIER = "Acurite Lightning 6045M"
IDENTIFIER = "Acurite-6045M"
PATTERN = re.compile('0x([0-9a-fA-F]+) Ch (.) Msg Type 0x([0-9a-fA-F]+): ([\d.-]+) ([CF]) ([\d.]+) % RH Strikes ([\d]+) Distance ([\d.]+)')
@staticmethod
def parse_json(obj):
pkt = dict()
pkt['dateTime'] = Packet.parse_time(obj.get('time'))
pkt['usUnits'] = weewx.US
pkt['channel'] = obj.get('channel')
pkt['hardware_id'] = "%04x" % obj.get('id', 0)
pkt['temperature'] = obj.get('temperature_F')
pkt['battery'] = 0 if obj.get('battery_ok') == 1 else 1
pkt['humidity'] = obj.get('humidity')
pkt['active'] = obj.get('active')
pkt['rfi'] = obj.get('rfi')
pkt['exception'] = obj.get('exception')
pkt['strikes_total'] = obj.get('strike_count')
pkt['distance'] = obj.get('storm_dist')
return Acurite.insert_ids(pkt, AcuriteLightningPacket.__name__)
@staticmethod
def parse_text(ts, payload, lines):
pkt = dict()
m = AcuriteLightningPacket.PATTERN.search(lines[0])
if m:
pkt['dateTime'] = ts
units = m.group(5)
if units == 'C':
pkt['usUnits'] = weewx.METRIC
else:
pkt['usUnits'] = weewx.US
pkt['hardware_id'] = m.group(1)
pkt['channel'] = m.group(2)
pkt['msg_type'] = m.group(3)
pkt['temperature'] = float(m.group(4))
pkt['humidity'] = float(m.group(6))
pkt['strikes_total'] = float(m.group(7))
pkt['distance'] = float(m.group(8))
else:
loginf("AcuriteLightningPacket: unrecognized data: %s" % lines[0])
lines.pop(0)
return Acurite.insert_ids(pkt, AcuriteLightningPacket.__name__)
class Acurite00275MPacket(Packet):
# {"time" : "2017-03-09 21:59:11", "model" : "00275rm", "probe" : 2, "id" : 3942, "battery" : "OK", "temperature_C" : 23.300, "humidity" : 34, "ptemperature_C" : 22.700, "crc" : "ok"}
# {"time" : "2017-03-09 21:59:11", "model" : "00275rm", "probe" : 2, "id" : 3942, "battery" : "OK", "temperature_C" : 23.300, "humidity" : 34, "temperature_1_C" : 22.700, "crc" : "ok"}
IDENTIFIER = "00275rm"
@staticmethod
def parse_json(obj):
pkt = dict()
pkt['dateTime'] = Packet.parse_time(obj.get('time'))
pkt['usUnits'] = weewx.METRIC
pkt['hardware_id'] = "%04x" % obj.get('id', 0)
pkt['probe'] = obj.get('probe')
pkt['battery'] = 0 if obj.get('battery') == 'OK' else 1
if 'temperature_1_C' in obj:
pkt['temperature_probe'] = Packet.get_float(obj, 'temperature_1_C')
else:
pkt['temperature_probe'] = Packet.get_float(obj, 'ptemperature_C')
pkt['temperature'] = Packet.get_float(obj, 'temperature_C')
pkt['humidity'] = Packet.get_float(obj, 'humidity')
return Acurite.insert_ids(pkt, Acurite00275MPacket.__name__)
class AcuriteWT450Packet(Packet):
# {"time" : "2017-09-14 20:24:43", "model" : "WT450 sensor", "id" : 1, "channel" : 2, "battery" : "OK", "temperature_C" : 25.090, "humidity" : 49}
# {"time" : "2017-09-14 20:24:44", "model" : "WT450 sensor", "id" : 1, "channel" : 2, "battery" : "OK", "temperature_C" : 25.110, "humidity" : 49}
# {"time" : "2017-09-14 20:24:44", "model" : "WT450 sensor", "id" : 1, "channel" : 2, "battery" : "OK", "temperature_C" : 25.120, "humidity" : 49}
IDENTIFIER = "WT450 sensor"
@staticmethod
def parse_json(obj):
pkt = dict()
pkt['dateTime'] = Packet.parse_time(obj.get('time'))
pkt['usUnits'] = weewx.METRIC
pkt['sid'] = Packet.get_int(obj, 'id')
pkt['channel'] = Packet.get_int(obj, 'channel')
pkt['battery'] = 0 if obj.get('battery') == 'OK' else 1
pkt['temperature'] = Packet.get_float(obj, 'temperature_C')
pkt['humidity'] = Packet.get_float(obj, 'humidity')
_id = "%s:%s" % (pkt['sid'], pkt['channel'])
return Packet.add_identifiers(pkt, _id, AcuriteWT450Packet.__name__)
class Acurite515Packet(Packet):
# refrigerator (XR) and freezer (XF) sensors
# X is one of A, B, or C
# "time" : "2022-01-21 21:55:54", "model" : "Acurite-515", "id" : 2375, "channel" : "BR", "battery_ok" : 1, "temperature_F" : 47.600, "mic" : "CHECKSUM"
# "time" : "2022-01-21 21:55:44", "model" : "Acurite-515", "id" : 78, "channel" : "BF", "battery_ok" : 1, "temperature_F" : 47.100, "mic" : "CHECKSUM"
IDENTIFIER = "Acurite-515"
@staticmethod