Skip to main content

Brewfather

What

Calling all brewers! Keep up-to-date with the status of your Brewfather batch directly in your commandline prompt using the brewfather segment!

You will need your User ID and API Key as generated in Brewfather's Settings screen, enabled with batches.read and recipes.read scopes.

Sample Configuration

This example uses the default segment template to show a rendition of detail appropriate to the status of the batch

Additionally, the background of the segment will turn red if the latest reading is over 4 hours old - possibly helping indicate an issue if, for example there is a Tilt or similar device that is supposed to be logging to Brewfather every 15 minutes.

info

Temperature units are in degrees C and specific gravity is expressed as X.XXX values.

{
"type": "brewfather",
"style": "powerline",
"powerline_symbol": "",
"foreground": "#ffffff",
"background": "#33158A",
"background_templates": [
"{{ if and (.Reading) (eq .Status \"Fermenting\") (gt .ReadingAge 4) }}#cc1515{{end}}"
],
"properties": {
"user_id": "abcdefg123456",
"api_key": "qrstuvw78910",
"batch_id": "hijklmno098765"
}
}

Properties

NameTypeDefaultDescription
user_idstringas provided by Brewfather's Generate API Key screen
api_keystringas provided by Brewfather's Generate API Key screen
batch_idstringGet this by navigating to the desired batch on the brewfather website, the batch id is at the end of the URL in the address bar
http_timeoutint2in milliseconds - How long to wait for the Brewfather service to answer the request
day_iconstringdicon or letter to use to indicate days

Icons

You can override the icons for temperature trend as used by template property .TemperatureTrendIcon with:

NameDescription
doubleup_iconfor increases of more than 4°C, default is ↑↑
singleup_iconincrease 2-4°C, default is
fortyfiveup_iconincrease 0.5-2°C, default is
flat_iconchange less than 0.5°C, default is
fortyfivedown_icondecrease 0.5-2°C, default is
singledown_icondecrease 2-4°C, default is
doubledown_icondecrease more than 4°C, default is ↓↓

You can override the default icons for batch status as used by template property .StatusIcon with:

Name
planning_status_icon
brewing_status_icon
fermenting_status_icon
conditioning_status_icon
completed_status_icon
archived_status_icon

Template (info)

default template
{{ .StatusIcon }} {{ if .DaysBottledOrFermented }}{{ .DaysBottledOrFermented }}{{ .DayIcon }} {{ end }}{{ url .Recipe.Name .URL }} {{ printf \"%.1f\" .MeasuredAbv }}%{{ if and (.Reading) (eq .Status \"Fermenting\") }} {{ printf \"%.3f\" .Reading.Gravity }} {{ .Reading.Temperature }}\u00b0 {{ .TemperatureTrendIcon }}{{ end }}

Properties

NameTypeDescription
.StatusstringOne of "Planning", "Brewing", "Fermenting", "Conditioning", "Completed" or "Archived"
.StatusIconstringIcon representing above stats. Can be overridden with properties shown above
.TemperatureTrendIconstringIcon showing temperature trend based on latest and previous reading
.DaysFermentingintdays since start of fermentation
.DaysBottledintdays since bottled/kegged
.DaysBottledOrFermentedintone of the above, chosen automatically based on batch status
.Recipe.NamestringThe recipe being brewed in this batch
.BatchNamestringThe name of this batch
.BatchNumerintThe number of this batch
.MeasuredAbvfloatThe ABV for the batch - either estimated from recipe or calculated from entered OG and FG values
.ReadingAgeintage in hours of most recent reading or -1 if there are no readings available

Reading

.Reading contains the most recent data from devices or manual entry as visible on the Brewfather's batch Readings graph. If there are no readings available, .Reading will be null.

NameTypeDescription
.Reading.Gravityfloatspecific gravity (in decimal point format)
.Reading.Temperaturefloattemperature in °C
.Reading.Timeintunix timestamp of reading
.Reading.Commentstringcomment attached to this reading
.Reading.DeviceTypestringsource of the reading, e.g. "Tilt"
.Reading.DeviceIDstringid of the device, e.g. "PINK"

Additional properties

NameTypeDescription
.MeasuredOgfloatThe OG for the batch as manually entered into Brewfather
.MeasuredFgfloatThe FG for the batch as manually entered into Brewfather
.BrewDateintThe unix timestamp of the brew day
.FermentStartDateintThe unix timestamp when fermentation was started
.BottlingDatetimeThe unix timestamp when bottled/kegged
.TemperatureTrendfloatThe difference between the most recent and previous temperature in °C
.DayIconstringgiven by "day_icon", or "d" by default
NameTypeDescription
.URLstringthe URL for the batch in the Brewfather app. You can use this to add a hyperlink to the segment if you are using a terminal that supports it. The default template implements this

Advanced Templating

The built in template will provides key useful information. However, you can use the properties about the batch to build your own. For reference, the built-in template looks like this:

{
"template": "{{.StatusIcon}} {{if .DaysBottledOrFermented}}{{.DaysBottledOrFermented}}{{.DayIcon}} {{end}}[{{.Recipe.Name}}]({{.URL}}) {{printf \"%.1f\" .MeasuredAbv}}%{{ if and (.Reading) (eq .Status \"Fermenting\")}}: {{printf \"%.3f\" .Reading.Gravity}} {{.Reading.Temperature}}° {{.TemperatureTrendIcon}}{{end}}"
}

Unit conversion

By default temperature readings are provided in degrees C, gravity readings in decimal Specific Gravity unts (X.XXX).

The following conversion functions are available to the template to convert to other units:

Temperature

NameDescription
DegCToFinput: float degrees in C; output float degrees in F (1 decimal place)
DegCToKelvininput: float degrees in C; output float Kelvin (1 decimal place)

Gravity

NameDescription
SGToBrixinput float SG in x.xxx decimal; output float Brix (2 decimal places)
SGToPlatoinput float SG in x.xxx decimal; output float Plato (2 decimal places)

(These use the polynomial conversions from Wikipedia)

Example

{
"template": "{{if .Reading}}{{.SGToBrix .Reading.Gravity}}°Bx, {{.DegCToF .Reading.Temperature}}°F{{end}}"
}

To display gravity as SG in XXXX format (e.g. "1020" instead of "1.020"), use the mulf template function

{
"template": "{{if .Reading}}{{.mulf 1000 .Reading.Gravity}}, {{.DegCToF .Reading.Temperature}}°F{{end}}"
}