summaryrefslogtreecommitdiff
path: root/receive.py
diff options
context:
space:
mode:
authorpks <pks@pks.rocks>2021-05-01 06:17:55 +0200
committerpks <pks@pks.rocks>2021-05-01 06:17:55 +0200
commitf461190e22a97bde985b067ce01c4ed9c74f7e62 (patch)
tree0c2c48d1933765f83d083241df2dd74c6603f2bc /receive.py
parent63fbf0f3aadb4b6d037a8164b501fe836d9c361d (diff)
v1
Diffstat (limited to 'receive.py')
-rwxr-xr-xreceive.py61
1 files changed, 0 insertions, 61 deletions
diff --git a/receive.py b/receive.py
deleted file mode 100755
index 71d0a67..0000000
--- a/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()