Skip to content

Commit dc44bf3

Browse files
committed
support json format for tower sensors
1 parent 248a801 commit dc44bf3

File tree

4 files changed

+652
-4
lines changed

4 files changed

+652
-4
lines changed

bin/user/sdr.py

+25-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/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)
34
"""
45
Collect data from stl-sdr. Run rtl_433 on a thread and push the output onto
56
a queue.
@@ -83,7 +84,7 @@
8384

8485

8586
DRIVER_NAME = 'SDR'
86-
DRIVER_VERSION = '0.12'
87+
DRIVER_VERSION = '0.13'
8788

8889
# -q - suppress non-data messages
8990
# -U - print timestamps in UTC
@@ -286,6 +287,15 @@ def add_identifiers(pkt, sensor_id='', packet_type=''):
286287
class AcuriteTowerPacket(Packet):
287288
# 2016-08-30 23:57:20 Acurite tower sensor 0x37FC Ch A: 26.7 C 80.1 F 16 % RH
288289

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+
289299
IDENTIFIER = "Acurite tower sensor"
290300
PATTERN = re.compile('0x([0-9a-fA-F]+) Ch ([A-C]): ([\d.-]+) C ([\d.-]+) F ([\d]+) % RH')
291301

@@ -307,6 +317,19 @@ def parse_text(ts, payload, lines):
307317
loginf("AcuriteTowerPacket: unrecognized data: '%s'" % lines[0])
308318
return pkt
309319

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+
310333

311334
class Acurite5n1Packet(Packet):
312335
# 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

changelog

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
0.13 11jan2016
2+
* deal with changes to acurite decoder in rtl-433 - use json now
3+
14
0.12 03nov2016
25
* added option to enumerate supported sensors
36
* added support for OS WGR800 and PCR800 sensors

install.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# installer for the weewx-sdr driver
2-
# Copyright 2016 Matthew Wall, all rights reserved
2+
# Copyright 2016 Matthew Wall
3+
# Distributed under the terms of the GNU Public License (GPLv3)
34

45
from setup import ExtensionInstaller
56

@@ -9,7 +10,7 @@ def loader():
910
class SDRInstaller(ExtensionInstaller):
1011
def __init__(self):
1112
super(SDRInstaller, self).__init__(
12-
version="0.12",
13+
version="0.13",
1314
name='sdr',
1415
description='Capture data from rtl_433',
1516
author="Matthew Wall",

0 commit comments

Comments
 (0)