diff options
author | pks <pks@pks.rocks> | 2021-05-10 13:23:21 +0200 |
---|---|---|
committer | pks <pks@pks.rocks> | 2021-05-10 13:23:21 +0200 |
commit | 281fa36a24f81d87543a7791252954414e161565 (patch) | |
tree | ab45e491aa93924f7310303913f2df2d3f3b069f /v1/receive.py | |
parent | 69e11599c2194187e1c172ebe6b7b51945a7f306 (diff) |
rm v0 v1
Diffstat (limited to 'v1/receive.py')
-rwxr-xr-x | v1/receive.py | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/v1/receive.py b/v1/receive.py deleted file mode 100755 index 71d0a67..0000000 --- a/v1/receive.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python3 - -from RFXtrx import PySerialTransport -import sys, datetime, os - - -if __name__ == "__main__": - transport = PySerialTransport('/dev/ttyUSB0') - transport.reset() - - while True: - if os.path.isfile('/home/pks/weather/stop'): - break - - recv = transport.receive_blocking() - - if not recv: - continue - - timestamp = datetime.datetime.timestamp(datetime.datetime.now()) - - sys.stderr.write("Raw: %s\n"%str(recv)) - - try: - device_id = recv.device.id_string - device_type = recv.device.type_string - except Exception as e: - sys.stderr.write("Cannot find device id, exception %s." % str(e)) - continue - - data = {} - for k,v in recv.values.items(): - data[k.lower().replace(" ", "_")] = v - - data_type = None - if "rain_rate" in data: - data_type = "rain" - elif "wind_gust" in data: - data_type = "wind" - elif "temperature" in data: - data_type = "temp" - else: - sys.stderr.write("Unknown device '%s' with id '%s', ignoring.\n"%(device_type, device_id)) - continue - - - out = [ "type::%s" % data_type, - "timestamp::%f" % timestamp, - "device_type::%s" % device_type, - "device_id::%s" % device_id ] - - for key in sorted(data.keys()): - out.append("%s::%s" % (key, data[key])) - - print("\t".join(out)) - sys.stderr.flush() - sys.stdout.flush() - - -sys.stderr.write("stop\n") -sys.stdout.flush() |