-
Notifications
You must be signed in to change notification settings - Fork 1
Config
The Config object is responsible for basic CraftBeerPi system configuration via properties--things like your brewery name, temperature units, port number, etc.
| Method | Param | Return Type | Description |
|---|---|---|---|
getConfig |
n/a | Promise | Fetches a list of all available configuration properties CraftBeerPi exposes. |
onUpdate |
Function | Unsubscribe function | A way to register for updates to any of the configuration properties. |
This is Swill's best estimation of what each configurable property does.
| Property | Value Range | Description |
|---|---|---|
actor_cols |
[1-12] |
The width of an actor widget on the brewing dashboard. |
| `brew_name | * |
The name of the current brew. |
brewery_name |
* |
The name of the brewery. |
buzzer |
[0-27] |
The buzzer GPIO pin. |
buzzer_beep_level |
HIGH|LOW |
The beeping level for the buzzer. |
donation_notification |
YES|NO |
Whether or not to enable the repeated donation notification. |
kettle_cols |
[1-10] |
The width of the kettle widget on brewing dashboard. |
port |
[0-9999] |
The port to serve the HTTP and Websocket servers on. |
sensor_cols |
[1-10] |
The width of a sensor widget on the brewing dashboard. |
setup |
YES|NO |
Show the setup dialog. |
step_boil |
BoilStep|ChilStep|MashInStep|MashStep|PumpStep |
Default boil step type. |
step_boil_kettle |
KettleId |
Default boil tun, specified by the id of the kettle. |
step_chil |
BoilStep|ChilStep|MashInStep|MashStep|PumpStep |
Default chill step type. |
step_mash |
BoilStep|ChilStep|MashInStep|MashStep|PumpStep |
Default mash step type. |
step_mash_kettle |
KettleId |
Default mash tun, specified by the id of the kettle. |
step_mashin |
BoilStep|ChilStep|MashInStep|MashStep|PumpStep |
Default mash in step type. |
unit |
C|F |
Type of temperature unit to use. |
Each configuration property is able to be changed by using the setValue function provided on each Property object. Below is an example of what it might look like to update the brewery name:
// Returns a list of configurable properties
const config = await sdk.config.getConfig();
// Returns {description: "Your brewery name", name: "brewery_name", options: null, type: "text", value: "MyTestBrewery4", …}
const updatedProperty = await config.brewery_name.setValue('MyTestBrewery4');You can subscribe to property updates using the onUpdate function. Your registered function will be called with the following data as a tuple: (event_name, updated_property). The onUpdate function itself returns a function that allows the caller to unsubscribe/deregister the listener at some point in the future.
Possible configuration events:
UPDATE_CONFIG
Example event handler
const unsubcribe = sdk.config.onUpdate((event_name, updated_property) =>
console.log(`${event_name}: ${JSON.stringify(updated_property)}`));
// Change a config value
const config = await sdk.config.getConfig();
await config.brewery_name.setValue('New Brewery Name');
// When the brew name is changed, or any other action that triggers an update, this log occurs:
// UPDATE_CONFIG: {description: "Your brewery name", name: "brewery_name", options: null, type: "text", value: "New Brewery Name", …}
unsubcribe (); // No more events