Created
January 23, 2019 17:03
-
-
Save dk2ro/6e116072e056e0d324b96cebe7723731 to your computer and use it in GitHub Desktop.
Quick and dirty script for plotting the JSON output of rtl_433
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pylab import * | |
from drawnow import drawnow, figure | |
import random | |
import time | |
import fileinput | |
import json | |
import datetime | |
sensors = [] | |
values = {} | |
def draw_fig(): | |
for s in sensors: | |
vals = values[s] | |
plot_date(vals["time"],vals["val"],".-") | |
legend(sensors) | |
for line in fileinput.input(): | |
vals = json.loads(line) | |
if "temperature_C" not in vals: | |
continue | |
t = datetime.datetime.fromisoformat(vals["time"]) | |
mid = vals["model"]+" "+str(vals["id"]) | |
if "channel" in vals: | |
mid += "_"+str(vals["channel"]) | |
if "rid" in vals: | |
mid += "_"+str(vals["rid"]) | |
if mid not in sensors: | |
sensors.append(mid) | |
values[mid]={"time":[],"val":[]} | |
values[mid]["time"].append(t) | |
values[mid]["val"].append(vals["temperature_C"]) | |
#print(values) | |
drawnow(draw_fig) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment