Skip to content

Commit

Permalink
support json format for tower sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewwall committed Jan 12, 2017
1 parent 248a801 commit dc44bf3
Show file tree
Hide file tree
Showing 4 changed files with 652 additions and 4 deletions.
27 changes: 25 additions & 2 deletions bin/user/sdr.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python
# Copyright 2016 Matthew Wall, all rights reserved
# Copyright 2016 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.
Expand Down Expand Up @@ -83,7 +84,7 @@


DRIVER_NAME = 'SDR'
DRIVER_VERSION = '0.12'
DRIVER_VERSION = '0.13'

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

# 2017-01-12 02:55:10 : Acurite tower sensor : 12391 : B
# Temperature: 18.0 C
# Humidity: 68
# Battery: 0
# : 68

# {"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}

IDENTIFIER = "Acurite tower sensor"
PATTERN = re.compile('0x([0-9a-fA-F]+) Ch ([A-C]): ([\d.-]+) C ([\d.-]+) F ([\d]+) % RH')

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

@staticmethod
def parse_json(obj):
pkt = dict()
pkt['dateTime'] = Packet.parse_time(obj.get('time'))
pkt['usUnits'] = weewx.METRIC
hardware_id = "%04x" % obj.get('id', 0)
pkt['temperature'] = Packet.get_float(obj, 'temperature_C')
pkt['humidity'] = Packet.get_float(obj, 'humidity')
pkt['battery'] = 0 if obj.get('battery') == 0 else 1
pkt['status'] = obj.get('status')
return Packet.add_identifiers(
pkt, hardware_id, 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
Expand Down
3 changes: 3 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
0.13 11jan2016
* deal with changes to acurite decoder in rtl-433 - use json now

0.12 03nov2016
* added option to enumerate supported sensors
* added support for OS WGR800 and PCR800 sensors
Expand Down
5 changes: 3 additions & 2 deletions install.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# installer for the weewx-sdr driver
# Copyright 2016 Matthew Wall, all rights reserved
# Copyright 2016 Matthew Wall
# Distributed under the terms of the GNU Public License (GPLv3)

from setup import ExtensionInstaller

Expand All @@ -9,7 +10,7 @@ def loader():
class SDRInstaller(ExtensionInstaller):
def __init__(self):
super(SDRInstaller, self).__init__(
version="0.12",
version="0.13",
name='sdr',
description='Capture data from rtl_433',
author="Matthew Wall",
Expand Down
Loading

0 comments on commit dc44bf3

Please sign in to comment.