Forum

Posting temp readin...
 

Posting temp readings via json and setting current ferment target temperature?  

  RSS

(@angus_grant)
Eminent Member
Joined: 10 months ago
Posts: 46
February 4, 2019 2:50 am  

Hi,

I have been building a plug-in for CraftBeerPi which integrates with my website brewerschronicle.com. Temp readings are posted from CraftBeerPi to my website api via json post, and a target ferment temperature is posted back to plug-in via post return value. The current target ferment temperature is calculated by a ferment schedule entered into my website, either by days into the ferment. You can also define the temperature schedule by gravity readings posted via api from Tilt or iSpindel hydrometer devices.

This is all working well and I am just finishing off on my first ferment now. Unfortunately due to license restrictions CraftBeerPi is not usable in a commercial environment. I am working with a brewer here in Brisbane to replace his current brewery control software.

Someone in the CBPi Facebook group mentioned BruControl, and it looks very promising. Is it possible to post temp readings via json?
It is possible to set the ferment temperature from a json request?

I have had a brief look through the scripts, but haven't managed to find an answer yet.

Thanks,
Angus.


Quote
(@angus_grant)
Eminent Member
Joined: 10 months ago
Posts: 46
February 6, 2019 12:36 pm  

Well while I was waiting for approval, I started reading through the 45 pages on the BrewTalk thread. One of BrunDog's posts talk about logs for all sensors being available as csv files.

So I could write a Windows service with a file watcher to grab values from the relevant log and upload to my website. The one problem I see is associating a BruControl csv file with a ferment log in my website. I'm not sure if the log file could include the GUID from my website somehow so I could associate them?

Is the target value for a ferment saved out to a log file or setting file somewhere? Perhaps my Windows service could update that file as well?

I'm waiting on all the parts to turn up so I can start building the ferment control system to provide to a local micro-brewery. I'm pretty excited about the possibilities, both with the BruControl software and also personally.

Cheers,
Angus.


ReplyQuote
(@pbruno3)
Estimable Member Admin
Joined: 3 years ago
Posts: 246
February 7, 2019 5:22 am  

Hi. You could pull the data off the data files via a file watcher, as you mentioned. But I think we need to create a pathway to pass information back and forth to third party sources. We have it on the docket so will look to accelerate it.  We’ll discuss possible mechanisms to do this and build something  ASAP. 


ReplyQuote
(@angus_grant)
Eminent Member
Joined: 10 months ago
Posts: 46
February 7, 2019 10:08 am  

That's good news.

I've pasted some php below which shows the use of the requests module in my CraftBeerPi plugin. It would be awesome if something along the same lines was available in BruControl

bc_uri = " https://api.brewerschronicle.com/api/readings/cbpi "
....
....
....
/* Code to submit current temp via API to my website */
ferment_id = components[1]
temp = fermenter.instance.get_temp()
unit = cbpi.get_config_parameter("unit", "C")
data = {"api_key": api_key, "ferment_id": ferment_id, "temperature": temp, "temp_unit": unit}
logBC("Temperature post payload: {0}".format(data))
response = requests.post(bc_uri, json=data)

/*
My website calculates current ferment target temperature based on a ferment schedule and either days into ferment or gravity readings submitted via Tilt or iSpindel hydrometers
This following section posts the target temp to the CraftBeerPi API.
*/
data = response.json()
set_temp = data['set_temp']
temp_api_url = "http://localhost:5000/api/fermenter/{0}/targettemp/{1}".format(fermenter.id, set_temp)
headers = {'content-type': 'application/json'}
logBC(temp_api_url)
requests.post(temp_api_url, data="", headers = headers, timeout = 1)

This post was modified 10 months ago by Angus

ReplyQuote
(@angus_grant)
Eminent Member
Joined: 10 months ago
Posts: 46
February 7, 2019 9:17 pm  

I had a sudden thought this morning: you could include vb.net scripts into BruControl and compile them up. That would be the ultimate solution.

I haven't actually done this before so can't really provide any quality links or samples, but here is a couple of quick links

http://www.drdobbs.com/add-vbnet-scripting-to-net-apps/184416634
https://support.microsoft.com/en-au/help/304654/how-to-programmatically-compile-code-by-using-the-visual-basic-net-or

That way, my script could do the posting to my API. It would need to hande passing values in from BruControl and reading values back into BruControl.


ReplyQuote
(@pbruno3)
Estimable Member Admin
Joined: 3 years ago
Posts: 246
February 8, 2019 3:04 am  

Thanks for the tip. I have seen this in some home automation software. Not sure the level of risk/reliability, but we'll discuss it.


ReplyQuote
Share: