matthewwall / weewx-sdr

weewx driver for software-defined radio
GNU General Public License v3.0
115 stars 74 forks source link

Update RTL_433 chanded HIDEKI TS04 #78

Closed michael-weewx closed 3 years ago

michael-weewx commented 4 years ago

i have used rtl_433 in version 19.08 so far. the output of:

sudo PYTHONPATH=/home/weewx/bin python /home/weewx/bin/user/sdr.py --cmd="rtl_433 -M utc -F json -G"

out: ['{"time" : "2020-03-22 12:49:29", "model" : "HIDEKI TS04 sensor", "rc" : 10, "channel" : 2, "battery" : "OK", "temperature_C" : 20.100, "humidity" : 39, "mic" : "CRC"}\n', '{"time" : "2020-03-22 12:49:29", "model" : "HIDEKI TS04 sensor", "rc" : 10, "channel" : 2, "battery" : "OK", "temperature_C" : 20.100, "humidity" : 39, "mic" : "CRC"}\n']

after I have updated to version 20.02, brings the following on my further weewx installation

sudo PYTHONPATH=/home/weewx/bin python3 /home/weewx/bin/user/sdr.py --cmd="rtl_433 -M utc -F json"

out:['{"time" : "2020-03-22 12:51:28", "model" : "Hideki-TS04", "id" : 14, "channel" : 3, "battery_ok" : 1, "temperature_C" : 21.500, "humidity" : 49, "mic" : "CRC"}\n',

i have changed HidekiTS04Packet in sdr.py as follows:

class HidekiTS04Packet(Packet):

2016-08-31 17:41:30 : HIDEKI TS04 sensor

# Rolling Code: 9
# Channel: 1
# Battery: OK
# Temperature: 27.30 C
# Humidity: 60 %

# {"time" : "2016-11-04 14:44:37", "model" : "HIDEKI TS04 sensor", "rc" : 9, "channel" : 1, "battery" : "OK", "temperature_C" : 12.400, "humidity" : 61}
# {"time" : "2020-03-21 18:41:31", "model" : "Hideki-TS04",           "id" : 13, "channel" : 4, "battery_ok" : 1, "temperature_C" : 23.100, "humidity" : 42, "mic" : "CRC"}#012'
IDENTIFIER = "Hideki-TS04"

@staticmethod
def parse_text(ts, payload, lines):
    pkt = dict()
    pkt['dateTime'] = ts
    pkt['usUnits'] = weewx.METRIC
    pkt.update(Packet.parse_lines(lines, HidekiTS04Packet.PARSEINFO))
    return Hideki.insert_ids(pkt, HidekiTS04Packet.__name__)

@staticmethod
def parse_json(obj):
    pkt = dict()
    pkt['dateTime'] = Packet.parse_time(obj.get('time'))
    pkt['usUnits'] = weewx.METRIC
    pkt['rolling_code'] = obj.get('id')
    pkt['channel'] = obj.get('channel')
    pkt['temperature'] = Packet.get_float(obj, 'temperature_C')
    pkt['humidity'] = Packet.get_float(obj, 'humidity')
    pkt['battery'] = 0 if obj.get('battery_ok') == '1' else 1
    return Hideki.insert_ids(pkt, HidekiTS04Packet.__name__)
matthewwall commented 3 years ago

changes rolled into pending release 26oct2021