Forum

Posting temp readin...
 
Notifications
Clear all

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

6 Posts
2 Users
0 Likes
5,111 Views
(@angus_grant)
Trusted Member
Joined: 5 years ago
Posts: 52
Topic starter  

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)
Trusted Member
Joined: 5 years ago
Posts: 52
Topic starter  

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)
Reputable Member Admin
Joined: 7 years ago
Posts: 343
 

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)
Trusted Member
Joined: 5 years ago
Posts: 52
Topic starter  

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)


   
ReplyQuote
(@angus_grant)
Trusted Member
Joined: 5 years ago
Posts: 52
Topic starter  

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)
Reputable Member Admin
Joined: 7 years ago
Posts: 343
 

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: