API - Temp Setpoint - can it be made r/w?

Things to come.
Post Reply
erichter66
Posts: 5
Joined: Thu Oct 01, 2015 4:32 pm
Bot?: No

API - Temp Setpoint - can it be made r/w?

Post by erichter66 »

I am working on an HMI using the API library. The temp setpoint is currently read only. Is there a way to write to it using the APIs? If not, is there a way to write it to an internal variable that I can later move to the temp.setpoint using the BCS logic?

Thanks,

EdR
JonW
Site Admin
Posts: 1726
Joined: Sun Jul 18, 2010 7:51 am
Bot?: No
Location: Huntington Beach, CA
Contact:

Re: API - Temp Setpoint - can it be made r/w?

Post by JonW »

Yes, you can use the API to change your setpoints. If you're looking at the API for /temp/{probe}, yes, the setpoint there is read-only. The reason for this is that when viewing a setpoint at any given time, the setpoint value could have been set from any process/state - e.g. 64 different places could have asserted that setpoint.

You need to set the actual setpoint from within the specified process/state/output that is currently asserting the setpoint value.
/process/{process_id}/state/{state_id}/output_controllers

Since multiple process/state/outputs could actually be using the same temp probe, you also need to ensure you write back to the highest priority process/state/output. Also know that changing a setpoint changes it in your current process/state/output configuration. e.g. just as if you had edited that state to utilize a new setpoint.

Yes, changing a setpoint is a PIA. We are looking at adding a new API function that would return the current process/state/output that is actively associated with temp probe setpoint. That would give you a shortcut to not needing to scan through process/state/outputs to find who is controlling it.

Here is a related post about setpoints & duty cycle: http://forum.embeddedcc.com/viewtopic.p ... 754#p10174
erichter66
Posts: 5
Joined: Thu Oct 01, 2015 4:32 pm
Bot?: No

Re: API - Temp Setpoint - can it be made r/w?

Post by erichter66 »

Thanks for the quick reply Jon. If I may make a suggestion, code samples on how to use the API calls would help a lot. I think the biggest time consumer for me has been trying to figure out the exact syntax.

I am working in Python 3.4. So far I am reading all IO once/sec, planning to log it to a CSV file. I am also planning to log the recipe, brewer's notes and events as the brew progresses. The idea is to eventually be able to compare the brewday to the recipe and to other times when the same recipe was brewed. Also to maintain temperature automatically and to get alarms when a certain phase reaches it's time setpoint. We are usually pretty plastered by the end of the brewday and our concentration is slipping.
JonW
Site Admin
Posts: 1726
Joined: Sun Jul 18, 2010 7:51 am
Bot?: No
Location: Huntington Beach, CA
Contact:

Re: API - Temp Setpoint - can it be made r/w?

Post by JonW »

Are you referencing the API docs? http://www.embeddedcc.com/api-docs/#!/process The sample structures and syntax are all detailed there. The /api/poll request is the only one not outlined in the docs, but it should be pretty self explanatory.

If you set a hostname of bcs in your localhost file to that of your BCS IP address, the API docs will let you test query and update against your live BCS.
erichter66
Posts: 5
Joined: Thu Oct 01, 2015 4:32 pm
Bot?: No

Re: API - Temp Setpoint - can it be made r/w?

Post by erichter66 »

yes, we did that and we are using the "Try it out" buttons. Very helpful. We had an issue with the string types. We had some trouble before we figured out that we need to use the utf-8 decode when logging and encode before we post the command to toggle the pump DO. - actually, we took some detours along the way, but it is pretty short piece of code now that we are done.
brahn
Posts: 543
Joined: Thu Dec 13, 2012 11:01 am
Bot?: No

Re: API - Temp Setpoint - can it be made r/w?

Post by brahn »

Python's a little funky with string encoding sometimes.

For code samples dealing with the BCS you can check my GitHub: https://github.com/lawn-chair/

Most of it's in JavaScript mainly for portability reasons, but the basics of working with the API should be similar. The new Finder is written in Python, but it doesn't interact with the API.
erichter66
Posts: 5
Joined: Thu Oct 01, 2015 4:32 pm
Bot?: No

Re: API - Temp Setpoint - can it be made r/w?

Post by erichter66 »

I just downloaded the trial vesion of beer smith and I realized that it has lot of what I am trying to accomplish - specifically, providing alarms during the brewday to remind of hops additions, when it is time to change temperature etc. All that is missing is the actual historical record of the brewday along with some brewer's notes.

Have you talked with Brad about integrating the BCS with the BrewSmith software? It would probably help sell the BCS.
Post Reply