Location of C vs F Defaults?

I did some searches and I don’t think this has been covered. My sincere apologies if it has. Searching for “C” and “F” is somewhat non-filtering.

First let me take my lumps - I have practiced unsafe modifications, poor code management practices, and overall done bad things. Now that that is out of the way …

I have endeavored to change the default BrewPi configuration from C to F within the application. I have NOT kept track of what I’ve changed (I know … I know … ). All I know for sure that I have changed is the following lines in brewpi.py:

# Control Settings
cs = dict(mode='b', beerSet=70.0, fridgeSet=70.0, heatEstimator=0.2, coolEstimator=5)

# Control Constants
cc = dict(tempFormat="F", tempSetMin=33.0, tempSetMax=80.0, pidMax=10.0, Kp=20.000, Ki=0.600, Kd=-3.000, iMaxErr=0.500,
          idleRangeH=1.000, idleRangeL=-1.000, heatTargetH=0.301, heatTargetL=-0.199, coolTargetH=0.199,
          coolTargetL=-0.301, maxHeatTimeForEst="600", maxCoolTimeForEst="1200", fridgeFastFilt="1", fridgeSlowFilt="4",
          fridgeSlopeFilt="3", beerFastFilt="3", beerSlowFilt="5", beerSlopeFilt="4", lah=0, hs=0)

Is this the only place I’d need to change? I ask because I strongly suspect that this is not. For instance, when I view the maintenance panel the various temp set mode tabs, they still read C.

Is this critical? Obviously not. It does smack of American imperialism - thinking everyone should adopt American practices. :slight_smile: However I have a half-realized change that I did not fully document and failed to track my changes specific to this so I’d prefer not to roll back to a state that would make me lose other, unrelated changes. So, if anyone knows where else I need to look, that help would be appreciated greatly.

Okay I got a little further. I think a lot keys off the defaultSettings.json:

{"beerName": "Sample Data", "tempFormat": "F", "profileName": "Sample Profile", "dateTimeFormat": "yy-mm-dd", "dateTimeFormatDisplay": "mm/dd/yy" }

The only issue I see right now is that the “Fridge Constant” and “Beer Constant” values default to 20 (carrying over Centigrade). They only place I can see any ‘20’ that might be it is in pinList.py (and I don’t think this is it):

{'val': 20, 'text': 'A2', 'type': 'free'},

I did change the tempProfile.csv settings to be realistic based on this but I still think I’m missing something.

sorry if this is an obvious question, but why are you trying to change the defaults rather than just changing the setting that exists? And have you tried looking at the code-path for that setting?

And for what it’s worth :wink:

I did previously own up to both American Imperialism and having a half-realized attempt to change this. So, no matter what, I need to figure out where all it lives so I can either complete the change or revert it.

And yes I have attempted to trace the code path. I’ve listed what I found. I have to admit to both being now a leader in IT and not a contributor so this is a significant change from my day to day - and that the context switching between php, py and js is really messing with my head.

Anyway, like I said I seem to have more fully realized the change but I’m just wondering where that “20” comes from, because it doesn’t seem to be associated with anything (that I’ve found) indicating a default setting. I’m obviously wrong in that, but I’m having trouble finding it.

Having chewed on this a while I’m beginning to suspect that (obviously) nobody ever considered making this change and testing the impact of actually changing the defaults. I’d hoped that someone had done it previously and/or was familiar with it, I’m still hoping that happens. Right now I’m playing whak-a-mole with the bugs I’ve created, which is fun (for a while.)

Any reason you cannot do a git diff or reset?
I am not proud of the design and in quite a lot of places it shows that I was unexperienced when I designed it.

It you have a BrewPi Spark, I wouldn’t even bother and upgrade to our new brewblox stack next week. I am proud of that architecture :slight_smile:

Because we were working on something new all that time, we didn’t bother getting the existing stack up to our new standards.

Elco, going back and looking at old code is like looking at store specials after you buy a new laptop. Just don’t do it. :slight_smile:

I’ve changed quite a lot about the scripts at this point so digging through the changes I made looking for the ones I screwed up would be more time consuming that pushing forward - or so I think at this point. I wonder though: I saw a note about “internals” doing temp calculations in C and then converting. Is it possible there’s a controller setting that I need to set to F as default before my crazy scheme will work?

This WHOLE thing came out of trying to help a (non-computer literate) friend recover after his Pi ate his SD card. It started simply as making it a little easier for him to install and then it just snowballed from there. There is NO good reason, no payback, for all the hours I have in this. It just makes me happy to tinker. I’ve not been an individual contributor for along time so whenever I get a chance to dip my toe in DOING technology, I jump at it. It keeps me relevant I think.

To tell a secret: I don’t even get a chance to brew anymore things are so busy at work. :pleading_face:

Calculations are in Celsius on the controller and are converted when serialized.
The setting changes the toString and fromString handlers (on the controller).

Gotcha. Thanks Elco.

It’s passable now. The beer and fridge constants are still defaulting to 20.0 despite being in F mode. One of these days I’l debug a little more.

I thought I’d close the loop a little here. This ended up not only impacting my parochial view of the world and playing with F as a default - but also failing in the display when I change to F “the right way.” In this section in js/control-panel.js:

function defaultTemp(){
    "use strict";
    if(typeof(window.tempFormat) === 'F'){
		return 68.0;

I ended up changing to:

function defaultTemp(){
	"use strict";
	if(window.tempFormat == 'F'){
		return 68.0;

Basically, it seemed like when it received the JSON with the temp format it went through all the right places but this part failed. I am supposing that comparing window.tempFormat as a type somehow was invalid here.

At any rate, it works now as a string compare.

Ah yes, JavaScript is weird. === Means type and value are the same. And apparently a 1 character string and a character are not the same.

Yes, and depending on the editor you are using (and how old your eyes are) the == and === look exactly the same.

My hat is off to you sir, for being able to keep bash and python and php and js and css and C++ all straight. It hurts my head.


As long as I an closing the loop on this one, this is a related change. In brewpi.py:

elif line[0] == 'C':
	# Control constants received
	cc = json.loads(line[2:])


elif line[0] == 'C':
	# Control constants received
	cc = json.loads(line[2:])
	# Update the json with the right temp format for the web page
	if 'tempFormat' in cc:
		changeWwwSetting('tempFormat', cc['tempFormat'])

What happens is, and I’m probably one of the few to keep reinstalling BrewPi over and over again, if you have a controller talking in “F” and a new install, the web json never gets updated with the temp format. So, I had to add that bit to make it all right.