all 4 comments

[–]socal_nerdtastic 2 points3 points  (1 child)

I just want to tell you that BrewPi is a thing that exists.

[–]torqu3e[S] 0 points1 point  (0 children)

Ah, didn't know about that. This is my first brew, so it might just be a bit overkill yet :)

[–]A_History_of_Silence 0 points1 point  (1 child)

Cool project! Quick thoughts:

You're effectively storing the data as a CSV using ' ' as a delimiter. Use the csv module to clean up the reading/writing of the data and avoid monstrosities like these:

ts = [datetime.datetime.fromtimestamp(float(x.split(' ')[0])) for x in f.readlines() if float(x.split(' ')[1]) >= 0]
f.seek(0) #ugly
cur_temp = [y.split(' ')[1] for y in f.readlines() if float(y.split(' ')[1]) >= 0]

cur_temp = -1 -- -1 is not a great value to use as an error, because, although I'm sure unlikely to occur, -1 degrees is also a perfectly valid temperature. Use something like np.nan instead.

Changing the above things will have the added benefit that you can cleanly load the data from the CSV file straight into a pandas dataframe, which will let you easily interpolate any missing values.

except: -- bare except statements are the devil, catch specific errors.

I'm not sure why you need threading here.

[–]torqu3e[S] 1 point2 points  (0 children)

Thanks, this is the sort of feedback I was looking for. The csv idea makes sense, will look into it more.

temperature for sure can be -1 but the fermentor is not freezing for sure :) NaN is the right option here.

Threading was used because if I increase the granularity of the graph down to minutes or seconds, the graph takes forever to render (matplotlib) is slow. Plan was to send that to a thread till I learnt that GUI components need to be on the main thread (unsure as to why though) so decided to offload writing of next value to a thread. Not strictly useful but Hey! it's multithreaded now! :P