I have a python script running to output room temperatures from my Evohome heating system to a Plotly graph, which works beautifully using the following code:
# We make a plot for every room for device in client.temperatures(): stream_id = Config.get('Rooms', device['id']) stream = Stream(token=stream_id, maxpoints=288 ) trace1 = Scatter( x=, y=, mode='lines+markers', line=Line( shape='spline' ), stream = stream ) data = Data([trace1]) layout = Layout(title=device['name']) fig = Figure(data=data, layout=layout) py.plot(fig, filename=device['name'], fileopt='extend') # Infinite loop every 5 minutes, send temperatures to plotly while True: # Get current time and then send all thermostat readings to plotly try: client = EvohomeClient(USERNAME, PASSWORD) from datetime import datetime j=0 for device in client.temperatures(): stream_id = Config.get('Rooms', device['id']) j+=1 s = py.Stream(stream_id) s.open() tijd = datetime.now().strftime('%Y-%m-%d %H:%M') temperatuur = float(device['temp']) print tijd + " : " + device['name'] + " " + str(temperatuur) s.write(dict(x=tijd ,y=temperatuur)) s.close() print "Going to sleep for 5 minutes" time.sleep(300) except Exception, e: print "An error occured! Trying again in 15 seconds" print str(e) time.sleep(15)
As you can see, the existing trace is plotting “device[‘temp’]”. I’d like to add a second trace to the same axes which plots "device[‘setpoint’]. The code to extract the information from the Honeywell servers is working fine, I just can’t get the code to add another trace to the Plotly graphs.
Struggling to get it to work, any help appreciated!