1
1
#!/usr/bin/env python
2
- # Copyright 2016 Matthew Wall, all rights reserved
2
+ # Copyright 2016 Matthew Wall
3
+ # Distributed under the terms of the GNU Public License (GPLv3)
3
4
"""
4
5
Collect data from stl-sdr. Run rtl_433 on a thread and push the output onto
5
6
a queue.
83
84
84
85
85
86
DRIVER_NAME = 'SDR'
86
- DRIVER_VERSION = '0.12 '
87
+ DRIVER_VERSION = '0.13 '
87
88
88
89
# -q - suppress non-data messages
89
90
# -U - print timestamps in UTC
@@ -286,6 +287,15 @@ def add_identifiers(pkt, sensor_id='', packet_type=''):
286
287
class AcuriteTowerPacket (Packet ):
287
288
# 2016-08-30 23:57:20 Acurite tower sensor 0x37FC Ch A: 26.7 C 80.1 F 16 % RH
288
289
290
+ # 2017-01-12 02:55:10 : Acurite tower sensor : 12391 : B
291
+ # Temperature: 18.0 C
292
+ # Humidity: 68
293
+ # Battery: 0
294
+ # : 68
295
+
296
+ # {"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}
297
+ # {"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}
298
+
289
299
IDENTIFIER = "Acurite tower sensor"
290
300
PATTERN = re .compile ('0x([0-9a-fA-F]+) Ch ([A-C]): ([\d.-]+) C ([\d.-]+) F ([\d]+) % RH' )
291
301
@@ -307,6 +317,19 @@ def parse_text(ts, payload, lines):
307
317
loginf ("AcuriteTowerPacket: unrecognized data: '%s'" % lines [0 ])
308
318
return pkt
309
319
320
+ @staticmethod
321
+ def parse_json (obj ):
322
+ pkt = dict ()
323
+ pkt ['dateTime' ] = Packet .parse_time (obj .get ('time' ))
324
+ pkt ['usUnits' ] = weewx .METRIC
325
+ hardware_id = "%04x" % obj .get ('id' , 0 )
326
+ pkt ['temperature' ] = Packet .get_float (obj , 'temperature_C' )
327
+ pkt ['humidity' ] = Packet .get_float (obj , 'humidity' )
328
+ pkt ['battery' ] = 0 if obj .get ('battery' ) == 0 else 1
329
+ pkt ['status' ] = obj .get ('status' )
330
+ return Packet .add_identifiers (
331
+ pkt , hardware_id , AcuriteTowerPacket .__name__ )
332
+
310
333
311
334
class Acurite5n1Packet (Packet ):
312
335
# 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
0 commit comments